How to use Eigen, a C ++ template library for linear algebra?

I have an image processing algorithm that makes out matrices, I have my own matrix opcode (multiplication, inversion ...) with me. But I use an ARM Cortex-A8 processor that has a NEON coprocessor for vectorization, since matrix operations are ideal cases for SIMD operations, I asked the compiler (-mfpu = neon -mfloat-abi = softfp) to generate NEON instructions for my code, but the compiler does not, and then I also tried to write my own NEON initialization code for Matrix operations, but it was very difficult for me to do this.

So, I thought about using the Eigen library, which promises the vectorization of matrix operations. So I quickly downloaded the Eigen C ++ library and tried to use it as indicated in their tutorials, but unfortunately I get compilation errors when I run their sample programs .

Anyone who has experience using Eigen, any examples will be really helpful? Please help me how to do this.

Help!

thanks


I have an Eigen folder: / home / ubuntu / Documents / eigen I installed this path in the additional directories of the Eclipse C ++ project. Then I run the following program (Example) -

#include <Eigen/Core> // import most common Eigen types USING_PART_OF_NAMESPACE_EIGEN int main(int, char *[]) { Matrix3f m3; m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9; Matrix4f m4 = Matrix4f::Identity(); Vector4i v4(1, 2, 3, 4); std::cout << "m3\n" << m3 << "\nm4:\n" << m4 << "\nv4:\n" << v4 << std::endl; } 

The errors I receive are -

Build the configuration Debugging for the Test_Eigen **** project

to do everything

Building File: ../ main.cpp

Call: Sourcery g ++ C ++ Compiler

arm-none-linux-gnueabi-g ++ -I / home / ubuntu / Documents / eigen -O0 -g3 -Wall -c -fmessage-length = 0 -fcommon -MMD -MP -MF "main.d" - MT "main .d "-mcpu = cortex-a8 -marm -o" main.o "

"../main.cpp"

../main.cpp: 6: error: expected constructor, destructor or type conversion before 'int' make: *** [main.o] Error 1

+4
source share
2 answers

The USING_PART_OF_NAMESPACE_EIGEN macro was deleted in Eigen 3. Instead, just use

 using namespace Eigen; 

The textbook seems to be out of date.

+10
source

I am using Ubuntu 17.04 and this is work for me
At first:
I upload egien3.3.3 to my own official site . Extracted to a directory called eigen, cd into it.
Secondly:
run the command below one at a time or create an xxx.sh file for them to run at the same time.

 #!/bin/bash #eigen3 install #from: http://eigen.tuxfamily.org/index.php?title=Main_Page #download the package like eigen-eigen-67e894c6cd8f.tar.gz mkdir build cd build cmake -DEIGEN_TEST_NO_OPENGL=1 .. make sudo make install 

Finally:
make a test

 #include <eigen3/Eigen/Core> #include <iostream> // import most common Eigen types //USING_PART_OF_NAMESPACE_EIGEN using namespace Eigen; using namespace std; int main(int, char *[]) { Matrix3f m3; m3 << 1, 2, 3, 4, 5, 6, 7, 8, 9; Matrix4f m4 = Matrix4f::Identity(); Vector4i v4(1, 2, 3, 4); cout << "m3\n" << m3 << "\nm4:\n" << m4 << "\nv4:\n" << v4 << endl; } 

Note:
To find the installed results, see / Usr / local / include / eigen 3 /
If any thing changes, see mytinx

+1
source

Source: https://habr.com/ru/post/1315811/


All Articles