eigen3

Eigen norm() with Boost.Units

旧时模样 提交于 2020-07-18 06:42:29
问题 I am trying to use Boost.Units with Eigen 3.3.1, but after following the instructions here, and some pieces of informations found around, I still cannot figure out how to make norm() work. Here is what I have so far (sorry for the long code block): #include <boost/units/quantity.hpp> #include <boost/units/systems/si/length.hpp> #include <boost/units/systems/si/area.hpp> #include <boost/units/cmath.hpp> #include <Eigen/Geometry> namespace Eigen { //specialization of numeric traits using boost:

Eigen norm() with Boost.Units

时光总嘲笑我的痴心妄想 提交于 2020-07-18 06:42:18
问题 I am trying to use Boost.Units with Eigen 3.3.1, but after following the instructions here, and some pieces of informations found around, I still cannot figure out how to make norm() work. Here is what I have so far (sorry for the long code block): #include <boost/units/quantity.hpp> #include <boost/units/systems/si/length.hpp> #include <boost/units/systems/si/area.hpp> #include <boost/units/cmath.hpp> #include <Eigen/Geometry> namespace Eigen { //specialization of numeric traits using boost:

Replacing all negative elements with zero eigen3 c++

£可爱£侵袭症+ 提交于 2020-07-08 18:50:34
问题 As said I want to replace all < 0 elements in a eigen3 matrix in C++ with zero in most efficient manner. I check that there are negative elements using: (result.array() < 0).any() 回答1: A nicer and more efficient way than your proposed method would be to use the select method. result = (result.array() < 0).select(0, result); 回答2: I found a way: Create a matrix of zeros of same shape, zero_matrix.setZero(); And find coeff wise maximum between zero matrix and your matrix. result = result.array()

Replacing all negative elements with zero eigen3 c++

╄→гoц情女王★ 提交于 2020-07-08 18:50:10
问题 As said I want to replace all < 0 elements in a eigen3 matrix in C++ with zero in most efficient manner. I check that there are negative elements using: (result.array() < 0).any() 回答1: A nicer and more efficient way than your proposed method would be to use the select method. result = (result.array() < 0).select(0, result); 回答2: I found a way: Create a matrix of zeros of same shape, zero_matrix.setZero(); And find coeff wise maximum between zero matrix and your matrix. result = result.array()

How large matrix can be fit into Eigen library? [closed]

拈花ヽ惹草 提交于 2020-03-21 05:59:17
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I am working on large scale data like 300000 x 300000 matrix currently may interest. It is really hard to process in matlab due to "Out of memory" error so I decide to use EIGEN. Is there any restriciton for eigen in the matrix size? 回答1: The dense matrices in EIGEN are stored in a contiguous block of memory,

Eigen 3.3 Conjugate Gradient is slower when multi-threaded with GCC compiler optimization

♀尐吖头ヾ 提交于 2020-03-20 06:10:53
问题 I've been using the ConjugateGradient solver in Eigen 3.2 and decided to try upgrading to Eigen 3.3.3 with the hope of benefiting from the new multi-threading features. Sadly, the solver seems slower (~10%) when I enable -fopenmp with GCC 4.8.4. Looking at xosview, I see that all 8 cpus are being used, yet performance is slower... After some testing, I discovered that if I disable compiler optimization (use -O0 instead of -O3 ), then -fopenmp does speed up the solver by ~50%. Of course, it's

Eigen 3.3 Conjugate Gradient is slower when multi-threaded with GCC compiler optimization

青春壹個敷衍的年華 提交于 2020-03-20 06:10:38
问题 I've been using the ConjugateGradient solver in Eigen 3.2 and decided to try upgrading to Eigen 3.3.3 with the hope of benefiting from the new multi-threading features. Sadly, the solver seems slower (~10%) when I enable -fopenmp with GCC 4.8.4. Looking at xosview, I see that all 8 cpus are being used, yet performance is slower... After some testing, I discovered that if I disable compiler optimization (use -O0 instead of -O3 ), then -fopenmp does speed up the solver by ~50%. Of course, it's

How to efficiently extract real/imaginary parts of complex matrix in Eigen3 library?

本小妞迷上赌 提交于 2020-03-17 08:56:13
问题 I have some complex, dense vectors/matrices in the Eigen3 library, and I want to extract the real and imaginary parts into separate arrays. In Matlab, I could do something like cplxFoo = [1, 1i; -1i -1] re = real(cplxFoo) im = imag(cplxFoo) which expectantly yields cplxFoo = 1.0000 + 0.0000i 0.0000 + 1.0000i 0.0000 - 1.0000i -1.0000 + 0.0000i re = 1 0 0 -1 im = 0 1 -1 0 Is there anything like the real() and imag() Matlab functions in Eigen3? Right now, the only thing I know will work is

Understanding solveInPlace operation in Eigen

僤鯓⒐⒋嵵緔 提交于 2020-03-05 02:16:06
问题 I was trying to explore the option of "solveInPlace()" function while using LLT in Eigen3.3.7 to speed up the matrix inverse computation in my application. I used the following code to test it. int main() { const int M=3; Eigen::Matrix<MyType,Eigen::Dynamic,Eigen::Dynamic> R = Eigen::Matrix<MyType,Eigen::Dynamic,Eigen::Dynamic>::Zero(M,M); // to make sure full rank for(int i=0; i<M*2; i++) { const Eigen::Matrix<MyType, Eigen::Dynamic,1> tmp = Eigen::Matrix<MyType,Eigen::Dynamic,1>::Random(M);

How to extract a subvector (of an Eigen::Vector) from a vector of indices in Eigen?

两盒软妹~` 提交于 2020-01-23 05:14:09
问题 Suppose I have Eigen::VectorXd x; //{1,2,3,4,5,6,7,8} and Eigen::VectorXd ind_vec; //{0,2,4,5} Is there a way an easy way to extract the ind_vec elements of x? Something like: x.extract(ind_vec) returning {1, 3, 5, 6} 回答1: Since the current answer was not satisfactory for me, I googled a bit and I found this tutorial in the Eigen documentation. #include <Eigen/Dense> #include <iostream> using namespace std; int main() { Eigen::ArrayXf v(6); v << 1, 2, 3, 4, 5, 6; cout << "v.head(3) =" << endl