Skip to content

Commit 5e9fbd8

Browse files
authored
constant propagation in defaultIntegral (#469)
1 parent 2b542b6 commit 5e9fbd8

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
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.27"
3+
version = "0.8.28"
44

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

src/Operators/banded/CalculusOperator.jl

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ end
189189
## Map to canonical
190190
@inline function _DefaultDerivative(sp::Space, k::Number)
191191
assert_integer(k)
192-
if typeof(canonicaldomain(sp)).name==typeof(domain(sp)).name
192+
if nameof(typeof(canonicaldomain(sp))) == nameof(typeof(domain(sp)))
193193
# this is the normal default constructor
194194
csp=canonicalspace(sp)
195195
if conversion_type(csp,sp)==csp # Conversion(sp,csp) is not banded, or sp==csp
@@ -219,22 +219,29 @@ end
219219
end
220220

221221
@static if VERSION >= v"1.8"
222-
Base.@constprop :aggressive DefaultDerivative(sp::Space, k::Number) =
223-
_DefaultDerivative(sp, k)
222+
for f in (:DefaultDerivative, :DefaultIntegral)
223+
_f = Symbol(:_, f)
224+
@eval Base.@constprop :aggressive $f(sp::Space, k::Number) = $_f(sp, k)
225+
end
224226
else
225-
DefaultDerivative(sp::Space, k::Number) = _DefaultDerivative(sp, k)
227+
for f in (:DefaultDerivative, :DefaultIntegral)
228+
_f = Symbol(:_, f)
229+
@eval $f(sp::Space, k::Number) = $_f(sp, k)
230+
end
226231
end
227232

228-
function DefaultIntegral(sp::Space, k::Number)
233+
@inline function _DefaultIntegral(sp::Space, k::Number)
229234
assert_integer(k)
230-
if typeof(canonicaldomain(sp)).name==typeof(domain(sp)).name
235+
if nameof(typeof(canonicaldomain(sp))) == nameof(typeof(domain(sp)))
231236
# this is the normal default constructor
232237
csp=canonicalspace(sp)
233238
if conversion_type(csp,sp)==csp # Conversion(sp,csp) is not banded, or sp==csp
234239
# we require that Integral is overridden
235240
error("Implement Integral($(string(sp)),$k)")
236241
end
237-
IntegralWrapper(TimesOperator([Integral(csp,k),Conversion(sp,csp)]),k)
242+
Ik = Integral(csp,k)
243+
C = Conversion_maybeconcrete(sp, csp, Val(:forward))
244+
IntegralWrapper(TimesOperator(Ik, C), k, sp, rangespace(Ik))
238245
elseif k > 1
239246
Q=Integral(sp,1)
240247
IntegralWrapper(TimesOperator(Integral(rangespace(Q),k-1),Q),k)

0 commit comments

Comments
 (0)