Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/scalar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,16 +379,14 @@ end
for T in SCALINGNUMBERTYPES[2:end]
@eval function Base.:*(α::ScalarOperator, x::$T)
if isconstant(α)
T2 = promote_type($T, eltype(α))
return ScalarOperator(convert(T2, α) * x, α.update_func)
return ScalarOperator(concretize(α) * x)
else
return ComposedScalarOperator(α, ScalarOperator(x))
end
end
@eval function Base.:*(x::$T, α::ScalarOperator)
if isconstant(α)
T2 = promote_type($T, eltype(α))
return ScalarOperator(convert(T2, α) * x, α.update_func)
return ScalarOperator(concretize(α) * x)
else
return ComposedScalarOperator(ScalarOperator(x), α)
end
Expand Down
5 changes: 5 additions & 0 deletions test/scalar.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ K = 12
copy!(w, orig_w)
α(w, v, u, nothing, 0.0, a, b)
@test w ≈ a * (x * v) + b * orig_w

# Operations with UniformScalar
α = ScalarOperator(1)
@test α * I == α
@test α + I isa AddedScalarOperator
end

@testset "ScalarOperator Combinations" begin
Expand Down
Loading