Reputation: 274
II would like to use Eigen for linear algebra in a geometry project I am currently working on. It is a great library relatively small and easy to use and popular enough.
However, I would also like to use a custom defined "Double" class to be able to compare two floating point values in computer precision (something like the difference between the two must be smaller than a given precision). For my custom type, I have implemented most of the std::math c++11 functions and all operators (including unary -, conj, imag, abs2...). I did everything listed in these links :
http://eigen.tuxfamily.org/dox-devel/TopicCustomizingEigen.html
https://forum.kde.org/viewtopic.php?f=74&t=26631
However, I still get compilation errors in Eigen Jacobi.h file, more specifically at line 340,341 which are :
x[i] = c * xi + numext::conj(s) * yi;
y[i] = -s * xi + numext::conj(c) * yi;
I get the following error from the compiler (Vs 2012, Win32, Release and Debug Configuration)
eigen\src/Jacobi/Jacobi.h(341): error C3767: '*': candidate function(s) not accessible
operator* is define in my custom type for the following cases :
CustomType operator*(CustomType const &_other);
CustomType operator*(double const &_other);
double operator*(CustomType const &_other);
I tried to define conj in the following manners :
CustomType conj(CustomType const &_type){return _type;}
double conj(customType const &_type){return _type.get();}
I tried defining conj in Eigen::numext namespace as well as in my CustomType namespace with no success. Anyone has a hint, link, suggestion or know something Eigen needs I might have forgotten ?
Upvotes: 1
Views: 642
Reputation: 5941
Most likely because your code isn't const correct.
Your operator overloads should be:
CustomType operator*(CustomType const &_other) **const**;
CustomType operator*(double const &_other) **const**;
double operator*(CustomType const &_other) **const**;
If eigen has a const reference to an object of type CustomType
it cannot call your operators because they are not const declared.
I.e.
void foo(const CustomType& x, const CustomType& y){
x * y; // Compile error, cannot call non-const operator * on const object.
}
Upvotes: 1