Skip to content

Commit 70a6d8d

Browse files
authored
Backport: Improve inference in normalized space derivative (#527)
* Backport: Improve inference in normalized space derivative * Fix constprop
1 parent 6ceba6e commit 70a6d8d

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunBase"
22
uuid = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"
3-
version = "0.8.47"
3+
version = "0.8.48"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Operators/banded/CalculusOperator.jl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ end
191191

192192

193193
## Map to canonical
194+
@static if VERSION >= v"1.8"
195+
for f in (:DefaultDerivative, :DefaultIntegral)
196+
_f = Symbol(:_, f)
197+
@eval Base.@constprop :aggressive $f(sp::Space, k::Number) = $_f(sp, k)
198+
end
199+
else
200+
for f in (:DefaultDerivative, :DefaultIntegral)
201+
_f = Symbol(:_, f)
202+
@eval $f(sp::Space, k::Number) = $_f(sp, k)
203+
end
204+
end
205+
194206
@inline function _DefaultDerivative(sp::Space, k::Number)
195207
assert_integer(k)
196208
if nameof(typeof(canonicaldomain(sp))) == nameof(typeof(domain(sp)))
@@ -206,34 +218,23 @@ end
206218
csp = canonicalspace(sp)
207219
D1 = if csp == sp
208220
_Dsp = invfromcanonicalD(sp)*Derivative(setdomain(sp,canonicaldomain(sp)))
209-
rsp = rangespace(_Dsp)
221+
rsp = setdomain(rangespace(_Dsp), domain(sp))
210222
_Dsp
211223
else
212224
Dcsp = Derivative(csp)
213225
rsp = rangespace(Dcsp)
214226
Dcsp * Conversion_maybeconcrete(sp, csp, Val(:forward))
215227
end
216-
D=DerivativeWrapper(SpaceOperator(D1,sp,setdomain(rsp,domain(sp))),1)
228+
D=DerivativeWrapper(D1,1,sp,rsp)
217229
if k==1
218-
D
230+
return D
219231
else
220-
DerivativeWrapper(TimesOperator(Derivative(rangespace(D),k-1),D), k, sp)
232+
Drsp = Derivative(rsp,k-1)
233+
return DerivativeWrapper(TimesOperator(Drsp,D), k, sp, rangespace(Drsp))
221234
end
222235
end
223236
end
224237

225-
@static if VERSION >= v"1.8"
226-
for f in (:DefaultDerivative, :DefaultIntegral)
227-
_f = Symbol(:_, f)
228-
@eval Base.@constprop :aggressive $f(sp::Space, k::Number) = $_f(sp, k)
229-
end
230-
else
231-
for f in (:DefaultDerivative, :DefaultIntegral)
232-
_f = Symbol(:_, f)
233-
@eval $f(sp::Space, k::Number) = $_f(sp, k)
234-
end
235-
end
236-
237238
@inline function _DefaultIntegral(sp::Space, k::Number)
238239
assert_integer(k)
239240
if nameof(typeof(canonicaldomain(sp))) == nameof(typeof(domain(sp)))

0 commit comments

Comments
 (0)