diff options
author | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 11:36:38 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2010-06-25 11:36:38 +0200 |
commit | e313826890f581f1b9665422bab7b83b9daf5bfd (patch) | |
tree | a00dbdf84203cb652008e58646b8661049d21f3a /test/sparse_product.cpp | |
parent | 1927b4dff513f66866de205a46c66a1f2c877d01 (diff) |
add mixed sparse-dense outer product
Diffstat (limited to 'test/sparse_product.cpp')
-rw-r--r-- | test/sparse_product.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/test/sparse_product.cpp b/test/sparse_product.cpp index 44239545c..d4809711c 100644 --- a/test/sparse_product.cpp +++ b/test/sparse_product.cpp @@ -46,6 +46,7 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& DenseMatrix refMat4 = DenseMatrix::Zero(rows, rows); DenseMatrix refMat5 = DenseMatrix::Random(rows, rows); DenseMatrix dm4 = DenseMatrix::Zero(rows, rows); + DenseVector dv1 = DenseVector::Random(rows); SparseMatrixType m2(rows, rows); SparseMatrixType m3(rows, rows); SparseMatrixType m4(rows, rows); @@ -53,6 +54,8 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& initSparse<Scalar>(density, refMat3, m3); initSparse<Scalar>(density, refMat4, m4); + int c = ei_random<int>(0,rows-1); + 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()); @@ -77,6 +80,10 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType& VERIFY_IS_APPROX(dm4=refMat2.transpose()*m3, refMat4=refMat2.transpose()*refMat3); VERIFY_IS_APPROX(dm4=refMat2.transpose()*m3.transpose(), refMat4=refMat2.transpose()*refMat3.transpose()); + // sparse * dense and dense * sparse outer product + VERIFY_IS_APPROX(m4=m2.col(c)*dv1.transpose(), refMat4=refMat2.col(c)*dv1.transpose()); + VERIFY_IS_APPROX(m4=dv1*m2.col(c).transpose(), refMat4=dv1*refMat2.col(c).transpose()); + VERIFY_IS_APPROX(m3=m3*m3, refMat3=refMat3*refMat3); } |