Questions tagged [eigen3]

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.

Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms. Homepage: http://eigen.tuxfamily.org

Please use eigen3 tag specifically for questions related to version 3 of the library.

1014 questions
2
votes
1 answer

Why does C++ Eigen require casting for matrix operations between different scalar type?

For example, if A is a double matrix, B is int matrix. A * B raises compiler error and it hast to be A.cast() * B or A * B.cast(). Why does eigen require this? It could have followed double * int = double convention of C++. Is there a performance…
Hedgehog
  • 77
  • 5
2
votes
1 answer

C++ Function Template is not deducing Eigen vector sizes

I have written a function template bool checkColinear(const std::array, 3>& points) noexcept; which takes three N-D points and returns true if they are collinear within a certain tolerance. Everything works if I…
2
votes
0 answers

Finding a quaternion of rotation between two quaternions

I am trying to understand quaternion rotations and have written these two code snippets to rotate a unit vector along the X-axis to the Y-axis. // Approach 1 Eigen::Vector3f a(1,0,0), b(0,1,0); Eigen::Quaternionf qr; qr.setFromTwoVectors(a,b); //…
2
votes
0 answers

Eigen householderQr gives nan/infs on specific singular matrix

I tried to solve linear system using colPivHouseholderQr, but received nans/infs for some specific matrices. Here is example: Eigen::MatrixXd lhs { {0. , 0. , 0. , 0. , 0. , 0.293596, 0.32315 , 0. }, …
Daiver
  • 1,488
  • 3
  • 18
  • 47
2
votes
1 answer

Eigen3 library with C++20 format

I am trying to print Eigen::Array or Eigen::Matrix with c++20 format, instead of Eigen::IOFormat. I would like to control the precision and alignment of elements in the matrix with specifiers, for example, #include #include…
Arsennnic
  • 21
  • 1
2
votes
0 answers

Eigen matrix multiply triggers code to link to libomp.dll; it is already linked to libiomp5md.lib/dll. How do I stop this spurious linkage

A short complex piece of code is built with cmake; it links to Lapack(MKL), gmp/mpir, boost,.. and eigen3 (the versions are from vcpckg and the version of eigen is eigen3:x64-windows 3.3.9#1 ). I am currently testing it on Visual Studio 2019. At…
tjl
  • 131
  • 1
  • 5
2
votes
1 answer

How to map a list of Numpy matrices to a vector of Eigen matrices in Cython

I have a C++ function which I want to run from Python. For this I use Cython. My C++ function relies heavily on Eigen matrices which I map to Python's Numpy matrices using Eigency. I cannot get this to work for the case where I have a list of Numpy…
Stefan
  • 919
  • 2
  • 13
  • 24
2
votes
0 answers

Unclear Eigen example about resizing matrix base class

I'm working with Eigen library and trying to understand what authors wanted to say about resizing base class within template. #include #include using namespace std; using namespace Eigen; template
Kerim
  • 171
  • 3
  • 10
2
votes
1 answer

conversion from Eigen::AngleAxisd to Eigen::Vector3d

I have a conversion from a rotation vector to a rotation matrix by: Eigen::Vector3d rotVec(-0.67925191, -1.35850382, -2.03775573); Eigen::AngleAxisd rotAA(rotVec.norm(), rotVec.normalized()); Eigen::Matrix3d rotationMatrix = rotAA.matrix(); Then I…
Alejandro
  • 879
  • 11
  • 27
2
votes
1 answer

2D transformations by normal vector with eigen library

I am looking for a builtin way with the eigen library to perform coordinate transformations by normal vectors in 2D space. Mathematically, it's not difficult: Let v = (v_x, v_y) be a 2D column vector and n = (n_x, n_y) be a normal vector, then the…
RL-S
  • 734
  • 6
  • 21
2
votes
0 answers

vcpkg and Eigen3: Eigen3 set to NOT FOUND

I have used vcpkg install eige3:x64-windows and then the integrate install command on Windows 10. Now, from inside CMakeLists.txt I do find_package(Eigen3 CONFIG REQUIRED), but I get the following in the Visual Studio 2019: Severity Code Description…
Ilonpilaaja
  • 1,169
  • 2
  • 15
  • 26
2
votes
2 answers

Find lowest real value in complex vector

How can I find the smallest positive real number in a complex vector of size N by 1 in Eigen3? For example, in this case I'd like to find the value 3.64038. #include #include using namespace std; using namespace Eigen; int…
rinkert
  • 6,593
  • 2
  • 12
  • 31
2
votes
1 answer

Should I install Lapack and Eigen for OpenCV?

I'm trying to build OpenCV (4.5.1) from source, from the CMake-GUI output, there are 2 third-party libraries displayed as NO. Other third-party libraries: Intel IPP: 2020.0.0 Gold [2020.0.0] at: …
user10838321
2
votes
1 answer

Eigen's matrix seems to preserve the memory in the different scope

The following snippets, I thought that standard output must be the same in the both scope1 and scope2. However, as the results shows there are not. And the result implies that m in the scope2 inherits some values from the ones in scope1. I think…
orematasaburo
  • 1,207
  • 10
  • 20
2
votes
1 answer

Eigen: create matrix from vectors

Having two vectors: Eigen::VectorXd A; A << 1, 2, 3, 4; Eigen::VectorXd B; B << 1, 2, 3; How to create following matrix C from vectors A and B? Matrix columns are equal to vector A, the elements of vector B are matrix column…