diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-10-06 16:11:26 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-10-06 16:11:26 +0200 |
commit | d44d432baa142fdbe17f9d3abeab2c7629e199b8 (patch) | |
tree | e36ed1b2515d9d307925fa30ef4e389b279d1ed1 /test/sparse_product.cpp | |
parent | 893bfcf95fd7aaa49747f029bac708a02a1526cd (diff) |
Re-enable products with triangular views of sparse matrices: we simply have to treat them as a sparse matrix.
Diffstat (limited to 'test/sparse_product.cpp')
-rw-r--r-- | test/sparse_product.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index fa9be5440..366e27274 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -194,7 +194,7 @@ template<typename SparseMatrixType> void sparse_product() VERIFY_IS_APPROX(d3=d1*m2.transpose(), refM3=d1*refM2.transpose()); } - // test self adjoint products + // test self-adjoint and traingular-view products { DenseMatrix b = DenseMatrix::Random(rows, rows); DenseMatrix x = DenseMatrix::Random(rows, rows); @@ -202,9 +202,12 @@ template<typename SparseMatrixType> void sparse_product() DenseMatrix refUp = DenseMatrix::Zero(rows, rows); DenseMatrix refLo = DenseMatrix::Zero(rows, rows); DenseMatrix refS = DenseMatrix::Zero(rows, rows); + DenseMatrix refA = DenseMatrix::Zero(rows, rows); SparseMatrixType mUp(rows, rows); SparseMatrixType mLo(rows, rows); SparseMatrixType mS(rows, rows); + SparseMatrixType mA(rows, rows); + initSparse<Scalar>(density, refA, mA); do { initSparse<Scalar>(density, refUp, mUp, ForceRealDiag|/*ForceNonZeroDiag|*/MakeUpperTriangular); } while (refUp.isZero()); @@ -224,19 +227,30 @@ template<typename SparseMatrixType> void sparse_product() VERIFY_IS_APPROX(mS, refS); VERIFY_IS_APPROX(x=mS*b, refX=refS*b); + // sparse selfadjointView with dense matrices VERIFY_IS_APPROX(x=mUp.template selfadjointView<Upper>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mLo.template selfadjointView<Lower>()*b, refX=refS*b); VERIFY_IS_APPROX(x=mS.template selfadjointView<Upper|Lower>()*b, refX=refS*b); - // sparse selfadjointView * sparse + // sparse selfadjointView with sparse matrices SparseMatrixType mSres(rows,rows); VERIFY_IS_APPROX(mSres = mLo.template selfadjointView<Lower>()*mS, refX = refLo.template selfadjointView<Lower>()*refS); - // sparse * sparse selfadjointview VERIFY_IS_APPROX(mSres = mS * mLo.template selfadjointView<Lower>(), refX = refS * refLo.template selfadjointView<Lower>()); + + // sparse triangularView with dense matrices + VERIFY_IS_APPROX(x=mA.template triangularView<Upper>()*b, refX=refA.template triangularView<Upper>()*b); + VERIFY_IS_APPROX(x=mA.template triangularView<Lower>()*b, refX=refA.template triangularView<Lower>()*b); + VERIFY_IS_APPROX(x=b*mA.template triangularView<Upper>(), refX=b*refA.template triangularView<Upper>()); + VERIFY_IS_APPROX(x=b*mA.template triangularView<Lower>(), refX=b*refA.template triangularView<Lower>()); + + // sparse triangularView with sparse matrices + VERIFY_IS_APPROX(mSres = mA.template triangularView<Lower>()*mS, refX = refA.template triangularView<Lower>()*refS); + VERIFY_IS_APPROX(mSres = mS * mA.template triangularView<Lower>(), refX = refS * refA.template triangularView<Lower>()); + VERIFY_IS_APPROX(mSres = mA.template triangularView<Upper>()*mS, refX = refA.template triangularView<Upper>()*refS); + VERIFY_IS_APPROX(mSres = mS * mA.template triangularView<Upper>(), refX = refS * refA.template triangularView<Upper>()); } - } // New test for Bug in SparseTimeDenseProduct |