Classes | Public Types | Public Member Functions | Protected Types | Protected Attributes | Friends
SparseMatrix< _Scalar, _Options, _Index > Class Template Reference

The main sparse matrix class. More...

#include <SparseMatrix.h>

Inheritance diagram for SparseMatrix< _Scalar, _Options, _Index >:
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

const Index_innerIndexPtr () const
Index_innerIndexPtr ()
const Index_outerIndexPtr () const
Index_outerIndexPtr ()
const Scalar_valuePtr () const
Scalar_valuePtr ()
Scalar coeff (Index row, Index col) const
ScalarcoeffRef (Index row, Index col)
Index cols () const
Storagedata ()
const Storagedata () const
EIGEN_DEPRECATED void endFill ()
EIGEN_DEPRECATED Scalarfill (Index row, Index col)
EIGEN_DEPRECATED Scalarfillrand (Index row, Index col)
void finalize ()
Index innerNonZeros (Index j) const
Index innerSize () const
EIGEN_DONT_INLINE Scalarinsert (Index row, Index col)
ScalarinsertBack (Index row, Index col)
ScalarinsertBackByOuterInner (Index outer, Index inner)
ScalarinsertBackByOuterInnerUnordered (Index outer, Index inner)
Index nonZeros () const
SparseMatrixoperator= (const SparseMatrix &other)
template<typename Lhs , typename Rhs >
SparseMatrixoperator= (const SparseSparseProduct< Lhs, Rhs > &product)
template<typename OtherDerived >
SparseMatrixoperator= (const ReturnByValue< OtherDerived > &other)
template<typename OtherDerived >
SparseMatrixoperator= (const EigenBase< OtherDerived > &other)
template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrixoperator= (const SparseMatrixBase< OtherDerived > &other)
Index outerSize () 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)
Index rows () const
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 ()

Protected Types

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

Protected Attributes

CompressedStorage< Scalar, Indexm_data
Index m_innerSize
Indexm_outerIndex
Index m_outerSize

Friends

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

Detailed Description

template<typename _Scalar, int _Options, typename _Index>
class SparseMatrix< _Scalar, _Options, _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.

Definition at line 70 of file SparseMatrix.h.


Member Typedef Documentation

template<typename _Scalar, int _Options, typename _Index>
typedef MappedSparseMatrix<Scalar,Flags> SparseMatrix< _Scalar, _Options, _Index >::Map

Definition at line 82 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
typedef CompressedStorage<Scalar,Index> SparseMatrix< _Scalar, _Options, _Index >::Storage

Definition at line 84 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
typedef SparseMatrix<Scalar,(Flags&~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> SparseMatrix< _Scalar, _Options, _Index >::TransposedSparseMatrix [protected]

Definition at line 91 of file SparseMatrix.h.


Member Enumeration Documentation

template<typename _Scalar, int _Options, typename _Index>
anonymous enum
Enumerator:
Options 

Definition at line 85 of file SparseMatrix.h.


Constructor & Destructor Documentation

template<typename _Scalar, int _Options, typename _Index>
SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( ) [inline]

Default constructor yielding an empty 0 x 0 matrix

Definition at line 399 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( Index  rows,
Index  cols 
) [inline]

Constructs a rows x cols empty matrix

Definition at line 406 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived >
SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( const SparseMatrixBase< OtherDerived > &  other) [inline]

Constructs a sparse matrix from the sparse expression other

Definition at line 414 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( const SparseMatrix< _Scalar, _Options, _Index > &  other) [inline]

Copy constructor

Definition at line 421 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
SparseMatrix< _Scalar, _Options, _Index >::~SparseMatrix ( ) [inline]

Destructor

Definition at line 544 of file SparseMatrix.h.


Member Function Documentation

template<typename _Scalar, int _Options, typename _Index>
const Index* SparseMatrix< _Scalar, _Options, _Index >::_innerIndexPtr ( ) const [inline]

Definition at line 110 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index* SparseMatrix< _Scalar, _Options, _Index >::_innerIndexPtr ( ) [inline]

Definition at line 111 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
const Index* SparseMatrix< _Scalar, _Options, _Index >::_outerIndexPtr ( ) const [inline]

Definition at line 113 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index* SparseMatrix< _Scalar, _Options, _Index >::_outerIndexPtr ( ) [inline]

Definition at line 114 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
const Scalar* SparseMatrix< _Scalar, _Options, _Index >::_valuePtr ( ) const [inline]

Definition at line 107 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar* SparseMatrix< _Scalar, _Options, _Index >::_valuePtr ( ) [inline]

Definition at line 108 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar SparseMatrix< _Scalar, _Options, _Index >::coeff ( Index  row,
Index  col 
) const [inline]

Definition at line 119 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar& SparseMatrix< _Scalar, _Options, _Index >::coeffRef ( Index  row,
Index  col 
) [inline]

Definition at line 126 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::cols ( void  ) const [inline]
Returns:
the number of columns.
See also:
rows(), ColsAtCompileTime

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

Definition at line 101 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Storage& SparseMatrix< _Scalar, _Options, _Index >::data ( ) [inline]

Definition at line 116 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
const Storage& SparseMatrix< _Scalar, _Options, _Index >::data ( ) const [inline]

Definition at line 117 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
EIGEN_DEPRECATED void SparseMatrix< _Scalar, _Options, _Index >::endFill ( ) [inline]
Deprecated:
use finalize

Definition at line 605 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
EIGEN_DEPRECATED Scalar& SparseMatrix< _Scalar, _Options, _Index >::fill ( Index  row,
Index  col 
) [inline]
Deprecated:
use insert()

Definition at line 575 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
EIGEN_DEPRECATED Scalar& SparseMatrix< _Scalar, _Options, _Index >::fillrand ( Index  row,
Index  col 
) [inline]
Deprecated:
use insert() Like fill() but with random inner coordinates.

Definition at line 568 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::finalize ( ) [inline]

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

Definition at line 323 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::innerNonZeros ( Index  j) const [inline]

Definition at line 105 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::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 SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 103 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
EIGEN_DONT_INLINE Scalar& SparseMatrix< _Scalar, _Options, _Index >::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 214 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar& SparseMatrix< _Scalar, _Options, _Index >::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 171 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar& SparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInner ( Index  outer,
Index  inner 
) [inline]
See also:
insertBack, startVec

Definition at line 177 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Scalar& SparseMatrix< _Scalar, _Options, _Index >::insertBackByOuterInnerUnordered ( Index  outer,
Index  inner 
) [inline]
Warning:
use it only if you know what you are doing

Definition at line 188 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::nonZeros ( ) const [inline]
Returns:
the number of non zero coefficients

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

Definition at line 152 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
SparseMatrix& SparseMatrix< _Scalar, _Options, _Index >::operator= ( const SparseMatrix< _Scalar, _Options, _Index > &  other) [inline]

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

Definition at line 437 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename Lhs , typename Rhs >
SparseMatrix& SparseMatrix< _Scalar, _Options, _Index >::operator= ( const SparseSparseProduct< Lhs, Rhs > &  product) [inline]

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

Definition at line 455 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived >
SparseMatrix& SparseMatrix< _Scalar, _Options, _Index >::operator= ( const ReturnByValue< OtherDerived > &  other) [inline]

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

Definition at line 459 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived >
SparseMatrix& SparseMatrix< _Scalar, _Options, _Index >::operator= ( const EigenBase< OtherDerived > &  other) [inline]

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

Definition at line 463 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrix& SparseMatrix< _Scalar, _Options, _Index >::operator= ( const SparseMatrixBase< OtherDerived > &  other) [inline]

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

Definition at line 468 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::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 SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >.

Definition at line 104 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::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 339 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
template<typename KeepFunc >
void SparseMatrix< _Scalar, _Options, _Index >::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 352 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::reserve ( Index  reserveSize) [inline]

Preallocates reserveSize non zeros

Definition at line 155 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::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 377 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::resizeNonZeros ( Index  size) [inline]

Low level API Resize the nonzero vector to size

Definition at line 393 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::rows ( void  ) const [inline]
Returns:
the number of rows.
See also:
cols(), RowsAtCompileTime

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

Definition at line 100 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::setZero ( ) [inline]

Removes all non zeros

Definition at line 145 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
EIGEN_DEPRECATED void SparseMatrix< _Scalar, _Options, _Index >::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 559 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::startVec ( Index  outer) [inline]
See also:
insertBack, insertBackByOuterInner

Definition at line 197 of file SparseMatrix.h.

template<typename _Scalar , int _Options, typename _Index >
internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar SparseMatrix< _Scalar, _Options, _Index >::sum ( ) const

Overloaded for performance

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

Definition at line 42 of file SparseRedux.h.

template<typename _Scalar, int _Options, typename _Index>
void SparseMatrix< _Scalar, _Options, _Index >::swap ( SparseMatrix< _Scalar, _Options, _Index > &  other) [inline]

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

Definition at line 428 of file SparseMatrix.h.


Friends And Related Function Documentation

template<typename _Scalar, int _Options, typename _Index>
std::ostream& operator<< ( std::ostream &  s,
const SparseMatrix< _Scalar, _Options, _Index > &  m 
) [friend]

Definition at line 521 of file SparseMatrix.h.


Member Data Documentation

template<typename _Scalar, int _Options, typename _Index>
CompressedStorage<Scalar,Index> SparseMatrix< _Scalar, _Options, _Index >::m_data [protected]

Definition at line 96 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::m_innerSize [protected]

Definition at line 94 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index* SparseMatrix< _Scalar, _Options, _Index >::m_outerIndex [protected]

Definition at line 95 of file SparseMatrix.h.

template<typename _Scalar, int _Options, typename _Index>
Index SparseMatrix< _Scalar, _Options, _Index >::m_outerSize [protected]

Definition at line 93 of file SparseMatrix.h.


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


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:34:29