aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sparse_product.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2012-10-02 23:03:06 +0200
committerGravatar Gael Guennebaud <g.gael@free.fr>2012-10-02 23:03:06 +0200
commitf30ca7ed7e1c756fcc76389ddbc361486f7d8c42 (patch)
treee729fa8328e8f38577d89c158a67419887f7419b /test/sparse_product.cpp
parent62b1f75a860f557db2ff8fbb6a41b363b571c693 (diff)
extend unit tests to check rectangular matrices for sparse*diagonal products
Diffstat (limited to 'test/sparse_product.cpp')
-rw-r--r--test/sparse_product.cpp19
1 files changed, 10 insertions, 9 deletions
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<typename SparseMatrixType> 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<Scalar,Dynamic,Dynamic> DenseMatrix;
typedef Matrix<Scalar,Dynamic,1> DenseVector;
@@ -121,17 +121,18 @@ template<typename SparseMatrixType> void sparse_product()
// test matrix - diagonal product
{
- DenseMatrix refM2 = DenseMatrix::Zero(rows, rows);
- DenseMatrix refM3 = DenseMatrix::Zero(rows, rows);
- DiagonalMatrix<Scalar,Dynamic> 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<Scalar,Dynamic> d1(DenseVector::Random(cols));
+ DiagonalMatrix<Scalar,Dynamic> d2(DenseVector::Random(rows));
+ SparseMatrixType m2(rows, cols);
+ SparseMatrixType m3(rows, cols);
initSparse<Scalar>(density, refM2, m2);
initSparse<Scalar>(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