Skip to content

Commit a7712bb

Browse files
committed
Allow multiplication with different algebras
1 parent f998c9f commit a7712bb

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/arithmetic.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,24 @@ function MA.operate_to!(
127127
return res
128128
end
129129

130+
function mstructure(args::AbstractStarAlgebra...)
131+
for arg in args
132+
@assert arg == first(args)
133+
end
134+
return mstructure(basis(args[1]))
135+
end
136+
137+
function MA.operate!(
138+
::UnsafeAddMul{typeof(*)},
139+
res::AlgebraElement,
140+
A::BasisTransformation,
141+
args::Vararg{AlgebraElement,N},
142+
) where {N}
143+
mstr = mstructure(algebra(res), algebra.(args)...)
144+
MA.operate!(UnsafeAddMul(mstr), coeffs(res), coeffs.(args)...)
145+
return res
146+
end
147+
130148
function MA.operate!(
131149
::UnsafeAddMul{typeof(*)},
132150
res::AlgebraElement,
@@ -137,7 +155,7 @@ function MA.operate!(
137155
@assert parent(res) == parent(arg)
138156
end
139157
end
140-
mstr = mstructure(basis(res))
158+
mstr = mstructure(basis(res), basis.(args)...)
141159
MA.operate!(UnsafeAddMul(mstr), coeffs(res), coeffs.(args)...)
142160
return res
143161
end

0 commit comments

Comments
 (0)