Extracting submatrices in Eigen (C++), dynamic version.
27 Feb 2022In a previous post, I mentioned Eigen’s block
function, which allows you to extract submatrices. But, in that post I was only aware and only wrote about the fixed-size version,
matrix.block<p,q>(i,j);
which returns a block of size (p,q), starting at (i,j) Eigen docs, Block operations. Using the fixed-size version, p
and q
cannot be variables, instead they have to be constants.
There is a dynamic version,
matrix.block(i,j,p,q);
which allows for the case when the size(s) of the block are variables.