Closed odow closed 4 months ago
I guess the problem with *(a::AbstractMutable, A::LinearAlgebra.Hermitian)
is that there is no way to know if a
is real or complex.
Why not? As far as I understand there's only three possibilities that need to be tested: GenericVariableRef{T}
, GenericAffExpr{T, GenericVariableRef{T}}
, and GenericAffExpr{Complex{T}, GenericVariableRef{T}}
. A bit cumbersome but doable, no?
We could do this in JuMP, but there is no easy fix in MutableArithmetics for arbitrary types.
I see. Maybe it is worth it to introduce RealMutableScalar
and ComplexMutableScalar
supertypes? I had a similar problem in jump-dev/Hypatia.jl#831: I needed to dispatch a function on whether the argument was a real or complex Mutable, and I couldn't figure out how. So in the end I just did a ugly hack hoping that a better programmer could fix it.
I'd rather not do that unless absolutely necessary. MA is already too complicated. In this case, the answer is still correct, it's just not the most performant.
We can fix this in JuMP though, so I'll move the issue.
x-ref https://github.com/jump-dev/MutableArithmetics.jl/issues/264#issuecomment-1971966048