eigen

Avoiding dynamic memory allocation on factorizing sparse matrix with Eigen

一笑奈何 提交于 2021-01-29 05:06:59
问题 In my application I need to avoid dynamic memory allocation (malloc like) except in the class constructors. I have a sparse semidefinite matrix M whose elements change during the program execution but it mantains a fixed sparsity pattern. In order to solve many linear systems M * x = b as fast as possible, the idea is to use inplace decomposition in my class constructor as described in Inplace matrix decompositions, then call factorize method whenever M changes: struct MyClass { private:

How to add a library, header file in Visual studio 2015

久未见 提交于 2021-01-28 12:46:41
问题 I am fairly new to Visual Studio. There is this open source linear solver called Eigen. I have currently downloaded the zip file containing all the header file according to the documentation I don't need to use Cmake or install or anything. I just need to make sure that the compiler has access to the Eigen header files. The documentation gives me different ways of doing this if I use gcc but I am using Visual Studio 2015. I have extracted the zip file and I know the location of the header

Undefined reference error from GCC using a template with a std::vector and an Eigen Matrix?

泪湿孤枕 提交于 2021-01-28 12:45:08
问题 I am experiencing an undefined reference error, when compiling the following code using GCC 4.7.2 20130108 under x86_64-suse-linux via the command: g++ main.cpp func.cpp -I/path/to/eigenlibrary/eigen_3.2.1 The error message reads: main.cpp:(.text+0x1d): undefined reference to `void f<2>(std::vector<Eigen::Matrix<double, 2, 2, ((Eigen::._84)0)|((((2)==(1))&&((2)!=(1)))? ((Eigen::._84)1) : ((((2)==(1))&&((2)!=(1)))?((Eigen::._84)0) : ((Eigen::._84)0))), 2, 2>, std::allocator<Eigen::Matrix

Undefined reference error from GCC using a template with a std::vector and an Eigen Matrix?

こ雲淡風輕ζ 提交于 2021-01-28 12:43:59
问题 I am experiencing an undefined reference error, when compiling the following code using GCC 4.7.2 20130108 under x86_64-suse-linux via the command: g++ main.cpp func.cpp -I/path/to/eigenlibrary/eigen_3.2.1 The error message reads: main.cpp:(.text+0x1d): undefined reference to `void f<2>(std::vector<Eigen::Matrix<double, 2, 2, ((Eigen::._84)0)|((((2)==(1))&&((2)!=(1)))? ((Eigen::._84)1) : ((((2)==(1))&&((2)!=(1)))?((Eigen::._84)0) : ((Eigen::._84)0))), 2, 2>, std::allocator<Eigen::Matrix

Block operations won't work on Eigen

自作多情 提交于 2021-01-28 12:23:23
问题 The block operations on Eigen won't work. I'm getting a bunch of errors like: error: ‘Eigen::Vector4d’ has no member named ‘head’ The line of code generating this error is: outVector.push_back(out.head<3>()); Where out is an Eigen::Vector4d and outVector is a std::vector<Eigen::Vector4d> . The full error output is: PortalSpace2.cpp: In member function ‘virtual std::vector<Eigen::Matrix<double, 3, 1> > PortalSpace::PointOfReference::vectorsFromPoint(std::tr1::shared_ptr<Manifold::Point>)’:

Eigen Indices of Dense Matrix meeting Condition

老子叫甜甜 提交于 2021-01-28 08:03:24
问题 I'm looking to get the row/column indices from a dense matrix which meet a condition. In my case the result is likely to be very sparse. For example, with matrix 1 5 2 7 6 3 2 3 8 I'd like to get the indicies where the coeff is greater than 4, or (0,1), (1,0), (1,1), (2,2) My initial thoughts include using either select or coefficientwise operations to build a bool/int matrix 0 1 0 1 1 0 0 0 1 and then convert it to a sparse matrix (0,1,1), (1,0,1), (1,1,1), (2,2,1) then remove the coeff

Eigen vertical stacking rows into Matrix

蹲街弑〆低调 提交于 2021-01-28 05:47:15
问题 I would like to create a matrix of size 2N x 9 where N is a dynamic value by vertical stacking 2N 1x9 matrices. Here's what I tried doing. using CoefficientMatrix = Eigen::Matrix<T, Eigen::Dynamic, 9>; using CoefficientRow = Eigen::Matrix<T, 1, 9>; CoefficientMatrix A(2*N, 9); for (int i = 0; i < N; i++) { CoefficientRow ax; CoefficientRow ay; // fill in ax and ay A << ax, ay; } But, I get the following runtime error. Assertion failed: (((m_row+m_currentBlockRows) == m_xpr.rows() || m_xpr

视觉SLAM十四讲实践之Sophus下的位姿表示和更新优化

和自甴很熟 提交于 2021-01-23 06:53:30
旋转矩阵是三维空间刚体运动的描述方式之一 李群SO(3)旋转矩阵 李代so(3) 三维向量实际上是旋转向量组成的空间 李群SE(3)变换矩阵 李代se(3) 六维向量 平移在前 旋转在后 旋转矩阵的导数由旋转向量指定,指导着如何在旋转矩阵中进行微积分运算。 每个李群都有与之对应的李代数,李代数描述了李群的局部性质。 Sophus(李群、李代数库) Eigen库是一个开源的C++线性代数库,它提供了快速的有关矩阵的线性代数运算,还包括解方程等功能。Eigen库提供了集合模块,但没有提供李代数的支持。 Sophus库是基于Eigen基础上开发的,继承了Eigen库中的定义的各个类。因此在使用Eigen库中的类时,既可以使用Eigen命名空间,也可以使用Sophus命名空间,Sophus库很好的支持了 李群SO3 李代so3 李群SE3 李代se3 。 高博视觉SLAM十四讲的这张图总结的很好 用沿Z轴转90度的Eigen旋转向量构造Eigen的旋转矩阵 / ***** ***** ***** ***** ***** ***** ***** ***** ** * 原型 李代数 * SO3 (3 *3)=="R" --> so3 (3* 3) * SE3 (4 *4)=="T" --> se3 (6* 1) ***** ***** ***** ***** ***** ***** *****

Return Array of Eigen::Matrix from C++ to Python without copying

非 Y 不嫁゛ 提交于 2021-01-21 05:26:29
问题 I have some C++ code that generates and manipulates arrays of Eigen matrices. In the end I want to use those matrices in python and thought this might be a job for pybind11 . Basically what I want back in python are two nested lists / numpy arrays mat_a(I, 4, 4) and mat_b(J, K, 4, 4) . Because I have to do a lot of linear algebra stuff in C++ I wanted to use Eigen and the data structure I used is std::array<std::array<Eigen::Matrix4f, 2>, 3>>> mat_b // for J=3, K=2 . The problem now is how to

tensorflow c++接口的编译安装与一些问题记录

橙三吉。 提交于 2021-01-13 21:01:17
参考 这篇文章 安装,依次安装bazel,protocbuf,eigen3,然后下载tensorflow源码,编译c++ api,将编译结果拷贝到搜索路径 最后测试案例时遇到一些问题 (1)fatal error: absl/strings/string_view.h 解决方案 ,git clone https://github.com/abseil/abseil-cpp,然后把该库加到搜索目录里面 (2)对‘tensorflow::SessionOptions::SessionOptions()’未定义的引用 找不到正确的libtensorflow_cc.so,添加动态链接库路径 (3)tensorflow::status::tostring[abi:cxx11]() const 解决方案 ,编译选项设置-D_GLIBCXX_USE_CXX11_ABI=0 最终测试代码 1 #include <tensorflow/core/platform/env.h> 2 #include <tensorflow/core/ public /session.h> 3 4 #include <iostream> 5 6 using namespace std; 7 using namespace tensorflow; 8 9 int main() 10 { 11 Session*