Re: [eigen] Missing methods for Eigen::DiagonalMatrix

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


Hi Matthias,

I can't be sure of the real reasons for that, but my take is that:
 - the methods you are referring to are not meaningful at the level of the common base class for DiagonalMatrix and Matrix (i.e. EigenBase), so they are not implemented there and DiagonalMatrix does not inherit them
 - there are easy workarounds to achieve the same goal, that are usually as efficient as a special implementation would be.

In your case, you can achieve what you want with:

    DiagonalMatrix<double, Dynamic> M(10);
    M.diagonal().setOnes();
    std::cout << M.toDenseMatrix() << std::endl;

Idem for M.diagonal().setRandom()

Best regards,
Adrien


On Tue, Oct 20, 2020 at 4:38 PM Matthias Peschke <mpeschke@xxxxxxxxxxxxxxxxxxxxxx> wrote:
I recently start using the type Eigen::DiagonalMatrix but it seems that
some methods for this type are missing. This includes the stream
operator which is not present so that the following does not compile:

         Eigen::DiagonalMatrix<double,-1> M(10); M.setIdentity();
         std::cout << M << std::endl;

Another example is setRandom() which is not implemented and there are no
block operations present.

Is there a special reason for this or it is because
Eigen::DiagonalMatrix is rarely used?

Best regards,
Matthias





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