generate set of random numbers in one hit

This commit is contained in:
conrad
2024-06-08 16:46:06 +10:00
parent 478809ca0d
commit 19f8a401e8
+10 -2
View File
@@ -1043,9 +1043,13 @@ spdiagview<eT>::randu()
const uword local_n_elem = n_elem;
Col<eT> 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<eT>());
x.at(i+row_offset, i+col_offset) = tmp[i];
}
}
@@ -1062,9 +1066,13 @@ spdiagview<eT>::randn()
const uword local_n_elem = n_elem;
Col<eT> 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<eT>());
x.at(i+row_offset, i+col_offset) = tmp[i];
}
}