
Ublas : 
Subject: Re: [ublas] Bug in Ublas' Inner Product between Matrix and Vector?
From: simon.carlstedt_at_[hidden]
Date: 20090129 22:50:19
How do you do your inner product? The prod function will give you the
standard matrivvector calc.
Which means, prod(inputMat,inputVec) is calculation of dimension [5 times 5
matrix] X [5 times 1 vector] giving you dimension a [5 times 1 vector] as
result, each element will be calced as:
result[element_i] = innerproduct(inputMat[row_i], inputVec) ,i = 1..5
(this is just pseudo code obv)
consider for example the third element you are discussing:
result[element_3] = innerproduct( (0, 0, 0.00528298, 0, 0) , (0.4, 0.2,
0.2, 0.2, 0.2) ) = 0.4*0 + 0.2*0 + 0.2*0.00528298 + 0.2*0 + 0.2* 0 =
0.2*0.00528298 = 0.001056596
(fourth and fifth element will result in 0.2*1 in the same way as above)
Cheers Simon
On Jan 30, 2009 2:17pm, Gundala Viswanath <gundalav_at_[hidden]> wrote:
> Hi all,
>
>
>
>
>
> I am trying to perform an inner product multiplication
>
>
> with ublas between this Matrix and Vector:
>
>
>
>
>
> ublas::matrix 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 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 Result (5);
>
>
> Result = ublas::prod(inputMat,inputVec);
>
>
>
>
>
>
>
>
> Is there anything wrong with my way of doing inner product
>
>
> or it is a bug?
>
>
>
>
>
>  Gundala Viswanath
>
>
> Jakarta  Indonesia
>
>
> _______________________________________________
>
>
> ublas mailing list
>
>
> ublas_at_[hidden]
>
>
> http://lists.boost.org/mailman/listinfo.cgi/ublas
>
>
>