Skip to content

Commit

Permalink
Allow multiplication with different algebras
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jul 3, 2024
1 parent f998c9f commit a7712bb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,24 @@ function MA.operate_to!(
return res
end

function mstructure(args::AbstractStarAlgebra...)
for arg in args
@assert arg == first(args)
end
return mstructure(basis(args[1]))
end

function MA.operate!(
::UnsafeAddMul{typeof(*)},
res::AlgebraElement,
A::BasisTransformation,
args::Vararg{AlgebraElement,N},
) where {N}
mstr = mstructure(algebra(res), algebra.(args)...)
MA.operate!(UnsafeAddMul(mstr), coeffs(res), coeffs.(args)...)
return res
end

function MA.operate!(
::UnsafeAddMul{typeof(*)},
res::AlgebraElement,
Expand All @@ -137,7 +155,7 @@ function MA.operate!(
@assert parent(res) == parent(arg)
end
end
mstr = mstructure(basis(res))
mstr = mstructure(basis(res), basis.(args)...)
MA.operate!(UnsafeAddMul(mstr), coeffs(res), coeffs.(args)...)
return res
end
Expand Down

0 comments on commit a7712bb

Please sign in to comment.