转换特征矩阵为C数组 [英] Convert Eigen Matrix to C array

查看:152
本文介绍了转换特征矩阵为C数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

href=\"http://eigen.tuxfamily.org/\">征库可以映射现有内存入本征矩阵的

The Eigen library can map existing memory into Eigen matrices.

float array[3];
Map<Vector3f>(array, 3).fill(10);
int data[4] = 1, 2, 3, 4;
Matrix2i mat2x2(data);
MatrixXi mat2x2 = Map<Matrix2i>(data);
MatrixXi mat2x2 = Map<MatrixXi>(data, 2, 2);

我的问题是,我们如何得到C阵列(例如浮动[] a)由特征矩阵(例如Matrix3f米)?什么特征矩阵真正的布局?存储真实数据作为普通的C数组?

My question is, how can we get c array (e.g. float[] a) from eigen matrix (e.g. Matrix3f m)? What it the real layout of eigen matrix? Is the real data stored as in normal c array?

推荐答案

您可以使用数据()的特征矩阵类的成员函数。默认布局是列为主,而不是行主要为多维数组c(布局可以创建一个Matrix对象时选择)。对于稀疏矩阵的preceding句话显然不适用。

You can use the data() member function of the Eigen Matrix class. The layout by default is column-major, not row-major as a multidimensional C array (the layout can be chosen when creating a Matrix object). For sparse matrices the preceding sentence obviously doesn't apply.

这篇关于转换特征矩阵为C数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆