我想在我目前正在从事的几何项目中将Eigen用于线性代数。这是一个很棒的图书馆,规模相对较小,易于使用,非常受欢迎。
但是,我也想使用一个自定义的“ Double”类,以便能够以计算机精度比较两个浮点值(类似两者之差必须小于给定的精度)。对于我的自定义类型,我已经实现了大多数std :: math c ++ 11函数和所有运算符(包括一元-,conj,imag,abs2 ...)。我做了这些链接中列出的所有操作:
http://eigen.tuxfamily.org/dox-devel/TopicCustomizingEigen.html
https://forum.kde.org/viewtopic.php?f=74&t=26631
但是,我仍然在Eigen Jacobi.h文件中遇到编译错误,更具体地讲,在340,341行是:
x[i] = c * xi + numext::conj(s) * yi;
y[i] = -s * xi + numext::conj(c) * yi;
我从编译器收到以下错误(与2012,Win32,发行版和调试配置相对)
eigen\src/Jacobi/Jacobi.h(341): error C3767: '*': candidate function(s) not accessible
在以下情况下,在我的自定义类型中定义了operator *:
CustomType operator*(CustomType const &_other);
CustomType operator*(double const &_other);
double operator*(CustomType const &_other);
我试图通过以下方式定义conj:
CustomType conj(CustomType const &_type){return _type;}
double conj(customType const &_type){return _type.get();}
我尝试在Eigen :: numext命名空间以及CustomType命名空间中定义conj,但没有成功。任何人都有暗示,链接,建议或知道我可能已经忘记的本征需求?
最有可能是因为您的代码不是const正确的。
您的运算符重载应为:
CustomType operator*(CustomType const &_other) **const**;
CustomType operator*(double const &_other) **const**;
double operator*(CustomType const &_other) **const**;
如果eigen具有对类型对象的const引用,CustomType
则无法调用您的运算符,因为它们未声明const。
即
void foo(const CustomType& x, const CustomType& y){
x * y; // Compile error, cannot call non-const operator * on const object.
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句