Reputation: 23
I'm trying to extract a submatrix from an Eigen::DiagonalMatrix
type, but block
is not a member of type Eigen::DiagonalMatrix
.
Eigen::DiagonalMatrix<double, 7> A;
...
(void) A.block<6,6>(0,0); // fails, block is not a member of Eigen::DiagonalMatrix
Is there another way to extract a submatrix of type DiagonalMatrix
?
Upvotes: 1
Views: 85
Reputation: 13295
A diagonal matrix is just a wrapper around a vector with the diagonal entries. You can access this vector with the diagonal()
method. So you can use this:
Eigen::DiagonalMatrix<double, 7> A;
A.diagonal().head<6>().asDiagonal();
Upvotes: 1