From f30ca7ed7e1c756fcc76389ddbc361486f7d8c42 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 2 Oct 2012 23:03:06 +0200 Subject: extend unit tests to check rectangular matrices for sparse*diagonal products --- test/sparse_product.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'test/sparse_product.cpp') diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 17a955c9d..df660fe12 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -43,7 +43,7 @@ template void sparse_product() typedef typename SparseMatrixType::Scalar Scalar; enum { Flags = SparseMatrixType::Flags }; - double density = (std::max)(8./(rows*cols), 0.01); + double density = (std::max)(8./(rows*cols), 0.1); typedef Matrix DenseMatrix; typedef Matrix DenseVector; @@ -121,17 +121,18 @@ template void sparse_product() // test matrix - diagonal product { - DenseMatrix refM2 = DenseMatrix::Zero(rows, rows); - DenseMatrix refM3 = DenseMatrix::Zero(rows, rows); - DiagonalMatrix d1(DenseVector::Random(rows)); - SparseMatrixType m2(rows, rows); - SparseMatrixType m3(rows, rows); + DenseMatrix refM2 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM3 = DenseMatrix::Zero(rows, cols); + DiagonalMatrix d1(DenseVector::Random(cols)); + DiagonalMatrix d2(DenseVector::Random(rows)); + SparseMatrixType m2(rows, cols); + SparseMatrixType m3(rows, cols); initSparse(density, refM2, m2); initSparse(density, refM3, m3); VERIFY_IS_APPROX(m3=m2*d1, refM3=refM2*d1); - VERIFY_IS_APPROX(m3=m2.transpose()*d1, refM3=refM2.transpose()*d1); - VERIFY_IS_APPROX(m3=d1*m2, refM3=d1*refM2); - VERIFY_IS_APPROX(m3=d1*m2.transpose(), refM3=d1 * refM2.transpose()); + VERIFY_IS_APPROX(m3=m2.transpose()*d2, refM3=refM2.transpose()*d2); + VERIFY_IS_APPROX(m3=d2*m2, refM3=d2*refM2); + VERIFY_IS_APPROX(m3=d1*m2.transpose(), refM3=d1*refM2.transpose()); } // test self adjoint products -- cgit v1.2.3