[eigen] discrepancy in (triangular view + transpose) and self-adjointness |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: [eigen] discrepancy in (triangular view + transpose) and self-adjointness
- From: Manoj Rajagopalan <rmanoj@xxxxxxxxx>
- Date: Wed, 14 Jul 2010 19:02:52 -0400
- Organization: EECS Dept., University of Michigan, Ann Arbor, MI, USA
Hi all,
Could someone please help me figure out the source of the following
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);
C1 = A.selfadjointView<Lower>();
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
comments?
thanks,
Manoj