mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-16 14:49:39 +08:00
optimize A * v product for A sparse and row major
This commit is contained in:
parent
178858f1bd
commit
36c478cd6e
@ -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);
|
||||
|
@ -103,7 +103,7 @@ class SparseVector
|
||||
*/
|
||||
inline Scalar& coeffRef(int i)
|
||||
{
|
||||
return m_data.atWithInsertiob(i);
|
||||
return m_data.atWithInsertion(i);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user