Main MRPT website > C++ reference
MRPT logo
Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes | Friends
Eigen::SparseMatrix Class Reference

Detailed Description

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 TopicCustomizingEigen by defining the preprocessor symbol EIGEN_SPARSEMATRIX_PLUGIN.

Inheritance diagram for Eigen::SparseMatrix:
Inheritance graph
[legend]

List of all members.

Classes

struct  default_prunning_func
class  InnerIterator

Public Types

enum  { Options = _Options }
typedef MappedSparseMatrix
< Scalar, Flags > 
Map
typedef CompressedStorage
< Scalar, Index > 
Storage

Public Member Functions

Index rows () const
Index cols () const
Index innerSize () const
Index outerSize () const
Index innerNonZeros (Index j) const
const Scalar * _valuePtr () const
Scalar * _valuePtr ()
const Index * _innerIndexPtr () const
Index * _innerIndexPtr ()
const Index * _outerIndexPtr () const
Index * _outerIndexPtr ()
Storage & data ()
const Storage & data () const
Scalar coeff (Index row, Index col) const
Scalar & coeffRef (Index row, Index col)
void setZero ()
 Removes all non zeros.
Index nonZeros () const
void reserve (Index reserveSize)
 Preallocates reserveSize non zeros.
Scalar & insertBack (Index row, Index col)
Scalar & insertBackByOuterInner (Index outer, Index inner)
Scalar & insertBackByOuterInnerUnordered (Index outer, Index inner)
void startVec (Index outer)
EIGEN_DONT_INLINE Scalar & insert (Index row, Index col)
void finalize ()
 Must be called after inserting a set of non zero entries.
void prune (Scalar reference, RealScalar epsilon=NumTraits< RealScalar >::dummy_precision())
 Suppress all nonzeros which are smaller than reference under the tolerence epsilon.
template<typename KeepFunc >
void prune (const KeepFunc &keep=KeepFunc())
 Suppress all nonzeros which do not satisfy the predicate keep.
void resize (Index rows, Index cols)
 Resizes the matrix to a rows x cols matrix and initializes it to zero.
void resizeNonZeros (Index size)
 Low level API Resize the nonzero vector to size.
 SparseMatrix ()
 Default constructor yielding an empty 0 x 0 matrix.
 SparseMatrix (Index rows, Index cols)
 Constructs a rows x cols empty matrix.
template<typename OtherDerived >
 SparseMatrix (const SparseMatrixBase< OtherDerived > &other)
 Constructs a sparse matrix from the sparse expression other.
 SparseMatrix (const SparseMatrix &other)
 Copy constructor.
void swap (SparseMatrix &other)
 Swap the content of two sparse matrices of same type (optimization)
SparseMatrix & operator= (const SparseMatrix &other)
template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrix & operator= (const SparseMatrixBase< OtherDerived > &other)
 ~SparseMatrix ()
 Destructor.
Scalar sum () const
 Overloaded for performance.
EIGEN_DEPRECATED void startFill (Index reserveSize=1000)
EIGEN_DEPRECATED Scalar & fillrand (Index row, Index col)
EIGEN_DEPRECATED Scalar & fill (Index row, Index col)
EIGEN_DEPRECATED void endFill ()

Protected Types

typedef SparseMatrix< Scalar,(Flags
&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> 
TransposedSparseMatrix

Protected Attributes

Index m_outerSize
Index m_innerSize
Index * m_outerIndex
CompressedStorage< Scalar, Index > m_data

Friends

std::ostream & operator<< (std::ostream &s, const SparseMatrix &m)

Member Typedef Documentation

Definition at line 83 of file Sparse.

Definition at line 85 of file Sparse.

typedef SparseMatrix<Scalar,(Flags&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> Eigen::SparseMatrix::TransposedSparseMatrix [protected]

Definition at line 92 of file Sparse.


Member Enumeration Documentation

anonymous enum
Enumerator:
Options 

Definition at line 86 of file Sparse.


Constructor & Destructor Documentation

Eigen::SparseMatrix::SparseMatrix ( ) [inline]

Default constructor yielding an empty 0 x 0 matrix.

Definition at line 400 of file Sparse.

Eigen::SparseMatrix::SparseMatrix ( Index  rows,
Index  cols 
) [inline]

Constructs a rows x cols empty matrix.

Definition at line 407 of file Sparse.

template<typename OtherDerived >
Eigen::SparseMatrix::SparseMatrix ( const SparseMatrixBase< OtherDerived > &  other) [inline]

Constructs a sparse matrix from the sparse expression other.

Definition at line 415 of file Sparse.

Eigen::SparseMatrix::SparseMatrix ( const SparseMatrix &  other) [inline]

Copy constructor.

Definition at line 422 of file Sparse.

Eigen::SparseMatrix::~SparseMatrix ( ) [inline]

Destructor.

Definition at line 545 of file Sparse.


Member Function Documentation

const Index* Eigen::SparseMatrix::_innerIndexPtr ( ) const [inline]

Definition at line 111 of file Sparse.

Index* Eigen::SparseMatrix::_innerIndexPtr ( ) [inline]

Definition at line 112 of file Sparse.

const Index* Eigen::SparseMatrix::_outerIndexPtr ( ) const [inline]

Definition at line 114 of file Sparse.

Index* Eigen::SparseMatrix::_outerIndexPtr ( ) [inline]

Definition at line 115 of file Sparse.

const Scalar* Eigen::SparseMatrix::_valuePtr ( ) const [inline]

Definition at line 108 of file Sparse.

Scalar* Eigen::SparseMatrix::_valuePtr ( ) [inline]

Definition at line 109 of file Sparse.

Scalar Eigen::SparseMatrix::coeff ( Index  row,
Index  col 
) const [inline]

Definition at line 120 of file Sparse.

Scalar& Eigen::SparseMatrix::coeffRef ( Index  row,
Index  col 
) [inline]

Definition at line 127 of file Sparse.

Index Eigen::SparseMatrix::cols ( void  ) const [inline]
Returns:
the number of columns.
See also:
rows(), ColsAtCompileTime

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 102 of file Sparse.

Storage& Eigen::SparseMatrix::data ( ) [inline]

Definition at line 117 of file Sparse.

const Storage& Eigen::SparseMatrix::data ( ) const [inline]

Definition at line 118 of file Sparse.

EIGEN_DEPRECATED void Eigen::SparseMatrix::endFill ( ) [inline]
Deprecated:
use finalize

Definition at line 606 of file Sparse.

EIGEN_DEPRECATED Scalar& Eigen::SparseMatrix::fill ( Index  row,
Index  col 
) [inline]
Deprecated:
use insert()

Definition at line 576 of file Sparse.

EIGEN_DEPRECATED Scalar& Eigen::SparseMatrix::fillrand ( Index  row,
Index  col 
) [inline]
Deprecated:
use insert() Like fill() but with random inner coordinates.

Definition at line 569 of file Sparse.

void Eigen::SparseMatrix::finalize ( ) [inline]

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

Definition at line 324 of file Sparse.

Index Eigen::SparseMatrix::innerNonZeros ( Index  j) const [inline]

Definition at line 106 of file Sparse.

Index Eigen::SparseMatrix::innerSize ( ) const [inline]
Returns:
the size of the inner dimension according to the storage order, i.e., the number of rows for a columns major matrix, and the number of cols otherwise

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 104 of file Sparse.

EIGEN_DONT_INLINE Scalar& Eigen::SparseMatrix::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.

Definition at line 215 of file Sparse.

Scalar& Eigen::SparseMatrix::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

Definition at line 172 of file Sparse.

Scalar& Eigen::SparseMatrix::insertBackByOuterInner ( Index  outer,
Index  inner 
) [inline]
See also:
insertBack, startVec

Definition at line 178 of file Sparse.

Scalar& Eigen::SparseMatrix::insertBackByOuterInnerUnordered ( Index  outer,
Index  inner 
) [inline]
Warning:
use it only if you know what you are doing

Definition at line 189 of file Sparse.

Index Eigen::SparseMatrix::nonZeros ( ) const [inline]
Returns:
the number of non zero coefficients

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 153 of file Sparse.

SparseMatrix& Eigen::SparseMatrix::operator= ( const SparseMatrix &  other) [inline]

Definition at line 438 of file Sparse.

template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrix& Eigen::SparseMatrix::operator= ( const SparseMatrixBase< OtherDerived > &  other) [inline]

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 469 of file Sparse.

Index Eigen::SparseMatrix::outerSize ( ) const [inline]
Returns:
the size of the storage major dimension, i.e., the number of columns for a columns major matrix, and the number of rows otherwise

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 105 of file Sparse.

void Eigen::SparseMatrix::prune ( Scalar  reference,
RealScalar  epsilon = NumTraits<RealScalar>::dummy_precision() 
) [inline]

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

Definition at line 340 of file Sparse.

template<typename KeepFunc >
void Eigen::SparseMatrix::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)

Definition at line 353 of file Sparse.

void Eigen::SparseMatrix::reserve ( Index  reserveSize) [inline]

Preallocates reserveSize non zeros.

Definition at line 156 of file Sparse.

void Eigen::SparseMatrix::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()

Definition at line 378 of file Sparse.

void Eigen::SparseMatrix::resizeNonZeros ( Index  size) [inline]

Low level API Resize the nonzero vector to size.

Definition at line 394 of file Sparse.

Index Eigen::SparseMatrix::rows ( void  ) const [inline]
Returns:
the number of rows.
See also:
cols(), RowsAtCompileTime

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 101 of file Sparse.

void Eigen::SparseMatrix::setZero ( ) [inline]

Removes all non zeros.

Definition at line 146 of file Sparse.

EIGEN_DEPRECATED void Eigen::SparseMatrix::startFill ( Index  reserveSize = 1000) [inline]
Deprecated:
use setZero() and reserve() Initializes the filling process of *this.
Parameters:
reserveSizeapproximate number of nonzeros Note that the matrix *this is zero-ed.

Definition at line 560 of file Sparse.

void Eigen::SparseMatrix::startVec ( Index  outer) [inline]
See also:
insertBack, insertBackByOuterInner

Definition at line 198 of file Sparse.

internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar Eigen::SparseMatrix::sum ( ) const

Overloaded for performance.

Reimplemented from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 43 of file Sparse.

void Eigen::SparseMatrix::swap ( SparseMatrix &  other) [inline]

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

Definition at line 429 of file Sparse.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  s,
const SparseMatrix &  m 
) [friend]

Definition at line 522 of file Sparse.


Member Data Documentation

Definition at line 97 of file Sparse.

Definition at line 95 of file Sparse.

Definition at line 96 of file Sparse.

Definition at line 94 of file Sparse.




Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Sun Oct 16 12:16:33 UTC 2011