Vector3f(Eigen Libs)的log10

时间:2017-06-06 11:54:56

标签: eigen logarithm

我需要计算Vector3f的log10。 我试过了:

Eigen::Vector3f valsingn = svd.singularValues()/svd.singularValues()(0);
valsingn = valsingn.log10();

但它不起作用。

main.cpp:145:27: error: ‘Eigen::Vector3f {aka class Eigen::Matrix<float, 3, 1>}’ has no member named ‘log10’; did you mean ‘log’?
     valsingn = valsingn.log10();

有没有办法用这个向量计算log10

谢谢!

2 个答案:

答案 0 :(得分:2)

允许Eigen仍然使用SIMD的简单方法(我假设它已经启用)将是一个简单的基础更改:

valsingn = valsingn.array().log() / log(10.0);

或者,您可以将log10作为一元表达式传递:

 valsingn.unaryExpr(&log10); // You may have to wrap 
                             // log10 in a function of
                             // your own depending on
                             // the log10 overloads

答案 1 :(得分:1)

对于纯系数函数,您需要移至array world

Vector3f v, w;
w = v.array().log10();
w = log10(v.array());
Arrayt3f a, b;
b = a.log10();
b = log10(a);