sparse module: makes -= and += operator working

Question 1: why are *=scalar and /=scalar working right away ?
Same weirdness in DynamicSparseMatrix where operators += and -= work wihout
  having to redefine them ???
This commit is contained in:
Gael Guennebaud
2009-01-23 13:59:32 +00:00
parent 899e2ada15
commit e7c48fac9b
6 changed files with 49 additions and 4 deletions

View File

@@ -57,6 +57,8 @@ class SparseVector
{
public:
EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseVector)
EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, +=)
EIGEN_SPARSE_INHERIT_ASSIGNMENT_OPERATOR(SparseVector, -=)
protected:
public:
@@ -117,14 +119,32 @@ class SparseVector
/**
*/
inline void reserve(int reserveSize) { m_data.reserve(reserveSize); }
inline void startFill(int reserve)
{
setZero();
m_data.reserve(reserve);
}
/**
*/
inline Scalar& fill(int r, int c)
{
ei_assert(r==0 || c==0);
return fill(IsColVector ? r : c);
}
inline Scalar& fill(int i)
{
m_data.append(0, i);
return m_data.value(m_data.size()-1);
}
inline Scalar& fillrand(int r, int c)
{
ei_assert(r==0 || c==0);
return fillrand(IsColVector ? r : c);
}
/** Like fill() but with random coordinates.
*/
@@ -145,10 +165,18 @@ class SparseVector
return m_data.value(id+1);
}
inline void endFill() {}
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
{
m_data.prune(reference,epsilon);
}
void resize(int rows, int cols)
{
ei_assert(rows==1 || cols==1);
resize(IsColVector ? rows : cols);
}
void resize(int newSize)
{
@@ -161,6 +189,8 @@ class SparseVector
inline SparseVector() : m_size(0) { resize(0); }
inline SparseVector(int size) : m_size(0) { resize(size); }
inline SparseVector(int rows, int cols) : m_size(0) { resize(rows,cols); }
template<typename OtherDerived>
inline SparseVector(const MatrixBase<OtherDerived>& other)