Skip to content

Commit 3ffe8cd

Browse files
Merge pull request #300 from albertomercurio/master
Fix StackOverFlowError on multiplication between ScalarOperator and UniformScalar
2 parents 347c2be + 86a5e22 commit 3ffe8cd

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/scalar.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,16 +379,14 @@ end
379379
for T in SCALINGNUMBERTYPES[2:end]
380380
@eval function Base.:*::ScalarOperator, x::$T)
381381
if isconstant(α)
382-
T2 = promote_type($T, eltype(α))
383-
return ScalarOperator(convert(T2, α) * x, α.update_func)
382+
return ScalarOperator(concretize(α) * x)
384383
else
385384
return ComposedScalarOperator(α, ScalarOperator(x))
386385
end
387386
end
388387
@eval function Base.:*(x::$T, α::ScalarOperator)
389388
if isconstant(α)
390-
T2 = promote_type($T, eltype(α))
391-
return ScalarOperator(convert(T2, α) * x, α.update_func)
389+
return ScalarOperator(concretize(α) * x)
392390
else
393391
return ComposedScalarOperator(ScalarOperator(x), α)
394392
end

test/scalar.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ K = 12
7474
copy!(w, orig_w)
7575
α(w, v, u, nothing, 0.0, a, b)
7676
@test w a * (x * v) + b * orig_w
77+
78+
# Operations with UniformScalar
79+
α = ScalarOperator(1)
80+
@test α * I == α
81+
@test α + I isa AddedScalarOperator
7782
end
7883

7984
@testset "ScalarOperator Combinations" begin

0 commit comments

Comments
 (0)