eigen3

sparse sparse product A^T*A optim in Eigen lib

非 Y 不嫁゛ 提交于 2019-12-11 13:35:43
问题 In the case of multiple of same matrix matA, like matA.transpose()*matA, You don't have to compute all result product, because the result matrix is symmetric(so only if the m>n), in my specific case is always symmetric! square. So its enough the compute only for. ex. lower triangular part and rest only copy..... because the results of the multiple 2nd and 3rd row, resp.col, is the same like 3rd and 2nd.....And etc.... So my question is , exist way how to tell Eigen, to compute only lower part

Eigen vectors not initialized when cross-compiled for ARM

这一生的挚爱 提交于 2019-12-11 12:17:21
问题 I'm using Eigen3 on a cross compiled program using the arm-linux-gnueabihf-g++ (gcc version 4.8 from Linaro). The target platform is a duovero from gumstix using the Poky distribution - ARMv7. When I run the program with the Eigen code I get really strange values on the Eigen objects (see the output example at the end of this post). I've tried to turn off vectorization, I've played with all these flags -marm -mcpu=cortex-a7 -mfpu=neon -mfloat-abi=hard but always get the same behavior. If I

DenseBase, auto, and binary operation says arrays have different shape

ぐ巨炮叔叔 提交于 2019-12-11 06:37:49
问题 I write a function that takes two DenseBase as arguments. The function uses .derived().array() to convert both Array and Matrix to Array . I got tired of writing derived for many times and use auto. But auto leads to strange error. Eigen complains that x2 and y2 don't have same shape. If I don't want to write .derived().array() for many times, what can I use? Eigen is from https://github.com/eigenteam/eigen-git-mirror.git #include <Eigen/Eigen> int main() { Eigen::ArrayXf x(3); Eigen::ArrayXf

Eigen Sparse LU solver return value

左心房为你撑大大i 提交于 2019-12-11 04:23:18
问题 I have a problem with the following piece of code, after some research I have singled out the problem in a separate line, but not sure now how to solve it. typedef double ComplexType; typedef std::complex<ComplexType> Complex; typedef Eigen::SparseMatrix<Complex, Eigen::ColMajor, long long> SparseMatrixT; typedef Eigen::SparseVector<Complex, Eigen::ColMajor, long long> SparseVectorC; typedef Eigen::SparseLU<SparseMatrixT, Eigen::COLAMDOrdering< long long>> SolverT; SparseVectorC Solve(const

Mixing Scalar Types in Eigen

拈花ヽ惹草 提交于 2019-12-11 00:45:22
问题 #include <iostream> #include <Eigen/Core> namespace Eigen { // float op double -> double template <typename BinaryOp> struct ScalarBinaryOpTraits<float, double, BinaryOp> { enum { Defined = 1 }; typedef double ReturnType; }; // double op float -> double template <typename BinaryOp> struct ScalarBinaryOpTraits<double, float, BinaryOp> { enum { Defined = 1 }; typedef double ReturnType; }; } int main() { Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic> m1(2, 2); m1 << 1, 2, 3, 4; Eigen:

Eigen: Divide each row by last row

只谈情不闲聊 提交于 2019-12-10 17:45:53
问题 I can't quite figure out the syntax for this when using Eigen's rowwise operations... I have an Eigen matrix, and I want to divide each row by the last row. So if we started with a matrix r = [ 0, 1 2, 3 4, 5 ] then after this transform, I want to have r = [ 0, .2 .5, .6 1, 1 ] Preferably the operation would happen in place, overwriting r . Furthermore, I will not be using the values in the last row, so it doesn't matter if the last row is actually 1's after the transform. Here are some

Eigen with -O3 warning: argument 1 value ‘X’ exceeds maximum object size Y

≡放荡痞女 提交于 2019-12-10 17:14:50
问题 What happens When I try to add an Eigen::Vector3f into an std::vector following the tutorial on Eigen website like this: #include <Eigen/Core> #include <Eigen/StdVector> #include <iostream> template <class EigenT> using EigenStdVector = std::vector<EigenT, Eigen::aligned_allocator<EigenT>>; int main() { EigenStdVector<Eigen::Vector3f> vec; vec.emplace_back(1.0f, 1.0f, 1.0f); std::cerr << vec.back().transpose() << std::endl; return 0; } I get the following warning: In file included from /usr

Extracting blocks/ROIs from Eigen::SparseMatrix without copying

时光总嘲笑我的痴心妄想 提交于 2019-12-10 16:18:05
问题 I wonder is there any good way to extract blocks/ROIs from Eigen::SparseMatrix? More precisely, what I want to extract is inner vectors . What I want to do is like: typedef Eigen::SparseMatrix<double,Eigen::RowMajor> SpMat; // Prepare some sparse matrix SpMat spmat; // Extract lines from it const SpMat& row_i = spmat.innerVector(i); const SpMat& row_j = spmat.innerVector(j); // Some calculation with row_i and row_j... As I tested, the data of row_i and row_j is copied (!!) from spmat .

Eigen: Return a reference to a block of a matrix with compile-time dimension checks

左心房为你撑大大i 提交于 2019-12-10 14:43:38
问题 What I am asking is a generalization of this question. Specifically, I would like to make a C++ Eigen wrapper around a legacy C and Fortran library, which uses a 2D data-structure: [ x[0,0] ... x[0,w-1] ] [ u[0,0] ... u[0,w-1] ] [ ... ] [ x[c-1,0] ... x[c-1,w-1] ] [ u[c-1,0] ... u[c-1,w-1] ] where each of the entries x[i,j] and u[i,j] are themselves column vectors of size ( nx1 ) and ( mx1 ) respectively. This leads to some complicated (and error prone) pointer arithmetic as well as some very

How can I calculate inverse of sparse matrix in Eigen library

爷,独闯天下 提交于 2019-12-09 12:33:40
问题 I have a question about Eigen library in C++. Actually, I want to calculate inverse matrix of sparse matrix. When I used Dense matrix in Eigen, I can use .inverse() operation to calculate inverse of dense matrix. But in Sparse matrix, I cannot find inverse operation anywhere. Does anyone who know to calculate inverse of sparse matrix? help me. 回答1: You cannot do it directly, but you can always calculate it, using one of the sparse solvers. The idea is to solve A*X=I , where I is the identity