diff options
author | Gael Guennebaud <g.gael@free.fr> | 2011-12-22 14:01:06 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2011-12-22 14:01:06 +0100 |
commit | 2c03e6fccc274db665c6e4708f2cbde14813e826 (patch) | |
tree | 9b2ca1b7b59b7f1d6fb00f2f4d749d88ca890311 /test | |
parent | 7f0484502328c1ee0ed6a3916d7f3aa4417237c1 (diff) |
evaluate 1D sparse expressions into SparseVector and make the sparse operator<< and dot honor nested types
Diffstat (limited to 'test')
-rw-r--r-- | test/sparse_vector.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/test/sparse_vector.cpp b/test/sparse_vector.cpp index 5be4f5d9a..09d36a51b 100644 --- a/test/sparse_vector.cpp +++ b/test/sparse_vector.cpp @@ -34,9 +34,9 @@ template<typename Scalar> void sparse_vector(int rows, int cols) typedef SparseMatrix<Scalar> SparseMatrixType; Scalar eps = 1e-6; - SparseMatrixType m1(rows,cols); + SparseMatrixType m1(rows,rows); SparseVectorType v1(rows), v2(rows), v3(rows); - DenseMatrix refM1 = DenseMatrix::Zero(rows, cols); + DenseMatrix refM1 = DenseMatrix::Zero(rows, rows); DenseVector refV1 = DenseVector::Random(rows), refV2 = DenseVector::Random(rows), refV3 = DenseVector::Random(rows); @@ -86,6 +86,11 @@ template<typename Scalar> void sparse_vector(int rows, int cols) VERIFY_IS_APPROX(v1.dot(v2), refV1.dot(refV2)); VERIFY_IS_APPROX(v1.dot(refV2), refV1.dot(refV2)); + VERIFY_IS_APPROX(v1.dot(m1*v2), refV1.dot(refM1*refV2)); + int i = internal::random<int>(0,rows-1); + VERIFY_IS_APPROX(v1.dot(m1.col(i)), refV1.dot(refM1.col(i))); + + VERIFY_IS_APPROX(v1.squaredNorm(), refV1.squaredNorm()); } |