Skip to content

Commit c3cad8f

Browse files
authored
improve inference in Fun multiplication (#204)
* improve inference in Fun multiplication * version bump to v0.7.6 * hardcode literal exponents in intpow
1 parent 4996de6 commit c3cad8f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
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.7.5"
3+
version = "0.7.6"
44

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

src/Fun.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,14 @@ function intpow(f::Fun,k::Integer)
359359
ones(cfstype(f), space(f))
360360
elseif k==1
361361
f
362+
elseif k==2
363+
f * f
364+
elseif k==3
365+
f * f * f
366+
elseif k==4
367+
f * f * f * f
362368
else
363-
t = foldl(*, fill(f, abs(k)))
369+
t = foldl(*, fill(f, abs(k)-1), init=f)
364370
if k > 0
365371
return t
366372
else

src/Operators/banded/Multiplication.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ end
146146

147147
coefficienttimes(f::Fun,g::Fun) = Multiplication(f,space(g))*g
148148

149-
function transformtimes(f::Fun,g::Fun, n = ncoefficients(f) + ncoefficients(g) - 1, sp = space(f))
149+
@inline function transformtimes(f::Fun,g::Fun, n = ncoefficients(f) + ncoefficients(g) - 1, sp = space(f))
150150
@assert pointscompatible(sp,space(g))::Bool
151151
iszero(ncoefficients(f)) && return f
152152
iszero(ncoefficients(g)) && return g

0 commit comments

Comments
 (0)