nalgebra icon indicating copy to clipboard operation
nalgebra copied to clipboard

Specialized matrix types

Open schneiderfelipe opened this issue 2 years ago • 2 comments

Is there a way to implement custom matrix types, such that algorithms could use its structure efficiently? Say, having a diagonal matrix storing only its diagonal and specializing matrix-vector multiplication for it?

Probably related: #822

schneiderfelipe avatar Oct 01 '21 14:10 schneiderfelipe

No, currently nothing like this is possible - and it's not likely to be possible any time soon either. A great number of methods in nalgebra rely on the storage being a dense matrix.

A DiagonalMatrix type is something I've been wanting for a while, however. Although perhaps it would be a better fit in nalgebra-sparse than nalgebra itself. This is however debatable as for example dense SVD or Eigendecompositions produce diagonal matrices. Currently these diagonal matrices are represented as vectors in nalgebra, but this is less than ideal because you cannot work with the matrix as if it were a matrix.

Andlon avatar Oct 01 '21 14:10 Andlon

I was expecting to have something like a matrix trait that could be implemented for different matrix types. But this rapidly evolves into a hierarchy of types (like in Julia), I'm afraid, and that can be hard given specialization in Rust being currently unstable (rust-lang/rust#31844).

schneiderfelipe avatar Oct 01 '21 15:10 schneiderfelipe