Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "ones" method for initializing a matrix filled with ones. #125

Closed
pleepleus opened this issue Apr 23, 2024 · 2 comments
Closed

Add a "ones" method for initializing a matrix filled with ones. #125

pleepleus opened this issue Apr 23, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@pleepleus
Copy link
Contributor

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

@pleepleus pleepleus added the enhancement New feature or request label Apr 23, 2024
@pleepleus
Copy link
Contributor Author

To be consistent with numpy, we could also add a method called "full" which does this without the need for the additional multiplication.

@sarah-quinones
Copy link
Owner

merged in #126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants