Questions tagged [eigen]

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

Filter by
Sorted by
Tagged with
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 ...
Vitaly Borzenkov's user avatar
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::...
Mitto's user avatar
  • 1
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 ...
E_1996's user avatar
  • 63
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&...
dagnic's user avatar
  • 149
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 ...
giafranchini's user avatar
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 ...
Yes's user avatar
  • 331
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 ...
Rob's user avatar
  • 15
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 ...
Mico Mrkaic's user avatar
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),...
DONTEN's user avatar
  • 19
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, ...
Matteo's user avatar
  • 3
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 ...
Yes's user avatar
  • 331
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 ...
Cedric Martens's user avatar
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 ...
Hans's user avatar
  • 31
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 ...
Cedric Martens's user avatar
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 ...
sophistcxf's user avatar
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.
Soo's user avatar
  • 913
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:...
Fisteshak's user avatar
-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(...
YHD's user avatar
  • 50
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 ...
PluginPenguin's user avatar
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 ...
CocoLAsticot's user avatar
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 ...
JCut's user avatar
  • 21
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 }; ...
苏茂江's user avatar
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++) {...
苏茂江's user avatar
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 ...
苏茂江's user avatar
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 - ...
Vince W.'s user avatar
  • 3,601
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 ...
Cedric Martens's user avatar
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 ...
AprilL's user avatar
  • 1
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 ...
MrMinimalEffort's user avatar
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....
Danny's user avatar
  • 356
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]...
skm's user avatar
  • 5,143
-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 ...
skm's user avatar
  • 5,143
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/...
j-hap's user avatar
  • 184
-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 ...
user900476's user avatar
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> #...
Duloren's user avatar
  • 2,425
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(); }
atb's user avatar
  • 1,412
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\\...
Hamsha's user avatar
  • 1
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....
pierreXVI's user avatar
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 ...
Vishal Patil's user avatar
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 ...
PanJa's user avatar
  • 15
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 ...
Danny's user avatar
  • 356
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 ...
user2129053's user avatar
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) ...
Vishal Patil's user avatar
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 ...
Prashant's user avatar
  • 837
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 <...
Jamie 's user avatar
  • 441
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_, ...
GregReese's user avatar
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 ...
Benyamin's user avatar
  • 111
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 ...
Govind Chari's user avatar
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 ...
dshin's user avatar
  • 2,364
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::...
Concyclics's user avatar
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 ...
Andrea Gotelli's user avatar

1
2 3 4 5
70