我的問題:是否有可能創建一個具有不同級別的特徵張量向量?不同級別的特徵張量向量
我的目標是能夠創建一個向量,其中包含的對象的類型取值爲Eigen::MatrixXd, Tensor3d, Tensor4d,..., Tensor10d
(定義如下)中的值。對象可以有不同的類型。
在此先感謝您的幫助!
#include <iostream>
#include <vector>
#include <Eigen/Dense>
#include <unsupported/Eigen/CXX11/Tensor>
typedef Eigen::Tensor< double , 3 > Tensor3d;
typedef Eigen::Tensor< double , 4 > Tensor4d;
typedef Eigen::Tensor< double , 5 > Tensor5d;
typedef Eigen::Tensor< double , 6 > Tensor6d;
typedef Eigen::Tensor< double , 7 > Tensor7d;
typedef Eigen::Tensor< double , 8 > Tensor8d;
typedef Eigen::Tensor< double , 9 > Tensor9d;
typedef Eigen::Tensor< double , 10 > Tensor10d;
class MyClass
{
private:
std::vector<TensorXd> Tensors;
public:
MyClass();
};
也許:http://stackoverflow.com/questions/13461869/c-push-multiple-types-onto-vector,但這有點難看。 – Aziuth
@Aziuth謝謝,我會試一試,但仍然在尋找更優雅和透明的解決方案。 – Khue