Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
対角線上の要素が短い VectorXd の N 複製である Eigen ライブラリを使用して、C++ で対角線 MatrixXd を作成する必要があります。
VectorXd R; // サイズ n のベクトル
VectorXd V; // R の N 個の連結複製に対応するサイズ n*N のベクトル、作成方法がわかりません
MatrixXd D=MatrixXd(V.asDiagonal()); //サイズ n N xn Nの私の対角行列
ありがとう。
の線に沿った何か
VectorXd V(N * R.innerSize()); // construct vector of size N * n for(size_t i = 0; i < n; ++i) for(size_t j = 0; j < R.innerSize(); ++j) V[i * R.innerSize() + j] = R[j];