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
This PR does:
* close#187; close#199; close#201
* require use of using Polynomials.PolyCompat for Poly and Pade types.
* Add ImmutablePolynomial type to take advantage of evalpoly function. Backed by an NTuple, not an array
* Add SparsePolynomial type backed by a dictionary, not an array
* Add evalpoly(x, p) method to enable broadcast for arrays of polynomials. Close#209
* refactor code from Polynomial.jl into standard-basis.jl to reuse amongst ImmutablePolynomial and Poly.jl
* add StandardBasisPolynomial abstract type
* modify + and * for immutable and sparse polynomials to close#206
* extend tests for Polynomial to cover ImmutablePolynomial, SparsePolynomial, rename test file
borrow constructorof from ConstructionBase.jl
* modify one, add oneunit
* remove restriction that T <: Number in AbstractPolynomial type. This is enforceable by subtypes
* Close#201 (issue with `round`)
Copy file name to clipboardExpand all lines: README.md
+16-4Lines changed: 16 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ Basic arithmetic, integration, differentiation, evaluation, and root finding ove
11
11
## Installation
12
12
13
13
```julia
14
-
(v1.2) pkg> add Polynomials
14
+
(v1.4) pkg> add Polynomials
15
15
16
16
julia>using Polynomials
17
17
```
@@ -21,6 +21,8 @@ julia> using Polynomials
21
21
#### Available Polynomials
22
22
23
23
*`Polynomial` - Standard polynomials
24
+
*`ImmutablePolynomial` - Standard polynomial backed by a tuple for faster evaluation of values
25
+
*`SparsePolynomial` - Standard basis polynomial backed by a dictionary to hold sparse high-degree polynomials
24
26
*`ChebyshevT` - Chebyshev polynomials of the first kind
25
27
26
28
#### Construction and Evaluation
@@ -186,14 +188,24 @@ Polynomial objects also have other methods:
186
188
187
189
## Related Packages
188
190
191
+
*[StaticUnivariatePolynomials.jl](https://github.com/tkoolen/StaticUnivariatePolynomials.jl) Fixed-size univariate polynomials backed by a Tuple
192
+
189
193
*[MultiPoly.jl](https://github.com/daviddelaat/MultiPoly.jl) for sparse multivariate polynomials
190
194
191
-
*[MultivariatePolynomials.jl](https://github.com/blegat/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
195
+
*[DynamicPolynomals.jl](https://github.com/JuliaAlgebra/DynamicPolynomials.jl) Multivariate polynomials implementation of commutative and non-commutative variables
196
+
197
+
*[MultivariatePolynomials.jl](https://github.com/JuliaAlgebra/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
198
+
199
+
*[PolynomialRings](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
200
+
201
+
*[AbstractAlgebra.jl](https://github.com/wbhart/AbstractAlgebra.jl) and [Nemo.jl](https://github.com/wbhart/Nemo.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series
202
+
203
+
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder. For larger degree problems, also [FastPolynomialRoots](https://github.com/andreasnoack/FastPolynomialRoots.jl) and [AMRVW](https://github.com/jverzani/AMRVW.jl).
192
204
193
-
*[Nemo.jl](https://github.com/wbhart/Nemo.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series
194
205
195
-
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder
206
+
## Legacy code
196
207
208
+
As of v0.7, the internals of this package were greatly generalized and new types and method names were introduced. For compatability purposes, legacy code can be run after issuing `using Polynomials.PolyCompat`.
*[StaticUnivariatePolynomials.jl](https://github.com/tkoolen/StaticUnivariatePolynomials.jl) Fixed-size univariate polynomials backed by a Tuple
215
+
214
216
*[MultiPoly.jl](https://github.com/daviddelaat/MultiPoly.jl) for sparse multivariate polynomials
215
217
216
-
*[MultivariatePolynomials.jl](https://github.com/blegat/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
218
+
*[DynamicPolynomals.jl](https://github.com/JuliaAlgebra/DynamicPolynomials.jl) Multivariate polynomials implementation of commutative and non-commutative variables
219
+
220
+
*[MultivariatePolynomials.jl](https://github.com/JuliaAlgebra/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
221
+
222
+
*[PolynomialRings](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
223
+
224
+
*[AbstractAlgebra.jl](https://github.com/wbhart/AbstractAlgebra.jl) and [Nemo.jl](https://github.com/wbhart/Nemo.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series
225
+
226
+
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder. For larger degree problems, also [FastPolynomialRoots](https://github.com/andreasnoack/FastPolynomialRoots.jl) and [AMRVW](https://github.com/jverzani/AMRVW.jl).
217
227
218
-
*[AbstractAlgeebra.jl](https://github.com/wbhart/AbstractAlgebra.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series.
219
228
220
-
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder
Copy file name to clipboardExpand all lines: src/common.jl
+13-16Lines changed: 13 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,7 @@ Returns the roots of the given polynomial. This is calculated via the eigenvalue
110
110
111
111
!!! note
112
112
113
-
The [PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) package provides an alternative that is a bit faster and abit more accurate; the [AMRVW.jl](https://github.com/jverzani/AMRVW.jl) package provides an alternative for high-degree polynomials.
113
+
The [PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) package provides an alternative that is a bit faster and a bit more accurate; the [FastPolynomialRoots](https://github.com/andreasnoack/FastPolynomialRoots.jl) provides an interface to FORTRAN code implementing an algorithm that can handle very large polynomials (it is `O(n^2)` not `O(n^3)`. the [AMRVW.jl](https://github.com/jverzani/AMRVW.jl) package implements the algorithm in Julia, allowing the use of other number types.
114
114
115
115
"""
116
116
functionroots(q::AbstractPolynomial{T}; kwargs...) where {T <:Number}
@@ -105,7 +105,25 @@ function _evalpoly(z::Complex, p)
105
105
muladd(ai, z, b)
106
106
end
107
107
108
-
## modify muladd for matrices
108
+
## modify muladd, as needed
109
109
_muladd(a,b,c) =muladd(a,b,c)
110
+
_muladd(a::Vector, b, c) = a.*b .+ c
110
111
_muladd(a::Matrix, b, c) = a*(b*I) + c*I
111
112
113
+
# try to get y = P(c::T)(x::S) = P{T}(c)(x::S) to
114
+
# have y == one(T)*one(S)*x
115
+
_one(P::Type{<:Matrix}) =one(eltype(P))*I
116
+
_one(x::Matrix) =one(eltype(x))*I
117
+
_one(x) =one(x)
118
+
119
+
## get type of parametric composite type without type parameters
120
+
## this is needed when the underlying type changes, e.g. with integration
121
+
## where T=Int might become T=Float64
122
+
##
123
+
## trick from [ConstructionBase.jl](https://github.com/JuliaObjects/ConstructionBase.jl/blob/b5686b755bd3bee29b181b3cb18fe2effa0f10a2/src/ConstructionBase.jl#L25)
124
+
## as noted in https://discourse.julialang.org/t/get-new-type-with-different-parameter/37253/4
125
+
##
126
+
@generatedfunctionconstructorof(::Type{T}) where T
0 commit comments