Re: [eigen] Matrix types - please explain!

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


Hi Helmut,

On Thu, Sep 20, 2012 at 6:33 PM, Helmut Jarausch
<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> looking for the type of expressions like
> Mat.block(.....) and Mat.topRightConer(..), etc
>
> I have seen the following types in  test/householder.cpp :
>
>   typedef Matrix<Scalar, MatrixType::RowsAtCompileTime,
> MatrixType::RowsAtCompileTime> SquareMatrixType;
>   typedef Matrix<Scalar, MatrixType::ColsAtCompileTime,
> MatrixType::ColsAtCompileTime> RightSquareMatrixType;
>   typedef Matrix<Scalar, MatrixType::ColsAtCompileTime,
> MatrixType::RowsAtCompileTime> TMatrixType;
>
>   typedef Matrix<Scalar, Dynamic, MatrixType::ColsAtCompileTime>
> HBlockMatrixType;
>   typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, Dynamic>
> VBlockMatrixType;
>
>
> Can anybody please explain the difference?

1) SquareMatrixType/RightSquareMatrixType

Advantageous when RowsAtCompileTime != Eigen::Dynamic or
ColsAtCompileTime != Dynamic.

Example: Matrix<Scalar,2,3>
SquareMatrixType = Matrix<Scalar,2,2> without the need of dynamic allocations.
RightSquareMatrixType = Matrix<Scalar,3,3> without the need of dynamic
allocations.

2) TMatrixType

Looks like the transposed matrix type.

Example: Matrix<Scalar,2,3>
TMatrixType = Matrix<Scalar,3,2> again without the need of dynamic allocations

3) H/VBlockMatrixType

a) The dense type a class Block with dynamic rows and fixed size
columns could be assigned to.
b) The dense type a class Block with fixed rows and dynamic columns
could be assigned to.

I have to admit that I am a little bit confused by the naming since I
thought H=horizontal and V=vertical and I assumed further that H/V
indicated the dynamic dimension.

> MatrixXd Mat;
> auto SubMatrix= Mat.block(i,j,rows,cols);

None of the above. SubMatrix would be of type Block (expression type
that behaves a little bit like a matrix but does not right away copy
the data until you assign the object). You could find out via

  Eigen::MatrixXd mat(10,10);
  auto sub_matrix = mat.block(0,0,5,5);
  std::cout << typeid(sub_matrix).name() << std::endl;

I hope that helps a bit and that I got nothing wrong.

Regards,
Hauke



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/