I found that calculation of substracting two Eigen::Vector3f is slower than the substracting two strucutre. I call 10000000 times subtraction between Eigen::Vector3f and self-defined structure. I found the speed of self-defined structure is 20 times faster then Eigen::Vector3f. Here is my test code. #include<Eigen/Eigen> #include<iostream> #include “timer.h” struct Point { float x, y, z; Point […]

Categories

## Why eigen vector is so slow?

- Post author By Full Stack
- Post date September 11, 2019
- No Comments on Why eigen vector is so slow?

- Tags 1.f, 1.f); Eigen::Vector3f dest_eigen(1.f, 1.f); Point point_a = {1.f, 1.f}; int num_tests = 10000000; std::cout << "Caculate time:" << num_tests << "\n"; Timer timer; timer.Tic(); for (int i, 1.f}; Point point_b = {1.f, const Eigen::Vector3f& vector_b) { Eigen::Vector3f result; result = vector_a - vector_b; return result; }; Point sub_point(const, const Point& point_b) { Point result = point_a.Add(point_b); return result; } int main() { Eigen::Vector3f source_eigen(1.f, dest_eigen); } timer.Toc(); std::cout << "Time[Eigen]:" << timer.TimeElapsed() << "\n"; timer.Tic(); for (int i = 0; i <, I found that calculation of substracting two Eigen::Vector3f is slower than the substracting two strucutre. I call 10000000 times subtractio, point_b); } timer.Toc(); std::cout << "Time[Point]:" << timer.TimeElapsed() << "\n"; return 0; } The result is following:, the speed of Eigen::Vector3f is nearly 20 times slower than self-defined structre. Do I use eigen in wrong way?, y, y + point.y, z + point.z }; return result; } }; Eigen::Vector3f sub_eigen(const Eigen::Vector3f& vector_a, z; Point Add(const Point& point) const { Point result = { x + point.x