Hello!

I wonder what is the best way to:

- initialize a new DMatrix with all zeros, I used DMatrix::from_element(theta_axis_size as usize, rho_axis_size as usize, 0) but maybe there is a way with the Zero trait that I couldn’t find from the source code
- find the max/min element of a DMatrix? Currently i get the data as vector and then use iter().min() but maybe there is another way how the library allows for that

Thanks!

1 Like

Hi !

Your guesses are both correct.

- initialize a new DMatrix with all zeros, I used DMatrix::from_element(theta_axis_size as usize, rho_axis_size as usize, 0) but maybe there is a way with the Zero trait that I couldn’t find from the source code

The `Zero`

trait cannot be used for dynamically-sized matrices because there would be no way to specify its size (`Zero::zero()`

takes zero arguments). So you have to use `::from_element`

indeed.

- find the max/min element of a DMatrix? Currently i get the data as vector and then use iter().min() but maybe there is another way how the library allows for that

There is no dedicated method for that. But this seems to be a common operation so maybe we could add one in future versions of nalgebra !

2 Likes