eigen

Serializing Decomposed Matrix from eigen (SparseLU object)

北城以北 提交于 2019-12-30 14:40:28
问题 I am trying to solve Ax=b where the matrix A can be big close to 1M x 1M in size, is sparse and symmetric but might not be positively defined. Problem is that it might take a long time to compute the decomposition using the sparseLU object in eigen and it will be idea for one to store the sparseLU matrix instead of the original matrix such that whenever we perform similar operation using the same matrix A, we can speed things up by not needing to re-compute the A quick search on stackoverflow

Mapping array back to an existing Eigen matrix

允我心安 提交于 2019-12-28 16:06:29
问题 I want to map an array of double to an existing MatrixXd structure. So far I've managed to map the Eigen matrix to a simple array, but I can't find the way to do it back. void foo(MatrixXd matrix, int n){ double arrayd = new double[n*n]; // map the input matrix to an array Map<MatrixXd>(arrayd, n, n) = matrix; //do something with the array ....... // map array back to the existing matrix } 回答1: I'm not sure what you want, but I'll try to explain. You're mixing double and float in your code (a

基于eigen实现 bundle adjustment

心已入冬 提交于 2019-12-28 04:44:37
纯粹是演示性代码,用于展示BA过程,没有做稀疏矩阵相关的优化 # include <iostream> # include <opencv2/opencv.hpp> # include <opencv2/features2d/features2d.hpp> # include <opencv2/highgui/highgui.hpp> # include <Eigen/Core> # include <Eigen/Dense> # include "sophus/se3.h" using namespace std ; using namespace Eigen ; using namespace cv ; typedef vector < Vector3d , Eigen :: aligned_allocator < Vector3d >> VecVector3d ; typedef vector < Vector2d , Eigen :: aligned_allocator < Vector3d >> VecVector2d ; typedef Matrix < double , 6 , 1 > Vector6d ; double fx = 520.9 , fy = 521.0 , cx = 325.1 , cy = 249.7 ; template < typename T

Eigen矩阵的定义和基本运算

非 Y 不嫁゛ 提交于 2019-12-27 18:40:16
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 矩阵的定义 #include <iostream> #include <Eigen/Core> // 稠密矩阵的代数运算(逆,特征值等) #include <Eigen/Dense> int main() { // 声明一个2*3的float矩阵 Eigen::Matrix<float, 2, 3> matrix_23; // 例如 Vector3d 实质上是 Eigen::Matrix<double, 3, 1>,即三维向量 Eigen::Vector3d v_3d; // Matrix3d 实质上是 Eigen::Matrix<double, 3, 3> Eigen::Matrix3d matrix_33 = Eigen::Matrix3d::Zero(); //初始化为零 Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_dynamic; // 更简单的 Eigen::MatrixXd matrix_x; //初始化单位阵 Eigen::Matrix3d mat = Eigen::Matrix3d::Identity(); matrix_23 << 1, 2, 3, 4, 5, 6; v_3d << 3, 2, 1; for

RGBD-SLAM_v2 超详细安装加运行

妖精的绣舞 提交于 2019-12-27 15:23:19
RGBD-SLAM_v2超详细安装与运行 主要参考链接 注意 1.建立工作空间 2.下载RGBD-SLAM 3.卸载g2o 4.安装g2o依赖项 5.下载并提取eigen 3.2.10头文件 6.下载g2o 7.配置g2o头文件 8.编译g2o 9.下载PCL 10.用C++ 2011支持配置PCL编译 11.编译并安装PCL 12.配置RGBD-SLAM 13.构建siftgpu库(与rgbdslam绑定) 14.建构rgbdslam 15.完成构建rgbdslam包并将启动文件复制 16.添加rgbdslam_ws工作空间到.bashrc文件下 17.测试数据集 主要参考链接 RGBD-SLAM_v2 github地址 环境配置英文教程(很详细) CSDN其他教程 注意 需要环境ubuntu16.04 ROS Kinetic ROS Kinetic安装教程 安装的ros版本若是“full”,则是自带opencv,无需自己重新安装,但是在系统中找不到这个opencv 建议在安装之前下载好数据集,PCL1.8,这两个下载非常慢 PCL下载地址 RGBDSLAM数据集下载(bag版本) 1.建立工作空间 这种操作类似于深度学习经常会做的建立虚拟环境,使得多个环境之间不互相影响 mkdir -p ~/catkin_ws/src cd ~/catkin_ws catkin_make

视觉SLAM理论与实践6-2

余生颓废 提交于 2019-12-25 22:04:12
视觉SLAM理论与实践-直接法 一、直接法基础介绍 二、单层直接法 三、多层直接法 四、延申讨论 一、直接法基础介绍 二、单层直接法 该问题的误差项为: 其中p1,p2 为非其次像素坐标,ξ为R,t对应的李代数 本题目中位姿的自由度为6,误差函数中的光度的变化是1维的数据,所以雅克比矩阵为1×6,误差项相对于自变量的雅克比维度为1×6.求解过程如下: 有上式可知,一阶导由于链式法则分成了3项,方便雅克比的计算,下面就是计算这三项。 第一项: 第二项: 第三项: 得到: 所以推到出来误差相对于李代数的雅克比矩阵为: 窗口大小的选择和误差以及计算量有关系。窗口不能取太大,随着窗口的增大,两帧之间的关键点的计算量将会呈指数增长;窗口可以取单点。但是这样会导致像素梯度计算误差增大。 三、多层直接法 单层及多层金字塔直接法代码片段如下: #include < opencv2 / opencv . hpp > #include < sophus / se3 . h > #include < Eigen / Core > #include < vector > #include < string > #include < boost / format . hpp > #include < pangolin / pangolin . h > using namespace std ;

Converting Eigen::MatrixXf to 2D std::vector

怎甘沉沦 提交于 2019-12-25 15:57:52
问题 Is there a more elegant solution than to copy the values point to point?! Something like this works for a 1D vector... vector<float> vec(mat.data(), mat.data() + mat.rows() * mat.cols()); I tried various other alternatives that were suggested by the GCC compiler for vector< vector > but nothing worked out... 回答1: Eigen::MatrixXf uses efficient linear memory, while a vector of vector would represent a very different datatype. For multidimentional vector, you would therefore have to read the

Performance bottleneck in Eigen program

时光总嘲笑我的痴心妄想 提交于 2019-12-25 14:23:33
问题 As a part of a larger problem, I'm running into a performance bottle neck when dealing with Sparse Matrices in Eigen. I need to subtract a floating point number ( x ) from each element in a Sparse Matrix ( G ), including the positions where the coefficients are zero. So the zero elements should have a value -x The way I do this at the moment is as follows: //calculate G x=0.01; for(int i=0;i<rows;i++){ for (int j=0; j<cols; j++) { G.coeffRef(i, j) -= x; } } When the size of G is large, this

Performance bottleneck in Eigen program

萝らか妹 提交于 2019-12-25 14:22:19
问题 As a part of a larger problem, I'm running into a performance bottle neck when dealing with Sparse Matrices in Eigen. I need to subtract a floating point number ( x ) from each element in a Sparse Matrix ( G ), including the positions where the coefficients are zero. So the zero elements should have a value -x The way I do this at the moment is as follows: //calculate G x=0.01; for(int i=0;i<rows;i++){ for (int j=0; j<cols; j++) { G.coeffRef(i, j) -= x; } } When the size of G is large, this

Returning all rows, or just the last one

北城以北 提交于 2019-12-25 08:14:51
问题 I'm writing up a bunch (~ a dozen) algorithms that iteratively process a vector in the following pattern: ArrayXd prev; ArrayXd curr; prev = some_initial_vector(); for (i = 0; i < N; ++i) { // do lots of stuff, many lines to compute curr // use lots of algorithm specific variables initialised above ... prev = curr; } return curr; I would like to have a way of returning the entire history of the values of curr as well, as rows in an ArrayXXd . I have tried solving this by writing two classes