Category : eigen

How to define Matrix<mpreal, Dynamic, Dynamic> with typedef? We usually put the defined type in a header file, but it needs mpreal::set_default_prec(256); and that’s the problem. I am quite new to MPFR, so my apology if it seems easy. So what is your idea? #include <Eigen/LU> #include <iostream> #include <Eigen/Dense> #include "mylibrary.hpp" #include <unsupported/Eigen/MPRealSupport> using ..

Read more

I’m using nlohmann/json to read a JSON file that has an array of 3-element arrays that looks like this. {"data":[[-36,-6,0],[-36,-3,0],[-36,0,0]]} I want to load this into an std::vector of Eigen::Vector3d. std::vector<Vector3d> data = j.at("data").get<std::vector<Vector3d>>(); But I get the following compiler error No member named ‘insert’ in ‘Eigen::Matrix<double, 3, 1, 0>’ Thanks for any help. Source: ..

Read more

I have some code that uses eigen to calculate geodesic lengths on a mesh. In optimization O0 it works, however things break when optimizations are enabled. I am debugging the behaviour and found something strange. There is a gradient calculation that is performed correctly: Eigen::Matrix<float, Eigen::Dynamic, 3> gradient = CalculateSimplifiedVertexGradient<float>(mesh, heat); Then a loop iterates ..

Read more

my cmake file cmake_minimum_required (VERSION 2.8.11) project (Transformation) find_package(Eigen3 REQUIRED) include_directories(EIGEN3_INCLUDE_DIR) add_executable (Transformation main.cpp) After I run make /Users/…/main.cpp:2:9: fatal error: ‘eigen3/Eigen/Core’ file not found #include<eigen3/Eigen/Core> ^~~~~~~~~~~~~~~~~~~ 1 error generated. make[2]: *** [CMakeFiles/Transformation.dir/main.cpp.o] Error 1 make[1]: *** [CMakeFiles/Transformation.dir/all] Error 2 make: *** [all] Error 2 OS: MacOS 11.2 cmake version: 3.9.16 make version: 3.81 Source: ..

Read more

I am currently filling a vector with random numbers using Eigen::VectorXd::Random(n). Is it possible to seed Eigen’s random number generator for deterministic results? Or alternatively, pass a random number generator to Eigen? I found no mention of either in the Eigen wiki, but it seems odd that such a feature would be missing. Source: Windows ..

Read more

I was experimenting with C++20 concepts and the Eigen library, and I incurred an unexpected behavior. Specifically, consider the following concept requiring a type to be callable with either an Eigen::Matrix<double, -1, 1>> object or an Eigen::Matrix<char, -1, 1>> one: template <class FOO_CONCEPT> concept FooConcept = std::invocable<FOO_CONCEPT, Eigen::Matrix<double, -1, 1>> && std::invocable<FOO_CONCEPT, Eigen::Matrix<char, -1, 1>>; ..

Read more

I have written the following piece in order to test a function, which implements a logarithmic hysteretic quantizer. #include <iostream> #include <Eigen/Dense> #include <math.h> double logarithmic_hysteretic_quantizer(double u, double u_prev, double delta, double u_min); int main(int argc, const char * argv[]) { Eigen::MatrixXd control_signal = Eigen::MatrixXd::Zero(7,1); double delta = 0.1765; double u_min = 0.01; double i ..

Read more