c++ - Armadillo - fill a matrix from the values in a column vector -
i go , forth between arma::mat
of size m x n , arma::vec
of size mn (which column-major linearization of matrix).
i can go matrix vector using arma::vectorise
, i.e.
arma::vec vector = arma::vectorise(matrix);
however, cannot find simple way go other way around. insert first m values of vector in first column of matrix, second m values in second column , on. there way efficiently?
make memory matrix shared vector using advanced constructors:
mat x(4,5); vec v(x.memptr(), x.n_elem, false, false); // changing elements in x or v affect both
as long operations don't cause aliasing or change size of either x
or v
, 2 objects keep sharing memory.
Comments
Post a Comment