File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -218,6 +218,26 @@ for T in SCALINGNUMBERTYPES
218218 end
219219end
220220
221+ # Special cases for constant scalars. These simplify the structure when applicable
222+ for T in SCALINGNUMBERTYPES[2 : end ]
223+ @eval function Base.:* (α:: $T , L:: ScaledOperator )
224+ isconstant (L. λ) && return ScaledOperator (α * L. λ, L. L)
225+ return ScaledOperator (L. λ, α * L. L) # Try to propagate the rule
226+ end
227+ @eval function Base.:* (L:: ScaledOperator , α:: $T )
228+ isconstant (L. λ) && return ScaledOperator (α * L. λ, L. L)
229+ return ScaledOperator (L. λ, α * L. L) # Try to propagate the rule
230+ end
231+ @eval function Base.:* (α:: $T , L:: MatrixOperator )
232+ isconstant (L) && return MatrixOperator (α * L. A)
233+ return ScaledOperator (α, L) # Going back to the generic case
234+ end
235+ @eval function Base.:* (L:: MatrixOperator , α:: $T )
236+ isconstant (L) && return MatrixOperator (α * L. A)
237+ return ScaledOperator (α, L) # Going back to the generic case
238+ end
239+ end
240+
221241Base.:- (L:: AbstractSciMLOperator ) = ScaledOperator (- true , L)
222242Base.:+ (L:: AbstractSciMLOperator ) = L
223243
You can’t perform that action at this time.
0 commit comments