Re: [eigen] discrepancy in (triangular view + transpose) and self-adjointness
• To: eigen@xxxxxxxxxxxxxxxxxxx
• Subject: Re: [eigen] discrepancy in (triangular view + transpose) and self-adjointness
• From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
• Date: Wed, 14 Jul 2010 19:14:02 -0400

```Hi,

It would help if you could make a compilable test program, so we can
quickly run stuff.

Benoit

2010/7/14 Manoj Rajagopalan <rmanoj@xxxxxxxxx>:
> Hi all,
>
> discrepancy?
>
>   Given:
>        int const N = 5;
>        MatrixXi A(N,N);
>        A.setRandom();
>
>        TriangularView<MatrixXi,Lower> const A_l(A);
>        TriangularView<MatrixXi,Lower|ZeroDiag> const A_zl(A);
>
> the following must be true:
>
>   A.selfadjointView<Lower>() == A_l + A_zl.transpose()
>
> Basically, I am adding the lower triangle of A to its own transpose, without
> adding the diagonal a second time. So the following is calculated correctly
> by Eigen:
>
>    MatrixXi C1(N,N), C2(N,N);
>    C2 = A_l.toDenseMatrix() + A_zl.transpose().toDenseMatrix();
>    assert(C1 == C2);
>
> But, the following code produces a discrepancy:
>
>    MatrixXi B(N,N);
>    B.setRandom();
>    C1 = A.selfadjointView<Lower>() * B;
>    C2 = (A_l * B)   +   (A_zl.transpose() * B);
>    assert(C1 == C2); // <--------  FALSE!
>
>     After a long day my brain is unable to figure out if I am doing something
> extremely silly - it seems too trivial to be a bug. Can someone offer