Skip to content

Commit 990a3a1

Browse files
authored
skip multiplying identity constop (#418)
1 parent ffbecda commit 990a3a1

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
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.7"
3+
version = "0.8.8"
44

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

src/Operators/banded/ConstantOperator.jl

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,22 @@ for op in (:+,:-)
6060
@eval ($op)(A::ConstantOperator,B::ConstantOperator) = ConstantOperator($op(A.λ,B.λ))
6161
end
6262

63-
mul_coefficients(A::ConstantOperator, b) = A.λ * b
64-
mul_coefficients!(A::ConstantOperator, b) = b .*= A.λ
65-
63+
function mul_coefficients(A::ConstantOperator, b)
64+
λ = A.λ
65+
if isone(λ)
66+
T = promote_type(typeof(λ), eltype(b))
67+
convert(AbstractVector{T}, b)
68+
else
69+
A.λ * b
70+
end
71+
end
72+
function mul_coefficients!(A::ConstantOperator, b)
73+
λ = A.λ
74+
if !isone(λ)
75+
b .*= λ
76+
end
77+
return b
78+
end
6679

6780
## Basis Functional
6881

0 commit comments

Comments
 (0)