@@ -11,26 +11,32 @@ An abstract container for various polynomials.
11
11
- `coeffs` - The coefficients of the polynomial
12
12
- `var` - The indeterminate of the polynomial
13
13
"""
14
- abstract type AbstractPolynomial{T <: Number } end
14
+ abstract type AbstractPolynomial{T<: Number } end
15
15
16
16
17
17
macro register (name)
18
18
poly = esc (name)
19
19
quote
20
- Base. convert (:: Type{P} , p:: P ) where {P <: $poly } = p
21
- Base. convert (P:: Type{<:$poly} , p:: $poly ) where {T} = P (p. coeffs, p. var)
22
- Base. promote_rule (:: Type{$poly{T}} , :: Type{$poly{S}} ) where {T,S} = $ poly{promote_type (T, S)}
23
- Base. promote_rule (:: Type{$poly{T}} , :: Type{S} ) where {T,S <: Number } = $ poly{promote_type (T, S)}
24
-
25
- function (p:: $poly )(x:: AbstractVector )
26
- Base. depwarn (" Calling p(x::AbstractVector is deprecated. Use p.(x) instead." , Symbol (" (p::AbstractPolynomial)" ))
27
- return p .(x)
28
- end
29
-
30
- $ poly (coeffs:: AbstractVector{T} , var:: SymbolLike = :x ) where {T} = $ poly {T} (coeffs, Symbol (var))
31
- $ poly (n:: Number , var = :x ) = $ poly ([n], var)
32
- $ poly {T} (n:: S , var = :x ) where {T,S <: Number } = $ poly (T (n), var)
33
- $ poly {T} (x:: AbstractVector{S} , var = :x ) where {T,S <: Number } = $ poly (T .(x), var)
20
+ Base. convert (:: Type{P} , p:: P ) where {P<: $poly } = p
21
+ Base. convert (P:: Type{<:$poly} , p:: $poly ) where {T} = P (p. coeffs, p. var)
22
+ Base. promote_rule (:: Type{$poly{T}} , :: Type{$poly{S}} ) where {T,S} =
23
+ $ poly{promote_type (T, S)}
24
+ Base. promote_rule (:: Type{$poly{T}} , :: Type{S} ) where {T,S<: Number } =
25
+ $ poly{promote_type (T, S)}
26
+
27
+ function (p:: $poly )(x:: AbstractVector )
28
+ Base. depwarn (
29
+ " Calling p(x::AbstractVector is deprecated. Use p.(x) instead." ,
30
+ Symbol (" (p::AbstractPolynomial)" ),
31
+ )
32
+ return p .(x)
33
+ end
34
+
35
+ $ poly (coeffs:: AbstractVector{T} , var:: SymbolLike = :x ) where {T} =
36
+ $ poly {T} (coeffs, Symbol (var))
37
+ $ poly (n:: Number , var = :x ) = $ poly ([n], var)
38
+ $ poly {T} (n:: S , var = :x ) where {T,S<: Number } = $ poly (T (n), var)
39
+ $ poly {T} (x:: AbstractVector{S} , var = :x ) where {T,S<: Number } = $ poly (T .(x), var)
34
40
35
41
end
36
42
end
0 commit comments