sparsemat / sprs

sparse linear algebra library for rust
Apache License 2.0
392 stars 46 forks source link

Implement ndarray::linalg::dot? #156

Closed pmarks closed 5 years ago

pmarks commented 5 years ago

I'm trying to write some large-scale SVDs methods that are generic over the type of the input array -- I'd like to to support ndarray::ArrayBase, sprs, and a custom compressed matrix format.

I noticed that ndarray uses this trait for matrix-matrix or matrix-vector multiply: ndarray::linalg::Dot, but sprs use std::ops::Mul. (ndarray uses Mul for point-wise multiplication).

  1. Would you be open to adding implementations of Dot to mirror the implementations of Mul?
  2. Should sprs consider switching to the case convention as ndarray?
vbarrielle commented 5 years ago

I think adding a ndarray::linalg::dot implementation is a good idea. I would keep the Mul implementation though, as the types in sprs are matrices, not arrays, so the natural expectation is that the multiplication is matrix multiplication.

It should however be possible to add another type, a sparse array type, that would implement Mul for coefficient-wise multiplication.