Click to enlarge uBLAS matrix / vector product

can anyone provide an example of using the uBLAS product for multiplication? Or if there is a more convenient C ++ matrix library that you can recommend, I would also welcome this. This turns into one serious headache.

Here is my code:

vector<double> myVec(scalar_vector<double>(3)); matrix<double> myMat(scalar_matrix<double>(3,3,1)); matrix<double> temp = prod(myVec, myMat); 

Here's the error:

 cannot convert from 'boost::numeric::ublas::matrix_vector_binary1<E1,E2,F>' to 'boost::numeric::ublas::matrix<T>' 

I have exhausted my search. Stackoverflow has a question about this here . The Boost documentation provides an example here . I copied the code from the example, but this is useless to me because the magic of the template that works for stdout is useless to me.

 #include <boost/numeric/ublas/matrix.hpp> #include <boost/numeric/ublas/io.hpp> int main () { using namespace boost::numeric::ublas; matrix<double> m (3, 3); vector<double> v (3); for (unsigned i = 0; i < std::min (m.size1 (), v.size ()); ++ i) { for (unsigned j = 0; j < m.size2 (); ++ j) m (i, j) = 3 * i + j; v (i) = i; } std::cout << prod (m, v) << std::endl; std::cout << prod (v, m) << std::endl; } 
+6
c ++ boost product ublas
source share
2 answers

I have not looked at Boost uBLAS much, but Eigen is sure that it is good and has good performance.

+3
source share

The product of a vector and a matrix is ​​a vector, not a matrix.

+9
source share

All Articles