You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/src/extending.md
+5-5
Original file line number
Diff line number
Diff line change
@@ -30,11 +30,11 @@ As always, if the default implementation does not work or there are more efficie
30
30
|`one`|| Convenience to find constant in new basis |
31
31
|`variable`|| Convenience to find monomial `x` in new basis|
32
32
33
-
Check out both the [`Polynomial`](@ref) and [`ChebyshevT`](@ref) for examples of this interface being extended.
33
+
Check out both the [`Polynomial`](@ref) and [`ChebyshevT`](@ref) for examples of this interface being extended.
34
34
35
35
## Example
36
36
37
-
The following shows a minimal example where the polynomial aliases the vector defining the coefficients.
37
+
The following shows a minimal example where the polynomial aliases the vector defining the coefficients.
38
38
The constructor ensures that there are no trailing zeros. The `@register` call ensures a common interface. This example subtypes `StandardBasisPolynomial`, not `AbstractPolynomial`, and consequently inherits the methods above that otherwise would have been required. For other bases, more methods may be necessary to define (again, refer to [`ChebyshevT`](@ref) for an example).
39
39
40
40
```jldoctest AliasPolynomial
@@ -75,7 +75,7 @@ julia> p(3)
75
75
142
76
76
```
77
77
78
-
For the `Polynomial` type, the default on operations is to copy the array. For this type, it might seem reasonable -- to avoid allocations -- to update the coefficients in place for scalar addition and scalar multiplication.
78
+
For the `Polynomial` type, the default on operations is to copy the array. For this type, it might seem reasonable -- to avoid allocations -- to update the coefficients in place for scalar addition and scalar multiplication.
79
79
80
80
Scalar addition, `p+c`, defaults to `p + c*one(p)`, or polynomial addition, which is not inplace without addition work. As such, we create a new method and an infix operator
81
81
@@ -134,7 +134,7 @@ julia> p ./= 2
134
134
AliasPolynomial(3 + 2*x + 3*x^2 + 4*x^3)
135
135
```
136
136
137
-
Trying to divide again would throw an error, as the result would not fit with the integer type of `p`.
137
+
Trying to divide again would throw an error, as the result would not fit with the integer type of `p`.
138
138
139
139
Now `p` is treated as the vector `p.coeffs`, as regards broadcasting, so some things may be surprising, for example this expression returns a vector, not a polynomial:
140
140
@@ -147,4 +147,4 @@ julia> p .+ 2
147
147
6
148
148
```
149
149
150
-
The [`Polynomials.PnPolynomial`](@ref) type implements much of this.
150
+
The unexported `Polynomials.PnPolynomial` type implements much of this.
Copy file name to clipboardexpand all lines: docs/src/index.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Polynomials.jl
2
2
3
3
Polynomials.jl is a Julia package that provides basic arithmetic, integration,
4
-
differentiation, evaluation, and root finding over dense univariate polynomials.
4
+
differentiation, evaluation, and root finding for univariate polynomials.
5
5
6
6
To install the package, run
7
7
@@ -57,6 +57,8 @@ julia> p(1)
57
57
58
58
```
59
59
60
+
The `Polynomial` constructor stores all coefficients using the standard basis with a vector. Other types (e.g. `ImmutablePolynomial`, `SparsePolynomial`, or `FactoredPolynomial`) use different back-end containers which may have advantage for some uses.
61
+
60
62
### Arithmetic
61
63
62
64
The usual arithmetic operators are overloaded to work on polynomials, and combinations of polynomials and scalars.
@@ -101,7 +103,7 @@ ERROR: ArgumentError: Polynomials have different indeterminates
101
103
[...]
102
104
```
103
105
104
-
Except for operations involving constant polynomials.
106
+
Except for operations involving constant polynomials.
105
107
106
108
```jldoctest
107
109
julia> p = Polynomial([1, 2, 3], :x)
@@ -358,7 +360,7 @@ Most of the root finding algorithms have issues when the roots have
358
360
multiplicities. For example, both `ANewDsc` and `Hecke.roots` assume a
359
361
square free polynomial. For non-square free polynomials:
360
362
361
-
* The `Polynomials.Multroot.multroot` function is available (version v"1.2" or greater) for finding the roots of a polynomial and their multiplicities. This is based on work of Zeng.
363
+
* The `Polynomials.Multroot.multroot` function is available (version `v"1.2"` or greater) for finding the roots of a polynomial and their multiplicities. This is based on work of Zeng.
362
364
363
365
Here we see `IntervalRootsFindings.roots` having trouble isolating the roots due to the multiplicites:
Copy file name to clipboardexpand all lines: src/common.jl
+2-3
Original file line number
Diff line number
Diff line change
@@ -170,10 +170,9 @@ _wlstsq(vand, y, W::AbstractMatrix) = qr(vand' * W * vand) \ (vand' * W * y)
170
170
171
171
Returns the roots, or zeros, of the given polynomial.
172
172
173
-
This is calculated via the eigenvalues of the companion matrix. The `kwargs` are passed to the `LinearAlgeebra.eigvals` call.
174
-
175
-
!!! Note
173
+
For non-factored, standard basis polynomials the roots are calculated via the eigenvalues of the companion matrix. The `kwargs` are passed to the `LinearAlgeebra.eigvals` call.
176
174
175
+
!!! note
177
176
The default `roots` implementation is for polynomials in the
178
177
standard basis. The companion matrix approach is reasonably fast
179
178
and accurate for modest-size polynomials. However, other packages
Copy file name to clipboardexpand all lines: src/polynomials/ChebyshevT.jl
+1-1
Original file line number
Diff line number
Diff line change
@@ -35,7 +35,7 @@ julia> Polynomials.evalpoly(5.0, p, false) # bypasses the domain check done in p
35
35
36
36
The latter shows how to evaluate a `ChebyshevT` polynomial outside of its domain, which is `[-1,1]`. (For newer versions of `Julia`, `evalpoly` is an exported function from Base with methods extended in this package, so the module qualification is unnecessary.
37
37
38
-
!!! Note:
38
+
!!! note
39
39
The Chebyshev polynomials are also implemented in `ApproxFun`, `ClassicalOrthogonalPolynomials.jl`, `FastTransforms.jl`, and `SpecialPolynomials.jl`.
julia> q′ ≈ (s-1) * (s+1)^2 # works, as q is monic
522
522
true
523
523
524
-
julia> p′ ≈ (-s^2 + s + 1)
524
+
julia> p′ ≈ (-s^2 + s + 1)
525
525
true
526
526
```
527
527
528
528
529
529
530
-
!!! Note:
530
+
!!! note
531
531
There are several areas where numerical issues can arise. The `divrem`, the identification of multiple roots (`multroot`), the evaluation of the derivatives, ...
0 commit comments