DynamicSparseMatrix< _Scalar, _Flags > Class Template Reference

A sparse matrix class designed for matrix assembly purpose. More...

#include <DynamicSparseMatrix.h>

Inheritance diagram for DynamicSparseMatrix< _Scalar, _Flags >:
Inheritance graph
[legend]

List of all members.

Classes

class  InnerIterator

Public Types

typedef MappedSparseMatrix
< Scalar, Flags > 
Map

Public Member Functions

const std::vector
< CompressedStorage< Scalar > > & 
_data () const
std::vector< CompressedStorage
< Scalar > > & 
_data ()
Scalar coeff (int row, int col) const
ScalarcoeffRef (int row, int col)
int cols () const
 DynamicSparseMatrix (const DynamicSparseMatrix &other)
template<typename OtherDerived >
 DynamicSparseMatrix (const SparseMatrixBase< OtherDerived > &other)
 DynamicSparseMatrix (int rows, int cols)
 DynamicSparseMatrix ()
void endFill ()
Scalarfill (int row, int col)
Scalarfillrand (int row, int col)
int innerNonZeros (int j) const
int innerSize () const
int nonZeros () const
template<typename OtherDerived >
DynamicSparseMatrixoperator= (const SparseMatrixBase< OtherDerived > &other)
DynamicSparseMatrixoperator= (const DynamicSparseMatrix &other)
int outerSize () const
void prune (Scalar reference, RealScalar epsilon=precision< RealScalar >())
void resize (int rows, int cols)
void resizeAndKeepData (int rows, int cols)
int rows () const
void setZero ()
void startFill (int reserveSize=1000)
void swap (DynamicSparseMatrix &other)
 ~DynamicSparseMatrix ()

Protected Types

enum  { IsRowMajor = Base::IsRowMajor }
typedef DynamicSparseMatrix
< Scalar,(Flags &~RowMajorBit)|(IsRowMajor?RowMajorBit:0)> 
TransposedSparseMatrix

Protected Attributes

std::vector< CompressedStorage
< Scalar > > 
m_data
int m_innerSize

Detailed Description

template<typename _Scalar, int _Flags>
class DynamicSparseMatrix< _Scalar, _Flags >

A sparse matrix class designed for matrix assembly purpose.

Parameters:
_Scalar the scalar type, i.e. the type of the coefficients

Unlike SparseMatrix, this class provides a much higher degree of flexibility. In particular, it allows random read/write accesses in log(rho*outer_size) where rho is the probability that a coefficient is nonzero and outer_size is the number of columns if the matrix is column-major and the number of rows otherwise.

Internally, the data are stored as a std::vector of compressed vector. The performances of random writes might decrease as the number of nonzeros per inner-vector increase. In practice, we observed very good performance till about 100 nonzeros/vector, and the performance remains relatively good till 500 nonzeros/vectors.

See also:
SparseMatrix

Definition at line 61 of file DynamicSparseMatrix.h.


Member Typedef Documentation

template<typename _Scalar, int _Flags>
typedef MappedSparseMatrix<Scalar,Flags> DynamicSparseMatrix< _Scalar, _Flags >::Map

Definition at line 69 of file DynamicSparseMatrix.h.

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

Definition at line 74 of file DynamicSparseMatrix.h.


Member Enumeration Documentation

template<typename _Scalar, int _Flags>
anonymous enum [protected]
Enumerator:
IsRowMajor 

Definition at line 73 of file DynamicSparseMatrix.h.


Constructor & Destructor Documentation

template<typename _Scalar, int _Flags>
DynamicSparseMatrix< _Scalar, _Flags >::DynamicSparseMatrix (  )  [inline]

Definition at line 223 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
DynamicSparseMatrix< _Scalar, _Flags >::DynamicSparseMatrix ( int  rows,
int  cols 
) [inline]

Definition at line 229 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
template<typename OtherDerived >
DynamicSparseMatrix< _Scalar, _Flags >::DynamicSparseMatrix ( const SparseMatrixBase< OtherDerived > &  other  )  [inline]

Definition at line 236 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
DynamicSparseMatrix< _Scalar, _Flags >::DynamicSparseMatrix ( const DynamicSparseMatrix< _Scalar, _Flags > &  other  )  [inline]

Definition at line 242 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
DynamicSparseMatrix< _Scalar, _Flags >::~DynamicSparseMatrix (  )  [inline]

Destructor

Definition at line 277 of file DynamicSparseMatrix.h.


Member Function Documentation

template<typename _Scalar, int _Flags>
const std::vector<CompressedStorage<Scalar> >& DynamicSparseMatrix< _Scalar, _Flags >::_data (  )  const [inline]

Definition at line 88 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
std::vector<CompressedStorage<Scalar> >& DynamicSparseMatrix< _Scalar, _Flags >::_data (  )  [inline]

Definition at line 87 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
Scalar DynamicSparseMatrix< _Scalar, _Flags >::coeff ( int  row,
int  col 
) const [inline]
Returns:
the coefficient value at given position row, col This operation involes a log(rho*outer_size) binary search.

Definition at line 93 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
Scalar& DynamicSparseMatrix< _Scalar, _Flags >::coeffRef ( int  row,
int  col 
) [inline]
Returns:
a reference to the coefficient value at given position row, col This operation involes a log(rho*outer_size) binary search. If the coefficient does not exist yet, then a sorted insertion into a sequential buffer is performed.

Definition at line 104 of file DynamicSparseMatrix.h.

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

Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Flags > >.

Definition at line 82 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::endFill (  )  [inline]

Does nothing. Provided for compatibility with SparseMatrix.

Definition at line 185 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
Scalar& DynamicSparseMatrix< _Scalar, _Flags >::fill ( int  row,
int  col 
) [inline]

inserts a nonzero coefficient at given coordinates row, col and returns its reference assuming that: 1 - the coefficient does not exist yet 2 - this the coefficient with greater inner coordinate for the given outer coordinate. In other words, assuming *this is column-major, then there must not exists any nonzero coefficient of coordinates i x col such that i >= row. Otherwise the matrix is invalid.

See also:
fillrand(), coeffRef()

Definition at line 150 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
Scalar& DynamicSparseMatrix< _Scalar, _Flags >::fillrand ( int  row,
int  col 
) [inline]

Like fill() but with random inner coordinates. Compared to the generic coeffRef(), the unique limitation is that we assume the coefficient does not exist yet.

Definition at line 164 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
int DynamicSparseMatrix< _Scalar, _Flags >::innerNonZeros ( int  j  )  const [inline]

Definition at line 85 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
int DynamicSparseMatrix< _Scalar, _Flags >::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< DynamicSparseMatrix< _Scalar, _Flags > >.

Definition at line 83 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
int DynamicSparseMatrix< _Scalar, _Flags >::nonZeros (  )  const [inline]
Returns:
the number of non zero coefficients

Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Flags > >.

Definition at line 120 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
template<typename OtherDerived >
DynamicSparseMatrix& DynamicSparseMatrix< _Scalar, _Flags >::operator= ( const SparseMatrixBase< OtherDerived > &  other  )  [inline]
template<typename _Scalar, int _Flags>
DynamicSparseMatrix& DynamicSparseMatrix< _Scalar, _Flags >::operator= ( const DynamicSparseMatrix< _Scalar, _Flags > &  other  )  [inline]
template<typename _Scalar, int _Flags>
int DynamicSparseMatrix< _Scalar, _Flags >::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< DynamicSparseMatrix< _Scalar, _Flags > >.

Definition at line 84 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::prune ( Scalar  reference,
RealScalar  epsilon = precision<RealScalar>() 
) [inline]

Definition at line 187 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::resize ( int  rows,
int  cols 
) [inline]

Resize the matrix without preserving the data (the matrix is set to zero)

Definition at line 195 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::resizeAndKeepData ( int  rows,
int  cols 
) [inline]

Definition at line 206 of file DynamicSparseMatrix.h.

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

Reimplemented from SparseMatrixBase< DynamicSparseMatrix< _Scalar, _Flags > >.

Definition at line 81 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::setZero (  )  [inline]

Definition at line 113 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::startFill ( int  reserveSize = 1000  )  [inline]

Set the matrix to zero and reserve the memory for reserveSize nonzero coefficients.

Definition at line 129 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
void DynamicSparseMatrix< _Scalar, _Flags >::swap ( DynamicSparseMatrix< _Scalar, _Flags > &  other  )  [inline]

Definition at line 248 of file DynamicSparseMatrix.h.


Member Data Documentation

template<typename _Scalar, int _Flags>
std::vector<CompressedStorage<Scalar> > DynamicSparseMatrix< _Scalar, _Flags >::m_data [protected]

Definition at line 77 of file DynamicSparseMatrix.h.

template<typename _Scalar, int _Flags>
int DynamicSparseMatrix< _Scalar, _Flags >::m_innerSize [protected]

Definition at line 76 of file DynamicSparseMatrix.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


vcglib
Author(s): Christian Bersch
autogenerated on Fri Jan 11 09:22:01 2013