Boost logo

Boost Users :

Subject: Re: [Boost-users] Inner Product and Sparse Matrix in Boost
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-01-27 06:00:04


Gundala Viswanath wrote:
> Is there a boost library that allow inner product
> between sparse matrix and vector?

The uBlas library
(http://www.boost.org/doc/libs/1_37_0/libs/numeric/ublas/doc/index.htm)
might help you here. The following code compiles at least, so there is
good hope that it does more or less what you want. (There is a special
mailing list for ublas, if you need more information/help.)

#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>

void test()
{
   boost::numeric::ublas::mapped_matrix<double> A(3,3, 3*3);
   boost::numeric::ublas::compressed_matrix<double> B(3,3, 3*3);
   boost::numeric::ublas::coordinate_matrix<double> C(3,3, 3*3);
   boost::numeric::ublas::vector<double> x(3);
   boost::numeric::ublas::vector<double> a =
boost::numeric::ublas::prod(A,x);
   boost::numeric::ublas::vector<double> b =
boost::numeric::ublas::prod(B,x);
   boost::numeric::ublas::vector<double> c =
boost::numeric::ublas::prod(C,x);
   boost::numeric::ublas::vector<double> d =
boost::numeric::ublas::prod(x,C);
}

Regards,
Thomas


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