Block
の再割り当てに問題があります。Eigenのブロックをどのように変更しますか?
ArrayXd
3としてS、ArrayXXd
として、各行に対して1つの
A
を格納します。 // data
ArrayXXd A (3, 3);
A << 0, 1, 2, 3, 4, 5, 6, 7, 8;
std::vector<ArrayXd> A_rows = {A.row(0), A.row(1), A.row(2)};
// std::vector<ArrayXd> solution
// first row
ArrayXd & current_row = A_rows[0];
// read it, write it, do stuff
// start working with the second row
current_row = std::ref(A_rows[1]);
cout << current_row << endl << endl; // prints 3 4 5
cout << A << endl; // A is unchanged
// Eigen solution
// first row
Block<ArrayXXd, 1, -1> && current_row_block = A.row(0);
// read it, write it, do stuff
// start working with the second row
current_row_block = std::ref(A.row(1)); // doesn't compile
cout << current_row_block << endl;
cout << A << endl;
エラーメッセージは次のとおりです。
error: use of deleted function 'void std::ref(const _Tp&&) [with _Tp = Eigen::Block<Eigen::Array<double, -1, -1>, 1, -1, false>]'
current_row_block = std::ref(A.row(1));
^
それは第二のアプローチを修正することは可能ですか私はstd::vector<ArrayXd>
として行列を格納することに移動する必要がありますか?
関連質問:Passing a reference of a vector element to a threaded function
あなたは 'Eigen :: Map'の使用を避けたいですか? –
@AviGinsburg、特にそうではありません。私は 'std :: vector'を私が完了したときに 'ArrayXXd'に変換することを考えていました。何を思っていたんだ? –
user357269
最初に 'std :: vector'を持っているのはなぜですか? –