This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Incorrect evaulation of matrix expression

Tags: None
(comma "," separated)
bgreene
Registered Member
Posts
11
Karma
0
I've just run across what appears to be a fairly serious bug in the evaluation of
a particular matrix expression involving a matrix transpose and some scalars. I'm guessing it may not be known since I can reproduce
it in 3.0.2. Here is a simple test case:

void prodTest()
{
Eigen::Matrix2Xd dNdxy(2, 3);
dNdxy <<
-0.5, 0.5, 0,
-0.333333, 0, 0.333333;
double det=6.0, wt=.5;

Eigen::MatrixXd p1 = dNdxy.transpose()*dNdxy*det*wt;
Eigen::MatrixXd p2 = det*wt*dNdxy.transpose()*dNdxy;
std::cout << p1 << std::endl;
std::cout << p2 << std::endl;
}

p2 is correct but p1 is not.

Bill
jitseniesen
Registered Member
Posts
204
Karma
2
I can reproduce it, both with and without optimizations. That is quite a bad bug. It looks like the factor det in the expression for p1 is ignored (perhaps overwritten by the factor wt ?)

Thanks very much for letting us know.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Thanks a lot jitse for fixing this.... scary. This fix justify a 3.0.3 asap.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]