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

infinite recursion in Eigen::internal::exp_retval?

Tags: None
(comma "," separated)
eudoxos
Registered Member
Posts
36
Karma
0
Hi, I am getting infinite recursion (and crash) with the following code, latest eigen from mercurial, using g++4.6 (with -std=c++0x):

Code: Select all
// typedef Eigen::Matrix<double,3,3> Matrix3r;
// Matrix3r Matrix3r T, D; double e;
// double CC(int i);

Real Tnorm=T.norm(), Dnorm=D.norm();
Matrix3r D0=D/Dnorm, T0=T/Tnorm;
Matrix3r R=D0.trace()*Matrix3r::Identity()+CC(1)*exp(CC(2)*D0);
Matrix3r R0=R/R.norm();
Real ec=(1+ec0)*exp(pow(Tnorm,1-CC(3))/(CC(4)*(1-CC(3))))-1;
Real f=CC(4)*D0.trace()+CC(5)*(e-ec)+CC(6);
Real g=-CC(6);
Real h=pow(Tnorm,CC(3));


If I run in gdb, this is bt snip (I stopped the output, it is all the same):

Code: Select all
#81724 0x00007fffe242f639 in Eigen::internal::exp_retval<Eigen::internal::global_math_functions_filtering_base<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, void>::type>::type Eigen::internal::exp<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const> >(Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const> const&) () from /usr/local/lib/yade-tr2/plugins/libplugins.so
#81725 0x00007fffe242f639 in Eigen::internal::exp_retval<Eigen::internal::global_math_functions_filtering_base<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const>, void>::type>::type Eigen::internal::exp<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const> >(Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, 3, 3, 0, 3, 3> const> const&) () from /usr/local/lib/yade-tr2/plugins/libplugins.so


What should I do? I am compiling with -ggdb2, though with EIGEN_NO_DEBUG. Could recompiling with eigen debugging help finding the bug? Or is the cause obvious for someone?

Cheers!
eudoxos
Registered Member
Posts
36
Karma
0
Replying to myself, I found that I accidentally typed
Code: Select all
exp(CC(2)*D0)
instead of
Code: Select all
(CC(2)*D0).exp()
. Strange that the compiler accepted the code.

Wouldn't it be worth to specialize std::exp template to Eigen classes to avoid such mistakes?

Sorry for noise.

v
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
just to be sure, you want the matrix exponential right? not the exponential of each coefficient...

Anyways that's weird that exp(Matrix) compiles, I'll check that...
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
ok, I got it. This is bug from our side, not from the std.
eudoxos
Registered Member
Posts
36
Karma
0
Thanks, Gael. Yes, I wanted matrix exponential. Cheers!


Bookmarks



Who is online

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