Public Member Functions | List of all members
SparseMatrix< _Scalar, _Flags, _Index > Class Template Reference

The main sparse matrix class. More...

+ Inheritance diagram for SparseMatrix< _Scalar, _Flags, _Index >:

Public Member Functions

EIGEN_DEPRECATED void endFill ()
 
EIGEN_DEPRECATED Scalar & fill (Index row, Index col)
 
EIGEN_DEPRECATED Scalar & fillrand (Index row, Index col)
 
void finalize ()
 
EIGEN_DONT_INLINE Scalar & insert (Index row, Index col)
 
Scalar & insertBack (Index row, Index col)
 
Scalar & insertBackByOuterInner (Index outer, Index inner)
 
Scalar & insertBackByOuterInnerUnordered (Index outer, Index inner)
 
Index nonZeros () const
 
void prune (Scalar reference, RealScalar epsilon=NumTraits< RealScalar >::dummy_precision())
 
template<typename KeepFunc >
void prune (const KeepFunc &keep=KeepFunc())
 
void reserve (Index reserveSize)
 
void resize (Index rows, Index cols)
 
void resizeNonZeros (Index size)
 
void setZero ()
 
 SparseMatrix ()
 
 SparseMatrix (Index rows, Index cols)
 
template<typename OtherDerived >
 SparseMatrix (const SparseMatrixBase< OtherDerived > &other)
 
 SparseMatrix (const SparseMatrix &other)
 
EIGEN_DEPRECATED void startFill (Index reserveSize=1000)
 
void startVec (Index outer)
 
Scalar sum () const
 
void swap (SparseMatrix &other)
 
 ~SparseMatrix ()
 

Detailed Description

template<typename _Scalar, int _Flags = 0, typename _Index = int>
class Eigen::SparseMatrix< _Scalar, _Flags, _Index >

The main sparse matrix class.

This class implements a sparse matrix using the very common compressed row/column storage scheme.

Template Parameters
_Scalarthe scalar type, i.e. the type of the coefficients
_OptionsUnion of bit flags controlling the storage scheme. Currently the only possibility is RowMajor. The default is 0 which means column-major.
_Indexthe type of the indices. Default is int.

See http://www.netlib.org/linalg/html_templates/node91.html for details on the storage scheme.

This class can be extended with the help of the plugin mechanism described on the page Customizing/Extending Eigen by defining the preprocessor symbol EIGEN_SPARSEMATRIX_PLUGIN.

Constructor & Destructor Documentation

SparseMatrix ( )
inline

Default constructor yielding an empty 0 x 0 matrix

SparseMatrix ( Index  rows,
Index  cols 
)
inline

Constructs a rows x cols empty matrix

SparseMatrix ( const SparseMatrixBase< OtherDerived > &  other)
inline

Constructs a sparse matrix from the sparse expression other

SparseMatrix ( const SparseMatrix< _Scalar, _Flags, _Index > &  other)
inline

Copy constructor

~SparseMatrix ( )
inline

Destructor

Member Function Documentation

EIGEN_DEPRECATED void endFill ( )
inline
EIGEN_DEPRECATED Scalar& fill ( Index  row,
Index  col 
)
inline
EIGEN_DEPRECATED Scalar& fillrand ( Index  row,
Index  col 
)
inline
void finalize ( )
inline

Must be called after inserting a set of non zero entries.

EIGEN_DONT_INLINE Scalar& insert ( Index  row,
Index  col 
)
inline
Returns
a reference to a novel non zero coefficient with coordinates row x col. The non zero coefficient must not already exist.
Warning
This function can be extremely slow if the non zero coefficients are not inserted in a coherent order.

After an insertion session, you should call the finalize() function.

Scalar& insertBack ( Index  row,
Index  col 
)
inline
Returns
a reference to the non zero coefficient at position row, col assuming that:
  • the nonzero does not already exist
  • the new coefficient is the last one according to the storage order

Before filling a given inner vector you must call the statVec(Index) function.

After an insertion session, you should call the finalize() function.

See Also
insert, insertBackByOuterInner, startVec
Scalar& insertBackByOuterInner ( Index  outer,
Index  inner 
)
inline
See Also
insertBack, startVec
Scalar& insertBackByOuterInnerUnordered ( Index  outer,
Index  inner 
)
inline
Warning
use it only if you know what you are doing
Index nonZeros ( ) const
inline
Returns
the number of non zero coefficients
void prune ( Scalar  reference,
RealScalar  epsilon = NumTraits<RealScalar>::dummy_precision() 
)
inline

Suppress all nonzeros which are smaller than reference under the tolerence epsilon

void prune ( const KeepFunc &  keep = KeepFunc())
inline

Suppress all nonzeros which do not satisfy the predicate keep. The functor type KeepFunc must implement the following function:

bool operator() (const Index& row, const Index& col, const Scalar& value) const;
See Also
prune(Scalar,RealScalar)
void reserve ( Index  reserveSize)
inline

Preallocates reserveSize non zeros

void resize ( Index  rows,
Index  cols 
)
inline

Resizes the matrix to a rows x cols matrix and initializes it to zero

See Also
resizeNonZeros(Index), reserve(), setZero()
void resizeNonZeros ( Index  size)
inline

Low level API Resize the nonzero vector to size

void setZero ( )
inline

Removes all non zeros

EIGEN_DEPRECATED void startFill ( Index  reserveSize = 1000)
inline
Parameters
reserveSizeapproximate number of nonzeros Note that the matrix *this is zero-ed.
void startVec ( Index  outer)
inline
internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar sum ( ) const

Overloaded for performance

void swap ( SparseMatrix< _Scalar, _Flags, _Index > &  other)
inline

Swap the content of two sparse matrices of same type (optimization)


The documentation for this class was generated from the following files: