Michael,
There is no matrix constructor defined that takes a std::vector as the third argument. It has to be a ublas storage array type. Look for "Storage and special containers" in http://www.boost.org/doc/libs/1_47_0/libs/numeric/ublas/doc/index.htm.
The following listing will work:
#include <iostream>
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix.hpp>
namespace ublas = boost::numeric::ublas;
void Foo(ublas::unbounded_array<double>& v)
{
ublas::matrix<double> t(2, 2, v);
std::cout << t << std::endl;
}
int main()
{
ublas::unbounded_array<double> v(4);
v[0] = 1.0; v[1] = 2.0; v[2] = 3.0; v[3] = 4.0;
Foo(v);
return 0;
}
Hello All,I have a method that takes a std::vector as one of its parameters. Is there a way I can initialize a matrix by assigning the std::vector to the matrix? Here's what I tried to do below. Does anyone know how i can achieve assigning the vector (or even a pointer of doubles) to the matrix? Thanks in advance. Mikevoid Foo(std::vector v){matrix<double> t(2, 2, v);// work with matrix...}
_______________________________________________
ublas mailing list
ublas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/ublas
Sent to: bacalfa@gmail.com