Bug in Ublas' Inner Product between Matrix and Vector?

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? - Gundala Viswanath Jakarta - Indonesia

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
participants (2)
-
Gundala Viswanath
-
Steven Watanabe