Questions tagged [eigen]
Eigen is a C++ template library for linear algebra: matrices, vectors, and related algorithms.
3,462
questions
0
votes
0
answers
25
views
Why would Eigen be slower at computing same calculating using columns of Eigen::Matrix vs loose Eigen::Vectors?
While trying to speed up a calculation, I was very confused to find out that it took more than twice as long to compute when loading my data into columns of a col-major Eigen::Matrix to do the ...
0
votes
0
answers
25
views
Spectra, Eigen, errors associated
I want to have the numerical errors associated to the eigenvalues it's returning. I currently use:
Eigen::SparseMatrix<float> sparse_matrix(num_el, num_el);
sparse_matrix.reserve(Eigen::...
1
vote
1
answer
45
views
How to convert between C++ ArrayFire and C++ Eigen matrices?
I am new to Eigen and looking to learn ArrayFire for GPU acceleration. I would like to implement ArrayFire within my existing Eigen code rather than having to re-code all of my functions.
Is there a ...
1
vote
1
answer
36
views
Reference on Eigen matrix with pybind11 (read/write) [duplicate]
This is an implementation of a class containing a vector of Eigen Matrix plus the definition of the python binding.
#include <vector>
#include <pybind11/eigen.h>
#include <Eigen/Dense&...
0
votes
1
answer
70
views
Mapping a C-style quaternion with different storage order with Eigen Quaternion Map
I am trying to map a C-style array which in my application represents a quaternion with components storage order w, x, y, z using an Eigen::Map<Quaternion>. The problem is that internally Eigen ...
0
votes
2
answers
45
views
Why does computation on contiguous slices of tensors take less time than doing it directly on the tensor?
I have a test, which performs an element wise multiplication operation on a large tensor and stores the result back into it, on an identical sliced view of it and on a noncontiguous sliced chipped ...
0
votes
1
answer
46
views
Odeint error: use of deleted function ‘boost::numeric::odeint::state_wrapper<State<3>&, void>::state_wrapper()’
I'm trying to write a general-purpose integrator in C++ leveraging Odeint and Eigen, but im stuck in trying to make Odeint happy about my custom State vector class that inherits from Eigen. To provide ...
2
votes
0
answers
69
views
Eigen c++ linear algebra much slower than numpy -- what is going on?
I compile the following C++ program and compile it with GCC using optimization O3. The resulting matrix inverse is about 3-4 times slower than the equivalent simple numpy code b=np.linalg.inv(a). I ...
1
vote
1
answer
55
views
Get common first zero-value indice from three dense Eigen::MatrixXi in C++
I have a NxN nonnegative Eigen::MatrixXi called cost_matrix, and two Nx1 nonnegative Eigen::VectorXi called rowVector and colVector. I want to find the first indices (i, j) such that cost_matrix(i, j),...
0
votes
1
answer
187
views
Evaluate the size in bytes of something in C++
i have a sparse matrix from eigen library defined as:
Eigen::SparseMatrix<float> MyMatrix(2**n, 2**n).
In addition I use the function reserve:
MyMatrix.reserve(Eigen::VectorXi::Constant(2**n, ...
0
votes
1
answer
46
views
Is it possible to recursively chip an Eigen Tensor based on the values specified in an array?
I am trying to create a wrapper around an Eigen::Tensor object in c++. The idea is to create a chipped view on a Tensor based on a provided array, which either specifies the row along which to chip or ...
0
votes
0
answers
45
views
C++ Eigen - Cannot run SVD due to "maxCoeff()" error
I have the following code
Eigen::SparseMatrix<double> S = A*B.transpose();
Eigen::JacobiSVD<Eigen::SparseMatrix<double>> svd(S);
Which has an error when calculating the SVD ...
0
votes
1
answer
34
views
Trouble compiling PardisoSupport with Eigen?
Below is a minimum working example of the problem I ran into recently:
My source code:
// main.cc
#define EIGEN_USE_MKL_ALL
#include <Eigen/Sparse>
#include <Eigen/PardisoSupport>
int ...
2
votes
1
answer
60
views
C++ Eigen read-only sparse block subexpression? How to write?
I would like to create one large matrix from four different matrices using Eigen's block expressions.
However, adding the first matrix in the top left corner results in the error:
error: static ...
2
votes
1
answer
123
views
what problem does "std::size_t huge = static_cast<std::size_t>(-1); ::operator new(huge);" solve in throw_std_bad_alloc?
Why is this code written this way, to solve what problem?
"::operator new(huge);" seems to cause a memory leak.
EIGEN_DEVICE_FUNC
inline void throw_std_bad_alloc()
{
#ifdef ...
0
votes
0
answers
36
views
Certification for Eigen C++ Library
We are planning to use Eigen in our projects.
Is there any software certification already available for the Eigen C++ Library?
If anybody knows of any work done in this direction, please reply.
0
votes
0
answers
29
views
unaryExpr from Eigen dosn't work with function from the same struct
I have code that applies sigmoid function to Eigen Matrix using unaryExpr
#include <Eigen/Dense>
#include <Eigen/Sparse>
#include <Eigen/Core>
#include <iostream>
using Eigen:...
-3
votes
0
answers
103
views
Linker can't find Eigen symbols on macos
I am trying to write a program and I use some Eigen features. When I try to run it I get error in the image below saying that "Undefined symbols for architecture x86_64" and "ld: symbol(...
0
votes
0
answers
48
views
EIGEN_USE_BLAS causes conflicting types errors on Mac
I wanted to try enabling blas support for a macOS application using the Eigen 3.4.90 to see if it results in any speedup for my use case. My application already links against the Apple Accelerate ...
1
vote
1
answer
33
views
About the default storage index type for Eigen::SparseMatrix
For dense matrices in Eigen, the storage index type is std::ptr_diff by default, but can be adjusted with a processor directive setting EIGEN_DEFAULT_DENSE_INDEX_TYPE (affects all code).
For sparse ...
0
votes
0
answers
25
views
Reuse patterns in sparse matrix-matrix product with Eigen lilbrary
I am new to numerical computing and have some questions about pattern reusing in sparse operations.
I have two sparse matrices A and B, whose non-zero-patterns never change.
I want to compute C=A*B in ...
0
votes
1
answer
54
views
How to traverse the matix rows for index not in a special index vector P by Eigen?
Today i met a trouble.I have a special index vector P,and a matrix A.for example:
MatrixXd B = MatrixXd::Ones(10, 10);
std::cout << B;
std::vector<int> P = { 1, 6, 3, 7, 5 };
...
0
votes
0
answers
47
views
What's wrong with my initialization using Eigen?
i want to initialize a Matrix ,but it is not what I expected.
int main()
{
int N = 84; /
MatrixXd A(N, N);
VectorXd b(N);
// initialization
for (int i = 0; i < N - 1; i++)
{...
0
votes
0
answers
67
views
How to get matrix induce L1 norm by Eigen?
Using C++ Eigen library, how to get Matrix L1 norm?
If I use method A.lpnorm<1>() I can not get a Matrix L1 norm, instead, it returns sums of every abs of members in the Matrix.
using namespace ...
0
votes
0
answers
34
views
Nanobind fails converting complex np array to Eigen complex vector
System:
Mac OSX 13.5.2
Apple Clang
Here is a test project:
complex_test/
.git/
nanobind/ # added as git submodule
eigen/ # added as git submodule
- CMakeLists.txt
- complex_test.cpp
- ...
0
votes
1
answer
38
views
Eigen Sparse Matrix, does the constructor and resize(int, int) ever form a dense representation?
The Eigen SparseMatrix has the functions:
SparseMatrix(Index,Index)
resize(Index, Index)
makeCompress()
I want to store a large but (really) sparse matrix using Eigen. Does calling the constructor ...
0
votes
0
answers
22
views
How to build A matrix for this argmin E problem to constraint vertex symmetrically distributed in a mesh
How to build A matrix for the argmin E=∑||N×(v_i-v_j)||^2 by solving it in a least square sense?
this energy is designed for constrainting vertex symmetrically distributed in both sides of the ...
2
votes
1
answer
55
views
Cppyy Setting a referenced value
I am attempting to use Eigen with cppyy and convert back and forth to numpy, but ran into a snag,
How would one set a value by reference, when you cannot assign to a function call in python?
Take this ...
1
vote
1
answer
96
views
How do I get Eigen::TensorRef to work for broadcast and other operations?
I'm using Eigen 3.4 with MSVC. I have used Eigen::Ref before, with some success, and I am trying to use Eigen::TensorRef, but am running into issues:
Eigen::Tensor<double, 3> A(3, 1, 2);
A....
1
vote
1
answer
86
views
QR decomposition results in Python (using numpy) and in C++ (using Eigen) are different?
Sample QR decomposition Code (Python):
import numpy as np
import matplotlib.pyplot as plt
# Define the 2D array
data = np.array([
[12, -51, 4],
[6, 167, -68],
[-4, 24, -41],
[-1, 1, 0]...
-6
votes
1
answer
84
views
How to use Eigen in a C++ program?
I read the documentation of Eigen installation. As per the documentation, only header files need to be referred in your project. As shown in the screenshot below, I included the path of the Eigen in ...
1
vote
2
answers
99
views
Specializing std::less for Eigen::DenseBase
I need a total order on both Eigen::Matrix and Eigen::Array, therefore I would like to specialize std::less for the parent class of both: Eigen::DenseBase. From https://eigen.tuxfamily.org/dox/...
-2
votes
1
answer
70
views
`a,b,c` are both type `Eigen::ArrayXd`. What's the shape of `{a,b,c}`?
from others' codes in the codebase, there is an assignment like z = {a,b,c} where z has type Eigen::Matrix<Eigen::ArrayXd, 3, 1>, but I have no idea how it forms this, and how to access a member ...
0
votes
0
answers
72
views
Eigen Tensor contraction with Autodiff causes Segmentation Error
I'm getting a segmentation fault when trying to use tensor contractions combined with the autodiff module. This is my minimal reproducible example:
#include <unsupported/Eigen/CXX11/Tensor>
#...
0
votes
0
answers
48
views
Loop free sum of column wise operations producing a matrix with Eigen
Is there a loop free way to do this with Eigen?
Matrix3Xf a, b;
Matrix3f m;
m.setZero();
for (size_t i = 0; i < a.cols(); ++i) {
m += a.col(i) * b.col(i).transpose();
}
0
votes
0
answers
71
views
Error in Eigen library examples on building my project
The errors i get are from doc in libraries
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "eigen-.4.0\\doc\\snippets\\MatrixBase_diagonal.o" "..\\..\\eigen-3.4.0\\doc\\snippets\\...
1
vote
0
answers
138
views
Unexpected behavior with Eigen
I have some c++ code that showed an error and I have not be able to understand why.
I have however managed to reduce the code to a small example.
I am using MSVC 19.34.31944, and the last release (3.4....
0
votes
0
answers
38
views
Unable to get eigen library to start working in clion
I am trying to work with matrixes using eigen library,
Below is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.25)
project(Laser_ablation_nanoparticles)
set(CMAKE_CXX_STANDARD 23)
set(EIGEN_DIR ...
0
votes
0
answers
53
views
Eigen Tensor library - strided convolution
I was wondering, is there a way to efficiently 'emulate' strided convolution in Eigen Tensor library, or any other in that sense ? It only provides convolution with fixed stride 1. Padding is pretty ...
1
vote
1
answer
86
views
What is the best way to use Eigen lazy evalution to multiply each row of an Nx3 matrix by a different 3x3 rotation matrix?
Pretty much the title. I'm trying to think up a good way to formulate this without creating any temporaries so I can actually make use of Eigen's speediness. The best I could come up with is this ...
1
vote
0
answers
54
views
Conflict between Eigen and operator that uses ‘auto’ in another (template) class
I have a template class called "Variable.h", which serves as the basis for all program variables.
After Eigen was added to handle matrix calculations, every time I compile the program, I get ...
0
votes
0
answers
24
views
Unable to install eigen in clion
I am new to programing and am using Clion to code. I have tried configuring the eigen library in C make but I am unable to do so.
My C make file is as follows :
cmake_minimum_required(VERSION 3.25)
...
2
votes
1
answer
61
views
Use Eigen::Vector4d as 3d in simpler way
Windows 10 /
eigen3 3.4.0-1 /
MSYS2/MinGW64 13.1.0 /
c++20
To take advantage of SIMD vectorization, I am planning to use vector4d as vector3d. To make code less confusing and more user-friendly, Here ...
1
vote
1
answer
55
views
Reduction with OpenMP: Matrix/tensor operations examples
I am trying to learn how to use reduction with OpenMP and was wondering if the following examples can be rewritten with reduction?
Example A: Finding the sum of three matrices/tensors
#include <...
0
votes
1
answer
41
views
How to use Boost BLAS in Eigen
This page says that you can specify what BLAS libary Eigen should use. I'd like to use the Boost version of BLAS but have been able to get it to link. It is missing a lot of symbols, such as daxpy_, ...
0
votes
0
answers
150
views
Eigen: This Compiler appears to be too old to be supported by Eigen, Linux c++14
I am attempting to build a large project (Amino) which has dependencies on the Open Motion Planning Library and Eigen. It is built with a makefile.am, with a makefile created after running autoreconf ...
0
votes
0
answers
39
views
How do you create a Sparse CSC Matrix In Eigen with arrays of Data, Column pointer, and row indices
I know how to create a sparse matrix with Eigen by inserting the nonzero elements based on their rows and columns, then calling makeCompressed(), but I already have the nonzero elements, and the row ...
1
vote
1
answer
34
views
Eigen: scale the positive entries in loop-free manner
I have an Eigen::Array<float, N, 1>. I would like to multiply all the positive elements by a positive scalar s chosen so that the positive elements instead sum to a target t. I am able to do ...
0
votes
0
answers
13
views
Eigen constructing SimplicialLLT call MatrixL reports error
//standard LLT with cholesky
Eigen::SimplicialLLT<Eigen::SparseMatrix<float>, Eigen::Lower, Eigen::NaturalOrdering<int>> cholesky;
cholesky.compute(array0);
Eigen::...
3
votes
0
answers
110
views
Eigen efficiency of Matrix-Matrix multiplication vs several Matrix-Vector multiplication
Assuming the following relations
a = M u
b = M v
c = M w
Where a, b and c are three [6x1] vectors, M is a [6x15] matrix and u, v and w are three [15x1] .
These operations are done for a set of ...