diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-02-05 18:37:21 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-02-05 18:37:21 +0000 |
commit | 910b387438bc71ab418b4fbb0a3561133a85a131 (patch) | |
tree | c5be9de53845a0f68d1fda9a21bf555de2fe682f /test | |
parent | 9637af5ecf629e0abd3078c61bdfbb0b2c507527 (diff) |
Add sub/super-diagonal expression (read/write) as a trivial extension of
DiagonalCoeffs. The current API is simply:
m.diagonal<1>() => 1st super diagonal
m.diagonal<-2>() => the 2nd sub diagonal
I'll add a code snippet once we agree on this API.
Diffstat (limited to 'test')
-rw-r--r-- | test/submatrices.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/submatrices.cpp b/test/submatrices.cpp index 63c61baca..e34650842 100644 --- a/test/submatrices.cpp +++ b/test/submatrices.cpp @@ -138,6 +138,20 @@ template<typename MatrixType> void submatrices(const MatrixType& m) VERIFY_IS_APPROX(v1.template end<2>(), v1.template segment<2>(i)); i = ei_random(0,rows-2); VERIFY_IS_APPROX(v1.segment(i,2), v1.template segment<2>(i)); + + enum { + N1 = MatrixType::RowsAtCompileTime>1 ? 1 : 0, + N2 = MatrixType::RowsAtCompileTime>2 ? -2 : 0 + }; + + // check sub/super diagonal + m2.template diagonal<N1>() = 2 * m1.template diagonal<N1>(); + m2.template diagonal<N1>()[0] *= 3; + VERIFY_IS_APPROX(m2.template diagonal<N1>()[0], static_cast<Scalar>(6) * m1.template diagonal<N1>()[0]); + + m2.template diagonal<N2>() = 2 * m1.template diagonal<N2>(); + m2.template diagonal<N2>()[0] *= 3; + VERIFY_IS_APPROX(m2.template diagonal<N2>()[0], static_cast<Scalar>(6) * m1.template diagonal<N2>()[0]); } // stress some basic stuffs with block matrices |