Consider a UV::Vector{SVector{2}}
or alternatively (U,V)::Tuple{Vector,Vector}
.
I would like to compute the same matrix multiplication formula for U
and V
but would prefer storing the information in the Vector{SVector{2}}
format (technically, it’s not an SVector
but my own type).
U = U - M*U
V = V - M*V
My preference would be for a single formula UV = UV - M*UV
where UV::Vector{SVector{2}}
is a vector of static vectors (or my own similar static type actually).
The matrix M
is a sparse matrix with only Real
coefficients. In order for M*UV
to make sense, the matrix multiplication needs to broadcast each operation onto the SVector{2}
in order to do the two matrix multiplications simultaneously in a single equation instead of two equations.
The point is that it is much better for me to have UV
stored in memory, than to have U,V
separate. It would save me some allocations elsewhere if I could do the matrix multiplication like this.
How would someone go about extending the matrix multiplication for this purpose?