make the accessors to internal sparse storage part of the public API and remove their "_" prefix.

This commit is contained in:
Gael Guennebaud
2011-12-04 12:19:26 +01:00
parent 1cdbae62db
commit 32917515df
13 changed files with 153 additions and 130 deletions

View File

@@ -121,6 +121,7 @@ template<typename _Scalar, int _Options, typename _Index>
}
class InnerIterator;
class ReverseInnerIterator;
void setZero()
{
@@ -348,4 +349,20 @@ class DynamicSparseMatrix<Scalar,_Options,_Index>::InnerIterator : public Sparse
const Index m_outer;
};
template<typename Scalar, int _Options, typename _Index>
class DynamicSparseMatrix<Scalar,_Options,_Index>::ReverseInnerIterator : public SparseVector<Scalar,_Options,_Index>::ReverseInnerIterator
{
typedef typename SparseVector<Scalar,_Options,_Index>::ReverseInnerIterator Base;
public:
ReverseInnerIterator(const DynamicSparseMatrix& mat, Index outer)
: Base(mat.m_data[outer]), m_outer(outer)
{}
inline Index row() const { return IsRowMajor ? m_outer : Base::index(); }
inline Index col() const { return IsRowMajor ? Base::index() : m_outer; }
protected:
const Index m_outer;
};
#endif // EIGEN_DYNAMIC_SPARSEMATRIX_H

View File

@@ -268,12 +268,12 @@ class RandomSetter
for (Index j=0; j<mp_target->outerSize(); ++j)
{
Index tmp = positions[j];
mp_target->_outerIndexPtr()[j] = count;
mp_target->outerIndexPtr()[j] = count;
positions[j] = count;
count += tmp;
}
mp_target->makeCompressed();
mp_target->_outerIndexPtr()[mp_target->outerSize()] = count;
mp_target->outerIndexPtr()[mp_target->outerSize()] = count;
mp_target->resizeNonZeros(count);
// pass 2
for (Index k=0; k<m_outerPackets; ++k)
@@ -288,16 +288,16 @@ class RandomSetter
// Note that we have to deal with at most 2^OuterPacketBits unsorted coefficients,
// moreover those 2^OuterPacketBits coeffs are likely to be sparse, an so only a
// small fraction of them have to be sorted, whence the following simple procedure:
Index posStart = mp_target->_outerIndexPtr()[outer];
Index posStart = mp_target->outerIndexPtr()[outer];
Index i = (positions[outer]++) - 1;
while ( (i >= posStart) && (mp_target->_innerIndexPtr()[i] > inner) )
while ( (i >= posStart) && (mp_target->innerIndexPtr()[i] > inner) )
{
mp_target->_valuePtr()[i+1] = mp_target->_valuePtr()[i];
mp_target->_innerIndexPtr()[i+1] = mp_target->_innerIndexPtr()[i];
mp_target->valuePtr()[i+1] = mp_target->valuePtr()[i];
mp_target->innerIndexPtr()[i+1] = mp_target->innerIndexPtr()[i];
--i;
}
mp_target->_innerIndexPtr()[i+1] = inner;
mp_target->_valuePtr()[i+1] = it->second.value;
mp_target->innerIndexPtr()[i+1] = inner;
mp_target->valuePtr()[i+1] = it->second.value;
}
}
}

View File

@@ -250,9 +250,9 @@ void SparseLDLT<_MatrixType,Backend>::_symbolic(const _MatrixType& a)
ei_declare_aligned_stack_constructed_variable(Index, tags, size, 0);
const Index* Ap = a._outerIndexPtr();
const Index* Ai = a._innerIndexPtr();
Index* Lp = m_matrix._outerIndexPtr();
const Index* Ap = a.outerIndexPtr();
const Index* Ai = a.innerIndexPtr();
Index* Lp = m_matrix.outerIndexPtr();
const Index* P = 0;
Index* Pinv = 0;
@@ -311,12 +311,12 @@ bool SparseLDLT<_MatrixType,Backend>::_numeric(const _MatrixType& a)
assert(m_parent.size()==size);
assert(m_nonZerosPerCol.size()==size);
const Index* Ap = a._outerIndexPtr();
const Index* Ai = a._innerIndexPtr();
const Scalar* Ax = a._valuePtr();
const Index* Lp = m_matrix._outerIndexPtr();
Index* Li = m_matrix._innerIndexPtr();
Scalar* Lx = m_matrix._valuePtr();
const Index* Ap = a.outerIndexPtr();
const Index* Ai = a.innerIndexPtr();
const Scalar* Ax = a.valuePtr();
const Index* Lp = m_matrix.outerIndexPtr();
Index* Li = m_matrix.innerIndexPtr();
Scalar* Lx = m_matrix.valuePtr();
m_diag.resize(size);
ei_declare_aligned_stack_constructed_variable(Scalar, y, size, 0);