@@ -5,64 +5,82 @@ import DynamicPolynomials: @polyvar
55using FixedPolynomials: FixedPolynomials
66
77function __init__ ()
8- @info " Loading ElementaryPDESolutions.jl FixedPolynomials extension"
8+ return @info " Loading ElementaryPDESolutions.jl FixedPolynomials extension"
99end
1010
11- struct VecPolyFastEvaluator{N,S, T}
11+ struct VecPolyFastEvaluator{N, S, T}
1212 N:: Int64
1313 PolSystem:: FixedPolynomials.System{S}
14- cfg:: FixedPolynomials.JacobianConfig{T,S}
14+ cfg:: FixedPolynomials.JacobianConfig{T, S}
1515end
1616
17- struct ScaPolyFastEvaluator{N,T}
17+ struct ScaPolyFastEvaluator{N, T}
1818 N:: Int64
1919 Pol:: FixedPolynomials.Polynomial{T}
20- r:: FixedPolynomials.GradientDiffResult{T,Vector{T}}
20+ r:: FixedPolynomials.GradientDiffResult{T, Vector{T}}
2121 cfg:: FixedPolynomials.GradientConfig{T}
2222end
2323
24- function VecPolyFastEvaluator (N, PolSystem:: FixedPolynomials.System{S} ,
25- cfg:: FixedPolynomials.JacobianConfig{T,S} ) where {S,T}
26- return VecPolyFastEvaluator {N,S,T} (N, PolSystem, cfg)
24+ function VecPolyFastEvaluator (
25+ N, PolSystem:: FixedPolynomials.System{S} ,
26+ cfg:: FixedPolynomials.JacobianConfig{T, S}
27+ ) where {S, T}
28+ return VecPolyFastEvaluator {N, S, T} (N, PolSystem, cfg)
2729end
2830
29- function ScaPolyFastEvaluator (N, Pol, r:: FixedPolynomials.GradientDiffResult{T} ,
30- cfg:: FixedPolynomials.GradientConfig{T} ) where {T}
31- return ScaPolyFastEvaluator {N,T} (N, Pol, r, cfg)
31+ function ScaPolyFastEvaluator (
32+ N, Pol, r:: FixedPolynomials.GradientDiffResult{T} ,
33+ cfg:: FixedPolynomials.GradientConfig{T}
34+ ) where {T}
35+ return ScaPolyFastEvaluator {N, T} (N, Pol, r, cfg)
3236end
3337
34- Base. length (VPFE:: VecPolyFastEvaluator{N,S, T} ) where {N,S, T} = length (VPFE. PolSystem)
38+ Base. length (VPFE:: VecPolyFastEvaluator{N, S, T} ) where {N, S, T} = length (VPFE. PolSystem)
3539
3640"""
3741 fast_evaluate_with_jacobian!(vals::AbstractArray{S}, grad::AbstractArray{S}, x::AbstractVector{S}, VPFE::VecPolyFastEvaluator{N,S,T})
3842
3943Evaluate an M-length vector of `N`-variate polynomials `VPFE` at point `x`, with values placed in the vector `vals` and its gradient placed in the array `grad` of size MxN.
4044"""
41- function ElementaryPDESolutions. fast_evaluate_with_jacobian! (vals:: AbstractArray{S} ,
42- grad:: AbstractArray{S} ,
43- x:: AbstractVector{S} ,
44- VPFE:: VecPolyFastEvaluator {N,S,
45- T}) where {N,
46- S,
47- T}
45+ function ElementaryPDESolutions. fast_evaluate_with_jacobian! (
46+ vals:: AbstractArray{S} ,
47+ grad:: AbstractArray{S} ,
48+ x:: AbstractVector{S} ,
49+ VPFE:: VecPolyFastEvaluator {
50+ N, S,
51+ T,
52+ }
53+ ) where {
54+ N,
55+ S,
56+ T,
57+ }
4858 @assert length (vals) == length (VPFE. PolSystem)
4959 @assert size (grad) == (length (VPFE. PolSystem), N)
50- return FixedPolynomials. evaluate_and_jacobian! (vals, grad, VPFE. PolSystem, x,
51- VPFE. cfg)
60+ return FixedPolynomials. evaluate_and_jacobian! (
61+ vals, grad, VPFE. PolSystem, x,
62+ VPFE. cfg
63+ )
5264end
5365
5466"""
5567 fast_evaluate_with_jacobian!(vals::AbstractArray{S}, grad::AbstractArray{S}, x::AbstractVector{S}, SPFE::ScaPolyFastEvaluator{N,S,T})
5668
5769Evaluate an `N`-variate polynomial `SPFE` at point `x`, with values placed in the vector `vals` and its gradient placed in the array `grad`.
5870"""
59- function ElementaryPDESolutions. fast_evaluate_with_gradient! (vals:: AbstractArray{S} ,
60- grad:: AbstractArray{S} ,
61- x:: AbstractVector{S} ,
62- SPFE:: ScaPolyFastEvaluator {N,
63- T}) where {N,
64- S,
65- T}
71+ function ElementaryPDESolutions. fast_evaluate_with_gradient! (
72+ vals:: AbstractArray{S} ,
73+ grad:: AbstractArray{S} ,
74+ x:: AbstractVector{S} ,
75+ SPFE:: ScaPolyFastEvaluator {
76+ N,
77+ T,
78+ }
79+ ) where {
80+ N,
81+ S,
82+ T,
83+ }
6684 @assert SPFE. N == length (x)
6785 @assert length (grad) == N
6886 FixedPolynomials. gradient! (SPFE. r, SPFE. Pol, x, SPFE. cfg)
7593
7694Evaluate a vector of polynomials `VPFE` at point `x`, with values placed in the vector `vals`.
7795"""
78- function ElementaryPDESolutions. fast_evaluate! (vals:: AbstractArray{S} , x:: AbstractVector{S} ,
79- VPFE:: VecPolyFastEvaluator{N,S,T} ) where {N,
80- S,
81- T}
96+ function ElementaryPDESolutions. fast_evaluate! (
97+ vals:: AbstractArray{S} , x:: AbstractVector{S} ,
98+ VPFE:: VecPolyFastEvaluator{N, S, T}
99+ ) where {
100+ N,
101+ S,
102+ T,
103+ }
82104 @assert VPFE. N == length (x)
83105 @assert length (vals) == length (VPFE. PolSystem)
84106 return FixedPolynomials. evaluate! (vals, VPFE. PolSystem, x, VPFE. cfg)
89111
90112Evaluate polynomial `SPFE` at point `x`, with value placed in `val`.
91113"""
92- function ElementaryPDESolutions. fast_evaluate! (val:: AbstractArray{S} , x:: AbstractVector{S} ,
93- SPFE:: ScaPolyFastEvaluator{N,T} ) where {N,S,
94- T}
114+ function ElementaryPDESolutions. fast_evaluate! (
115+ val:: AbstractArray{S} , x:: AbstractVector{S} ,
116+ SPFE:: ScaPolyFastEvaluator{N, T}
117+ ) where {
118+ N, S,
119+ T,
120+ }
95121 @assert SPFE. N == length (x)
96122 return val = FixedPolynomials. evaluate (SPFE. Pol, x, SPFE. cfg)
97123end
@@ -103,9 +129,15 @@ Perform precomputations for fast evaluation of a `Vector` of `N`-variate
103129`Polynomial` of input type `S`, with coefficients of type T. Return a
104130`VecPolyFastEvaluator` object for online use.
105131"""
106- function ElementaryPDESolutions. assemble_fastevaluator (Pols:: Vector {ElementaryPDESolutions. Polynomial{N,
107- T}},
108- :: Type{S} ) where {N,S,T}
132+ function ElementaryPDESolutions. assemble_fastevaluator (
133+ Pols:: Vector {
134+ ElementaryPDESolutions. Polynomial{
135+ N,
136+ T,
137+ },
138+ },
139+ :: Type{S}
140+ ) where {N, S, T}
109141 if N == 1
110142 @polyvar x
111143 elseif N == 2
@@ -132,8 +164,10 @@ function ElementaryPDESolutions.assemble_fastevaluator(Pols::Vector{ElementaryPD
132164 elseif N == 2
133165 PolArray[polind] = FixedPolynomials. Polynomial (exp_data, coeff_data, [:x , :y ])
134166 else
135- PolArray[polind] = FixedPolynomials. Polynomial (exp_data, coeff_data,
136- [:x , :y , :z ])
167+ PolArray[polind] = FixedPolynomials. Polynomial (
168+ exp_data, coeff_data,
169+ [:x , :y , :z ]
170+ )
137171 end
138172 end
139173 PolSystem = FixedPolynomials. System (PolArray)
147181Perform precomputations for fast evaluation of a `Polynomial` on points of type `S`.
148182Return a `ScaPolyFastEvaluator` object for online use.
149183"""
150- function ElementaryPDESolutions. assemble_fastevaluator (Pol:: ElementaryPDESolutions.Polynomial {N,
151- T},
152- :: Type{S} ) where {N,S,T}
184+ function ElementaryPDESolutions. assemble_fastevaluator (
185+ Pol:: ElementaryPDESolutions.Polynomial {
186+ N,
187+ T,
188+ },
189+ :: Type{S}
190+ ) where {N, S, T}
153191 if N == 1
154192 @polyvar x
155193 elseif N == 2
0 commit comments