Reputation: 11
How do I convert a standard C++ 2D array into an Armadillo mat
object representing a matrix, so that I can perform matrix operations?
For example, I want to convert from:
double a[10][20];
to:
arma::mat A;
Upvotes: 0
Views: 862
Reputation: 1466
Use
arma::mat A(&a[0][0], 10, 20);
if you want a copy of the buffer and:
arma::mat A(&a[0][0], 10, 20, false);
if you want to use the buffer pointed out by a
, for more detailed information see http://arma.sourceforge.net/docs.html#Mat
Upvotes: 3