JuliaAlgebra / StarAlgebras.jl

A package for computation in *-algebras with basis
MIT License
5 stars 2 forks source link

Creating a new element #40

Open blegat opened 3 weeks ago

blegat commented 3 weeks ago

MutableArithmetics assumes that zero is defined for the type of algebra elements at a few places: https://github.com/jump-dev/MutableArithmetics.jl/blob/10bf3f3a9e86061309aaab10bf6e5e7237ca04c7/src/reduce.jl#L25 https://github.com/jump-dev/MutableArithmetics.jl/blob/10bf3f3a9e86061309aaab10bf6e5e7237ca04c7/src/reduce.jl#L58 https://github.com/jump-dev/MutableArithmetics.jl/blob/10bf3f3a9e86061309aaab10bf6e5e7237ca04c7/src/implementations/LinearAlgebra.jl#L382 zero(::Type{<:AlgebraElement}) is however not defined and IIUC, it cannot be defined because it needs an object to create the algebra and it's not in the type. Actually, with DynamicPolynomials, I also have the issue that zero loses the vector of variables so maybe a solution could be found for both packages.

We could change MA to add something in the interface that allows you to do that. For a matrix-vector product with an empty matrix and an empty vector, it won't work because we cannot get an element but we actually do not need to create any element since the result is an empty vector so this is fine. But then how do we do the sum of an empty vector of algebra elements ?

blegat commented 3 weeks ago

Maybe the answer to a sum of an empty vector is MA.Zero() and the product between a n x 0 matrix with a 0-length vector if a Vector{MA.Zero}