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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -