Boost logo

Boost Users :

Subject: Re: [Boost-users] Bug in Ublas' Inner Product between Matrix and Vector?
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-01-29 22:31:09


Gundala Viswanath wrote:
> Hi all,
>
> I am trying to perform an inner product multiplication
> with ublas between this Matrix and Vector:
>
> ublas::matrix <double> inputMat (5,5,0);
> [5,5]((0.994704,0.000882587,0.000882587,0.000882587,0.00264776),(0.00527045,0.989459,0.00263523,0.00263523,0),(0,0,0.00528298,0,0),(0,0,0,1,0),(0,0,0,0,1))
>
> ublas::vector <double> inputVec (5);
> [5](0.4,0.2,0.2,0.2,0.2)
>
>
> The result I get is this:
> [5](0.398941,0.201054,0.0010566*,0.2,0.2)
>
> Where as the correct one should be (using R):
> 0.3999707,0.1981258,0.2007013*,0.2007013,0.2005310
>
> Note the significant discrepancy in the 3rd element (*).
>
> The product command I use is this:
>
> ublas::vector <double> Result (5);
> Result = ublas::prod(inputMat,inputVec);
>
>
> Is there anything wrong with my way of doing inner product
> or it is a bug?
>

The ubas version is correct. The third element of the
result is the inner product of
(0.4,0.2,0.2,0.2,0.2) and (0,0,0.00528298,0,0)
which is
0.2 * 0.00528298 = 0.0010566

I'm not sure what your trying to do. ublas::prod is
just a standard matrix/vector multiplication.

In Christ,
Steven Watanabe


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