@@ -3,26 +3,24 @@ module DataInterpolationsSparseConnectivityTracerExt
3
3
using SparseConnectivityTracer: AbstractTracer, Dual, primal, tracer
4
4
using SparseConnectivityTracer: GradientTracer, gradient_tracer_1_to_1
5
5
using SparseConnectivityTracer: HessianTracer, hessian_tracer_1_to_1
6
- using FillArrays: Fill # from FillArrays.jl
6
+ using FillArrays: Fill
7
7
using DataInterpolations:
8
- AbstractInterpolation,
9
- LinearInterpolation ,
10
- QuadraticInterpolation ,
11
- LagrangeInterpolation ,
12
- AkimaInterpolation ,
13
- ConstantInterpolation ,
14
- QuadraticSpline ,
15
- CubicSpline ,
16
- BSplineInterpolation ,
17
- BSplineApprox ,
18
- CubicHermiteSpline ,
19
- # PCHIPInterpolation ,
20
- QuinticHermiteSpline ,
21
- output_size
8
+ AbstractInterpolation,
9
+ AkimaInterpolation ,
10
+ BSplineApprox ,
11
+ BSplineInterpolation ,
12
+ ConstantInterpolation ,
13
+ CubicHermiteSpline ,
14
+ CubicSpline ,
15
+ LagrangeInterpolation ,
16
+ LinearInterpolation ,
17
+ QuadraticInterpolation ,
18
+ QuadraticSpline ,
19
+ QuinticHermiteSpline ,
20
+ SmoothedLinearInterpolation ,
21
+ output_size
22
22
23
- #= ==========#
24
23
# Utilities #
25
- #= ==========#
26
24
27
25
# Limit support to `u` begin an AbstractVector{<:Number} or AbstractMatrix{<:Number},
28
26
# to avoid any cases where the output size is dependent on the input value.
@@ -33,26 +31,26 @@ function _sct_interpolate(
33
31
uType:: Type{<:AbstractVector{<:Number}} ,
34
32
t:: GradientTracer ,
35
33
is_der_1_zero,
36
- is_der_2_zero,
37
- )
34
+ is_der_2_zero
35
+ )
38
36
return gradient_tracer_1_to_1 (t, is_der_1_zero)
39
37
end
40
38
function _sct_interpolate (
41
39
:: AbstractInterpolation ,
42
40
uType:: Type{<:AbstractVector{<:Number}} ,
43
41
t:: HessianTracer ,
44
42
is_der_1_zero,
45
- is_der_2_zero,
46
- )
43
+ is_der_2_zero
44
+ )
47
45
return hessian_tracer_1_to_1 (t, is_der_1_zero, is_der_2_zero)
48
46
end
49
47
function _sct_interpolate (
50
48
interp:: AbstractInterpolation ,
51
49
uType:: Type{<:AbstractMatrix{<:Number}} ,
52
50
t:: GradientTracer ,
53
51
is_der_1_zero,
54
- is_der_2_zero,
55
- )
52
+ is_der_2_zero
53
+ )
56
54
t = gradient_tracer_1_to_1 (t, is_der_1_zero)
57
55
N = only (output_size (interp))
58
56
return Fill (t, N)
@@ -62,48 +60,47 @@ function _sct_interpolate(
62
60
uType:: Type{<:AbstractMatrix{<:Number}} ,
63
61
t:: HessianTracer ,
64
62
is_der_1_zero,
65
- is_der_2_zero,
66
- )
63
+ is_der_2_zero
64
+ )
67
65
t = hessian_tracer_1_to_1 (t, is_der_1_zero, is_der_2_zero)
68
66
N = only (output_size (interp))
69
67
return Fill (t, N)
70
- end
68
+ end #= ========= =#
71
69
72
- #= ==========#
73
70
# Overloads #
74
- #= ==========#
75
71
76
72
# We assume that with the exception of ConstantInterpolation and LinearInterpolation,
77
73
# all interpolations have a non-zero second derivative at some point in the input domain.
78
74
79
75
for (I, is_der1_zero, is_der2_zero) in (
80
- (:ConstantInterpolation , true , true ),
81
- (:LinearInterpolation , false , true ),
82
- (:QuadraticInterpolation , false , false ),
83
- (:LagrangeInterpolation , false , false ),
84
- (:AkimaInterpolation , false , false ),
85
- (:QuadraticSpline , false , false ),
86
- (:CubicSpline , false , false ),
87
- (:BSplineInterpolation , false , false ),
88
- (:BSplineApprox , false , false ),
89
- (:CubicHermiteSpline , false , false ),
90
- (:QuinticHermiteSpline , false , false ),
91
- )
76
+ (:AkimaInterpolation , false , false ),
77
+ (:BSplineApprox , false , false ),
78
+ (:BSplineInterpolation , false , false ),
79
+ (:ConstantInterpolation , true , true ),
80
+ (:CubicHermiteSpline , false , false ),
81
+ (:CubicSpline , false , false ),
82
+ (:LagrangeInterpolation , false , false ),
83
+ (:LinearInterpolation , false , true ),
84
+ (:QuadraticInterpolation , false , false ),
85
+ (:QuadraticSpline , false , false ),
86
+ (:QuinticHermiteSpline , false , false ),
87
+ (:SmoothedLinearInterpolation , false , false )
88
+ )
92
89
@eval function (interp:: $ (I){uType})(
93
90
t:: AbstractTracer
94
- ) where {uType <: AbstractArray{<:Number} }
91
+ ) where {uType <: AbstractArray{<:Number} }
95
92
return _sct_interpolate (interp, uType, t, $ is_der1_zero, $ is_der2_zero)
96
93
end
97
94
end
98
95
99
96
# Some Interpolations require custom overloads on `Dual` due to mutation of caches.
100
97
for I in (
101
- :LagrangeInterpolation ,
102
- :BSplineInterpolation ,
103
- :BSplineApprox ,
104
- :CubicHermiteSpline ,
105
- :QuinticHermiteSpline ,
106
- )
98
+ :LagrangeInterpolation ,
99
+ :BSplineInterpolation ,
100
+ :BSplineApprox ,
101
+ :CubicHermiteSpline ,
102
+ :QuinticHermiteSpline
103
+ )
107
104
@eval function (interp:: $ (I){uType})(d:: Dual ) where {uType <: AbstractVector }
108
105
p = interp (primal (d))
109
106
t = interp (tracer (d))
0 commit comments