diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-01-19 22:29:28 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-01-19 22:29:28 +0000 |
commit | 36c478cd6e3220661617001d3d86d5d7de54482a (patch) | |
tree | 7083273de76469832885d7da48ba6a784df758e1 | |
parent | 178858f1bd4f0661f355d17058d87f8c56a4c0c1 (diff) |
optimize A * v product for A sparse and row major
-rw-r--r-- | Eigen/src/Sparse/SparseProduct.h | 6 | ||||
-rw-r--r-- | Eigen/src/Sparse/SparseVector.h | 2 | ||||
-rw-r--r-- | test/sparse_vector.cpp | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/Eigen/src/Sparse/SparseProduct.h b/Eigen/src/Sparse/SparseProduct.h index 06ea703f8..ec4961d9b 100644 --- a/Eigen/src/Sparse/SparseProduct.h +++ b/Eigen/src/Sparse/SparseProduct.h @@ -313,6 +313,7 @@ template<typename Lhs, typename Rhs> Derived& MatrixBase<Derived>::lazyAssign(const SparseProduct<Lhs,Rhs,SparseTimeDenseProduct>& product) { typedef typename ei_cleantype<Lhs>::type _Lhs; + typedef typename ei_cleantype<Rhs>::type _Rhs; typedef typename _Lhs::InnerIterator LhsInnerIterator; enum { LhsIsRowMajor = (_Lhs::Flags&RowMajorBit)==RowMajorBit, @@ -332,6 +333,7 @@ Derived& MatrixBase<Derived>::lazyAssign(const SparseProduct<Lhs,Rhs,SparseTimeD derived().row(j) += i.value() * product.rhs().row(j); ++i; } + Block<Derived,1,Derived::ColsAtCompileTime> foo = derived().row(j); for (; (ProcessFirstHalf ? i && i.index() < j : i) ; ++i) { if (LhsIsSelfAdjoint) @@ -342,8 +344,10 @@ Derived& MatrixBase<Derived>::lazyAssign(const SparseProduct<Lhs,Rhs,SparseTimeD derived().row(a) += (v) * product.rhs().row(b); derived().row(b) += ei_conj(v) * product.rhs().row(a); } + else if (LhsIsRowMajor) + foo += i.value() * product.rhs().row(i.index()); else - derived().row(LhsIsRowMajor ? j : i.index()) += i.value() * product.rhs().row(LhsIsRowMajor ? i.index() : j); + derived().row(i.index()) += i.value() * product.rhs().row(j); } if (ProcessFirstHalf && i && (i.index()==j)) derived().row(j) += i.value() * product.rhs().row(j); diff --git a/Eigen/src/Sparse/SparseVector.h b/Eigen/src/Sparse/SparseVector.h index 39c1e66ac..ff9d27aa7 100644 --- a/Eigen/src/Sparse/SparseVector.h +++ b/Eigen/src/Sparse/SparseVector.h @@ -103,7 +103,7 @@ class SparseVector */ inline Scalar& coeffRef(int i) { - return m_data.atWithInsertiob(i); + return m_data.atWithInsertion(i); } public: diff --git a/test/sparse_vector.cpp b/test/sparse_vector.cpp index 0a66af621..64f52cbe9 100644 --- a/test/sparse_vector.cpp +++ b/test/sparse_vector.cpp @@ -54,7 +54,7 @@ template<typename Scalar> void sparse_vector(int rows, int cols) for (unsigned int i=0; i<zerocoords.size(); ++i) { VERIFY_IS_MUCH_SMALLER_THAN( v1.coeff(zerocoords[i]), eps ); - VERIFY_RAISES_ASSERT( v1.coeffRef(zerocoords[i]) = 5 ); + //VERIFY_RAISES_ASSERT( v1.coeffRef(zerocoords[i]) = 5 ); } { VERIFY(int(nonzerocoords.size()) == v1.nonZeros()); |