![]() |
Blitz Support : |
From: Toby Walsh (twalsh_at_[hidden])
Date: 2004-08-09 03:57:54
Hi Xianglong,
Here's what I've got in my linear algebra wrapper class. The only line that
does anything is the "res = ..." line, so you could just put that where you
need multiplication (and of course the blitz::indices must be defined).
Hope that helps,
Toby
// Matrix-Matrix multiplication.
// Precondition: m1.columns() == m2.rows().
// Param: m1 is lhs of the multiplication.
// Param: m2 is rhs of the multiplication.
// Returns: the product of m1 and m2.
Matrix Multiply(Matrix const& m1, Matrix const& m2)
{
assert(m1.columns() == m2.rows());
Matrix res(m1.rows(), m2.columns());
blitz::firstIndex i;
blitz::secondIndex j;
blitz::thirdIndex k;
res = sum(m1(i,k) * m2(k,j), k);
return res;
}
At 08:21 AM 8/8/2004 -0400, you wrote:
>Hi, there,
>
>I'm new with Blitz, and would like to do a matrix multiplication.
>Particularly,
>
> M(3,N) x M(3,3) --> M(3,N)
>
>Here, N is a large number and the elements are in double precision.
>It seems to me that one cannot do a direct matrix - matrix
>multiplication with Blitz. Should I use a 2-D array to store the
>M(3,N) matrix? Then, how can I do the multiplication exactly? Anyone
>please help. A simple example will be excellent. Thanks.
>
>Xianglong
>
>_______________________________________________
>Blitz-support mailing list
>Blitz-support_at_[hidden]
>http://www.oonumerics.org/mailman/listinfo.cgi/blitz-support