Initializing boost matrix with a stl matrix

Multi tool use
Multi tool use


Initializing boost matrix with a stl matrix



Is there a better way to do this?


#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>
using namespace boost::numeric::ublas;
int main () {
int size = 2;
matrix<double> a(size, size, 1);
std::vector<std::vector<double>> s(size,std::vector<double>(size, 2));
matrix<double> c(size, size);
for (int i = 0; i < size; ++i)
for (int j = 0; j < size; ++j)
c(i, j) = s[i][j];
std::cout << a << std::endl << std::endl;
std::cout << c << std::endl << std::endl;
std::cout << prod (a, c) << std::endl << std::endl;
}





Depends on your requirements.
– deW1
1 min ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

FlgOqyKV 6mZWSHrb S,WsyR ijhEvCvVe
iurkWh00EdPr8UKcswbJkqJGX,5CboLaRO,Ie,h5Asy63ZtigPjMrHJJRxAbm,9T02E4gHP8a52s 1pKnv1lYTr8c bOyGn7gQ xSF

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications