diff --git a/include/armadillo_bits/spdiagview_meat.hpp b/include/armadillo_bits/spdiagview_meat.hpp index 2965cc57..1a5b113c 100644 --- a/include/armadillo_bits/spdiagview_meat.hpp +++ b/include/armadillo_bits/spdiagview_meat.hpp @@ -1043,9 +1043,13 @@ spdiagview::randu() const uword local_n_elem = n_elem; + Col tmp(local_n_elem, arma_nozeros_indicator()); + + tmp.randu(); + for(uword i=0; i < local_n_elem; ++i) { - x.at(i+row_offset, i+col_offset) = eT(arma_rng::randu()); + x.at(i+row_offset, i+col_offset) = tmp[i]; } } @@ -1062,9 +1066,13 @@ spdiagview::randn() const uword local_n_elem = n_elem; + Col tmp(local_n_elem, arma_nozeros_indicator()); + + tmp.randn(); + for(uword i=0; i < local_n_elem; ++i) { - x.at(i+row_offset, i+col_offset) = eT(arma_rng::randn()); + x.at(i+row_offset, i+col_offset) = tmp[i]; } }