Implement Default for all matrix types in `nalgebra` and `nalgebra-sparse`
Currently, VecStorage has no Default impl, and CsrMatrix, CscMatrix etc. have no default impls.
I wouldn't mind giving this one a try. Would it be preferred that they generate identity matrices or 0 matrices as defaults?
I just picked up this library and came across this issue as well. Just running the following line:
let x = nalgebra::SVector::<f64, 37>::default();
fails with the following:
error[E0599]: the function or associated item `default` exists for struct `Matrix<f64, Const<37>, Const<1>, ArrayStorage<f64, 37, 1>>`, but its trait bounds were not satisfied
--> src\bin\main.rs:136:51
|
136 | let x = nalgebra::SVector::<f64, 37>::default();
| ^^^^^^^ function or associated item cannot be called due to unsatisfied trait bounds
|
::: C:\Users\acxz\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nalgebra-0.32.3\src\base\array_storage.rs:46:1
|
46 | pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
| ---------------------------------------------------------- doesn't satisfy `ArrayStorage<f64, 37, 1>: Default`
|
::: C:\Users\acxz\.cargo\registry\src\index.crates.io-6f17d22bba15001f\nalgebra-0.32.3\src\base\matrix.rs:175:1
|
175 | pub struct Matrix<T, R, C, S> {
| ----------------------------- doesn't satisfy `_: Default`
|
= note: the following trait bounds were not satisfied:
`ArrayStorage<f64, 37, 1>: Default`
which is required by `Matrix<f64, Const<37>, Const<1>, ArrayStorage<f64, 37, 1>>: Default`
Values up to 32 do work however, looks like for static vectors, default isn't implemented for sizes up to 64.
Would implementing this be feasible and part of the roadplan?
Edit: going through the code I see that values up to 127 are included: https://github.com/dimforge/nalgebra/blob/f404bcbd6d9b2acd699b0b9ec8ff387d8a9c1742/src/base/dimension.rs#L325-L334
Is there a reason or has it been simply overlooked that sizes above 32 do not implement the default trait?