Add a "ones" method for initializing a matrix filled with ones.
pleepleus opened this issue · comments
Is your feature request related to a problem? Please describe.
This is a QOL feature to make it simple to create a matrix that is filled with the same value. So you want to create a 10 x 10 matrix filled with the value 5. This feature would allow one to write:
let a = scale(5.0) * Mat::<f64>::ones(10, 10);
Rather than:
let a =Mat::<f64>::from_fn(10, 10, |_, _| 5.0)
Or
let mut a = Mat::<f64>::zeros(10, 10);
a.fill(5.0);
Describe the solution you'd like
A new matrix creation method called "ones" which creates a matrix of specified dimensions filled with ones.
Describe alternatives you've considered
This is a QOL feature. There are certainly options to do the same thing outlined above.
Additional context
N/A
To be consistent with numpy, we could also add a method called "full" which does this without the need for the additional multiplication.