eigen

Eigen::Matrix vs. boost::multi_array vs. Eigen::Map

怎甘沉沦 提交于 2019-12-07 23:48:37
问题 I'm getting puzzling results while doing fairly simple tasks to compare the performance of: Eigen::Matrix boost::multi_array boost::multi_array mapped to Eigen::Matrix using Eigen::Map This is an abridged version of my test code; a fuller version can be found at: http://pastebin.com/faZ7TvJG. boost::multi_array<double, 2, Eigen::aligned_allocator<double> > boost_multi_array; Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> eigen_matrix; Eigen::Map<Eigen::Matrix<double,

Eigen compilation error with gcc 8.2.1 on MSYS2

限于喜欢 提交于 2019-12-07 22:46:33
问题 We are facing errors compiling against Eigen 3.3.7 (and probably older versions) against the latest versions of GCC 8.2.1 supplied by MSYS2. Strangely, this only happens with the latest builds of the same package ( mingw-w64-x86_64-gcc 8.2.1): 8.2.1+20181123-1 : fine 8.2.1+20181130-1 : error 8.2.1+20181207-1 : error The error is: In file included from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/SparseCore:50, from C:/Users/donald/msys64/mingw64/include/eigen3/Eigen/Sparse:26, from C:

How to use Eigen FFT with MatrixXf?

北慕城南 提交于 2019-12-07 16:54:01
问题 I am new to the Eigen library. I would like to compute FFT of Eigen Matrices. However, my attempts to do so indicate that the unsupported Eigen FFT module can't be used with MatrixXf. I want to pull off something like: #include <eigen3/unsupported/Eigen/FFT> #include<Eigen/Dense> #include<iostream> using namespace std; using namespace Eigen; int main(){ MatrixXf A = MatrixXf::Random(3,10); FFT<float> fft; MatrixXf B; fft.fwd(B,A); } Is this achievable? Any other suggestions are welcome. It

Transform dolfin::Matrix into Eigen::Matrix

爷,独闯天下 提交于 2019-12-07 15:46:31
I am coding in C++ and use Fenics for finite element discretization. Now I would like to transform a dolfin::Matrix into a Eigen::Matrix. How can I do that? I have done something similar for vectors: I have given c_vec which has the type: std::shared_ptr<dolfin::Vector> Then I have used std::vector<double> c_vec_new; c_vec->gather_on_zero(c_vec_new); (I am computing parallel). And then I could create a Eigen::Vector by Eigen::Map<Eigen::VectorXd> c_vec_eigen(c_vec_new.data(),c_vec_new.size()); Is there an easier way? How do I transform a dolfin::Matrix into an Eigen::Matrix? I would be very

How to bridge a JavaScript (ragged) array and an std::vector<std::vector<T>> object?

好久不见. 提交于 2019-12-07 15:17:18
问题 In JavaScript I have a list of "lines", each of which consists of indefinite number of "points", each of which has a form of [x, y] . So it is a 3D ragged array. Now I need to pass it to my C++ code with the help from emscripten (embind). Here's declaration of the C++ function: Eigen::MatrixXd f(const std::vector<std::vector<std::vector<double>>>& lines); And I would like to get a list of lists ( [[m11, m12],[m22, m22],...] ) in JavaScript after calling f . How to write the binding code in

Removing unsolvable equations from an underdetermined system

百般思念 提交于 2019-12-07 10:54:14
问题 My program tries to solve a system of linear equations. In order to do that, it assembles matrix coeff_matrix and vector value_vector , and uses Eigen to solve them like: Eigen::VectorXd sol_vector = coeff_matrix .colPivHouseholderQr().solve(value_vector); The problem is that the system can be both over- and under-determined. In the former case, Eigen either gives a correct or uncorrect solution, and I check the solution using coeff_matrix * sol_vector - value_vector . However, please

How to write a makefile for a C++ project which uses Eigen, the C++ template library for linear algebra?

大兔子大兔子 提交于 2019-12-07 09:35:06
问题 I'm making use of Eigen library which promises vectorization of matrix operations. I don't know how to use the files given in Eigen and write a makefile. The source files which make use of Eigen include files as listed below, these are not even header files (They are just some text files)- <Eigen/Core> <Eigen/Dense> <Eigen/Eigen> and so on. On Eigen's webpage, it's mentioned that, in order to use its functions I don't have to build the project, then how can I include these files in my

c++ check for nested typedef of a template parameter to get its scalar base type

≯℡__Kan透↙ 提交于 2019-12-07 07:43:31
问题 Consider the exponential smoother template class below. This class is for smoothing/filtering sequential data exponentially (see update method). Elemtype might be an vector and Floattype is usually a scalar. E.g. ExponentialSmoother<Eigen::Vector2f, float> x(0.1, Vector2f(0.5, 0.5)); In this example the second template parameter Floattype could be avoided because Eigen's Matrix class contains a nested typedef to get the scalar base type: Vector2f::Scalar It is also reasonable to instantiate

serializing Eigen's Matrix using boost.serialization

↘锁芯ラ 提交于 2019-12-07 05:40:38
问题 I'm trying to serialize Eigen's matrix. So that I can serialize a more complex object. I'm using Matrix as a base class and include the serialization in the derived class. I'm confused on how to address Matrix.data(), which returns a c-style array (if i'm correct). This is my attempt: #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> template < class TEigenMatrix> class VariableType : public TEigenMatrix { private: friend class boost::serialization::access;

using eigenvalues to test for singularity: identifying collinear columns

隐身守侯 提交于 2019-12-07 03:56:51
问题 I am trying to check if my matrix is singular using the eigenvalues approach (i.e. if one of the eigenvalues is zero then the matrix is singular). Here is the code: z <- matrix(c(-3,2,1,4,-9,6,3,12,5,5,9,4),nrow=4,ncol=3) eigen(t(z)%*%z)$values I know the eigenvalues are sorted in descending order. Can someone please let me know if there is a way to find out what eigenvalue is associated to what column in the matrix? I need to remove the collinear columns. It might be obvious in the example