diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 10:26:24 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 10:26:24 +0200 |
commit | 1927b4dff513f66866de205a46c66a1f2c877d01 (patch) | |
tree | 809f38f1017e793e28c57d63d315e344d103abec /test | |
parent | 28e64b0da371f77bd0877fe7013cfeda25ea8438 (diff) |
Fix use of nesting types in SparseTranspose and split the big SparseProduct.h file
Diffstat (limited to 'test')
-rw-r--r-- | test/sparse_product.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index c07735e43..44239545c 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -36,6 +36,9 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& typedef Matrix<Scalar,Dynamic,Dynamic> DenseMatrix; typedef Matrix<Scalar,Dynamic,1> DenseVector; + Scalar s1 = ei_random<Scalar>(); + Scalar s2 = ei_random<Scalar>(); + // test matrix-matrix product { DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows); @@ -49,11 +52,16 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& initSparse<Scalar>(density, refMat2, m2); initSparse<Scalar>(density, refMat3, m3); initSparse<Scalar>(density, refMat4, m4); + VERIFY_IS_APPROX(m4=m2*m3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(m4=m2.transpose()*m3, refMat4=refMat2.transpose()*refMat3); VERIFY_IS_APPROX(m4=m2.transpose()*m3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose()); VERIFY_IS_APPROX(m4=m2*m3.transpose(), refMat4=refMat2*refMat3.transpose()); + VERIFY_IS_APPROX(m4 = m2*m3/s1, refMat4 = refMat2*refMat3/s1); + VERIFY_IS_APPROX(m4 = m2*m3*s1, refMat4 = refMat2*refMat3*s1); + VERIFY_IS_APPROX(m4 = s2*m2*m3*s1, refMat4 = s2*refMat2*refMat3*s1); + // sparse * dense VERIFY_IS_APPROX(dm4=m2*refMat3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(dm4=m2*refMat3.transpose(), refMat4=refMat2*refMat3.transpose()); @@ -62,7 +70,7 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& VERIFY_IS_APPROX(dm4=m2*(refMat3+refMat3), refMat4=refMat2*(refMat3+refMat3)); VERIFY_IS_APPROX(dm4=m2.transpose()*(refMat3+refMat5)*0.5, refMat4=refMat2.transpose()*(refMat3+refMat5)*0.5); - + // dense * sparse VERIFY_IS_APPROX(dm4=refMat2*m3, refMat4=refMat2*refMat3); VERIFY_IS_APPROX(dm4=refMat2*m3.transpose(), refMat4=refMat2*refMat3.transpose()); |