使用特征矩阵构建3D结构的最有效选择 [英] Most efficient option for build 3D structures using Eigen matrices

查看:45
本文介绍了使用特征矩阵构建3D结构的最有效选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码中需要3D矩阵/数组结构,现在我的矩阵和向量都依赖Eigen.

I need a 3D matrix/array structure on my code, and right now I'm relying on Eigen for both my matrices and vectors.

现在我正在使用new创建3D结构:

Right now I am creating a 3D structure using new:

MatrixXd* cube= new MatrixXd[60];
for (int i; i<60; i++) cube[i]=MatrixXd(60,60);

并用于访问值:

double val;
MatrixXd pos;
for (int i; i<60; i++){
    pos=cube[i];
    for (int j; j<60; j++){
        for (int k; k<60; k++){
            val=pos(j,k);
            //...
        }
    }
}

但是,现在这部分代码非常慢,这使我相信这可能不是最有效的方法.有其他选择吗?

However, right now it is very slow in this part of the code, which makes me beleive that this might not be the most efficient way. Are there any alternatives?

推荐答案

虽然不可用,但在提出问题时,Eigen已经提供了Tensor模块已有一段时间了.它仍然处于不受支持"的阶段(意味着API可能会更改),但是基本功能应该基本上是稳定的.文档分散在此处此处.

While it was not available, when the question was asked, Eigen has been providing a Tensor module for a while now. It is still in an "unsupported" stage (meaning the API may change), but basic functionality should be mostly stable. The documentation is scattered here and here.

这篇关于使用特征矩阵构建3D结构的最有效选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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