Given vector<vector<double > > A_STL
, I want it to get converted into arma::mat A
.
One simple way would be to flatten your vector of vector matrix into one dimensional vector. And you can therefore use your mat(std::vector)
constructor.
Code example (not tested) :
// Flatten your A_STL into A_flat
std::vector<double> A_flat;
for (auto vec : A_STL) {
for (auto el : vec) {
A_flat.push_back(el);
}
}
// Create your Armadillo matrix A
mat A(A_flat);
Beware of how you order your vector of vector. A_flat should be column major.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With