Registered Member
|
Hi,
X is a matrix and y is the column vector corresponding to X's righmost column. I want to compute the product "yT X", which I call sumXy in the code. There are two ways to compute this with libeigen. One way is just "y.transpose() * x". The other way is to compute each row's product with x, accumulating the result, all done using libeigen. I find that the two ways don't always give the same exact result. Is this expected? If not, I have a bug. Otherwise, what's one way libeigen could be computing "y.transpose() * x" that results in such a difference? I'm running this on x86-64.
|
Moderator
|
yes this has to be expected with floating point precision because, for instance, (a+b)+c is different than a+(b+c). In your case, the difference should be in the order of 1e-14. You can check the relative error as follows:
[code] sumXy2 = y.transpose() * x; cout << (sumXy2-sumXy).norm() / sumXy2.norm() << "\n"; [code] |
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]