default to zero init matrix memory
@rcurtin This doesn't look like it's implemented in Bandicoot, so creating an issue to be sure. Happy to implement this.
During matrix construction, Armadillo fills matrices with zeros by default, ie. arma::mat A(4,5)
is equivalent to arma::mat A(4,5,arma::fill::zeros)
. If the user doesn't want automatic zeroing, fill::none
can be used.
For user-friendliness and consistency with Armadillo, Bandicoot should also zero initialise matrix memory by default.
The default to zero the elements is since Armadillo 10.5 (released in 2021), and was done for two reasons:
- Logical consistency with SpMat
- People were reporting weird bugs about strange values suddenly popping up in their algorithms. Turns out that sometimes the (unitiialised) matrix memory was zeros and sometimes it was full of garbage values. They incorrectly assumed that matrices (in Armadillo <= 10.4) were zeroed by default.
Having zero init as the default is the "least surprising" action, and prevents head-scratching and time-wasting bug reports later. Folks that know what they are doing can always use fill::none
to gain extra efficiency.