c++ - Armadillo: Obtain raw data from matrix/vector as array -
i searching this:
fmat = randu<fmat>(4,5); float **a = a.to_array(); // return matrix float**
does know how 1 in armadillo
?
there no function return array of pointers. can access underlying buffer memptr()
method:
float *a = a.memptr();
you can pointer matrix column colptr()
method. i'm not sure why might need array of pointers build 1 (uncompiled , untested code):
std::vector<float *> av; av.reserve(a.n_cols); (unsigned int = 0; < a.n_cols; ++i) av.push_back() = a.colptr(i); float **a = &av[0]; // remains valid while av in scope
note armadillo stores data in column-major order.
Comments
Post a Comment