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

Array operation not working in eigen 3.2

Tags: None
(comma "," separated)
hchang
Registered Member
Posts
1
Karma
0
Hi,

I have a program that can be successfully compiled with eigen 3.1.4 but it breaks with eigen 3.2 concerning coefficient-wise operation from array.

Here is a minimal code:
Code: Select all
#include<cmath>
#include<Eigen/Dense>

int main()
{
        Eigen::VectorXd a=Eigen::VectorXd::Random(5);
        Eigen::VectorXd b=std::tan(a.array());
        return 0;
}


When compiling with eigen 3.2 with compiler gcc 4.4.7 (default on centos 6.4), it gives the error message:
$ g++ eigen32-test.cxx -I/usr/local/include/eigen3
eigen32-test.cxx: In function 'int main()':
eigen32-test.cxx:7: error: no matching function for call to 'tan(Eigen::ArrayWrapper<Eigen::Matrix<double, -0x00000000000000001, 1, 0, -0x00000000000000001, 1> >)'
/usr/include/bits/mathcalls.h:68: note: candidates are: double tan(double)
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:444: note: float std::tan(float)
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../include/c++/4.4.7/cmath:448: note: long double std::tan(long double)


If I change the line into
Code: Select all
Eigen::VectorXd b=a.array().tan();

then compilation goes fine.

Compiling the code with g++ 4.8.1 gives the same kind of error.

Does this mean that the expression I used in the error-yielding code is obsoleted (though the "Quick reference guide" says the expression is fine), or is this a bug?

Thanks!
jitseniesen
Registered Member
Posts
204
Karma
2
We decided to move tan() and similar functions from the std namespace to the Eigen namespace, so you now have to write
Code: Select all
Eigen::VectorXd b=tan(a.array());
You don't need to specify that tan() is in the Eigen namespace because of argument-dependent lookup.

Unfortunately, we forgot to update the quick reference guide. I'll take care of it straightaway. Thanks for bringing this to our attention.


Bookmarks



Who is online

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