Boost logo

Boost Users :

Subject: [Boost-users] Multiplying a matrix and vector ===> vector
From: Vipin Varma (varma_at_[hidden])
Date: 2012-10-26 07:08:59


Dear all,

My basic requirement is to multiply a matrix and a vector and then to
store it into a vector using Boost's UBLAS.

When I multiply a
boost::numeric::ublas::compressed_matrix with a
boost::numeric::ublas::vector using prod(matrix, vector), the output is a
boost::numeric::ublas::matrix_vector_binary1. E.g.
<PSEUDOCODE>
boost::numeric::ublas::compressed_matrix m;
boost::numeric::ublas::vector x;
boost::numeric::ublas::matrix_vector_binary1<compressed_matrix, vector, ?
> tmp;
tmp = prod(m,x);
<PSEUDOCODE>
The problem is that in the third field --- which expects the operation
type --- in line 3, I do not know what to
enter or how to specify the type of operation; I tried '*' and 'prod' and
'vector' and 'compressed_matrix' but none work.

Alternatively, I can avoid the tmp variable altogether and get a
working program to copy the result of matrix-vector multiplication onto
a new vector y but then I would
need two multiplications. E.g.
<CODE>
std::copy(prod(m,x).begin(), prod(m,x).end(), y.begin());
<CODE>

Any suggestions on how to declare a matrix_vector_binary1 correctly or
how to
get the finaly result efficiently onto a vector will be appreciated.

Regards,
Vipin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net