Public Types | Public Member Functions | Protected Types | Protected Attributes | List of all members
DynamicSparseMatrix< _Scalar, _Flags > Class Template Reference

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

Public Types

typedef MappedSparseMatrix
< Scalar, Flags > 
Map
 
- Public Types inherited from SparseMatrixBase< Derived >
enum  {
  RowsAtCompileTime,
  ColsAtCompileTime,
  SizeAtCompileTime,
  MaxRowsAtCompileTime,
  MaxColsAtCompileTime,
  MaxSizeAtCompileTime,
  IsVectorAtCompileTime,
  Flags,
  CoeffReadCost,
  IsRowMajor
}
 
typedef SparseTranspose
< typename ei_cleantype
< ConjugateReturnType >::type > 
AdjointReturnType
 
typedef ei_meta_if< NumTraits
< Scalar >::IsComplex, const
SparseCwiseUnaryOp
< ei_scalar_conjugate_op
< Scalar >, Derived >, const
Derived & >::ret 
ConjugateReturnType
 
typedef CwiseUnaryOp
< ei_scalar_imag_op< Scalar >
, Derived > 
ImagReturnType
 
typedef CwiseUnaryOp
< ei_scalar_real_op< Scalar >
, Derived > 
RealReturnType
 
typedef ei_traits< Derived >
::Scalar 
Scalar
 

Public Member Functions

std::vector< CompressedStorage
< Scalar > > & 
_data ()
 
const std::vector
< CompressedStorage< Scalar > > & 
_data () const
 
Scalar coeff (int row, int col) const
 
Scalar & coeffRef (int row, int col)
 
int cols () const
 
 DynamicSparseMatrix (int rows, int cols)
 
template<typename OtherDerived >
 DynamicSparseMatrix (const SparseMatrixBase< OtherDerived > &other)
 
 DynamicSparseMatrix (const DynamicSparseMatrix &other)
 
void endFill ()
 
Scalar & fill (int row, int col)
 
Scalar & fillrand (int row, int col)
 
int innerNonZeros (int j) const
 
int innerSize () const
 
int nonZeros () const
 
DynamicSparseMatrixoperator= (const DynamicSparseMatrix &other)
 
template<typename OtherDerived >
DynamicSparseMatrixoperator= (const SparseMatrixBase< OtherDerived > &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 ()
 
- Public Member Functions inherited from SparseMatrixBase< Derived >
const AdjointReturnType adjoint () const
 
template<typename OtherDerived >
void assignGeneric (const OtherDerived &other)
 
template<typename NewType >
const SparseCwiseUnaryOp
< ei_scalar_cast_op< typename
ei_traits< Derived >::Scalar,
NewType >, Derived > 
cast () const
 
SparseInnerVectorSet< Derived, 1 > col (int j)
 
const SparseInnerVectorSet
< Derived, 1 > 
col (int j) const
 
int cols () const
 
ConjugateReturnType conjugate () const
 
const SparseCwise< Derived > cwise () const
 
SparseCwise< Derived > cwise ()
 
template<typename OtherDerived >
ei_traits< Derived >::Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
const ei_eval< Derived >::type eval () const
 
const ImagReturnType imag () const
 
int innerSize () const
 
SparseInnerVectorSet< Derived, 1 > innerVector (int outer)
 
const SparseInnerVectorSet
< Derived, 1 > 
innerVector (int outer) const
 
SparseInnerVectorSet< Derived,
Dynamic > 
innerVectors (int outerStart, int outerSize)
 
const SparseInnerVectorSet
< Derived, Dynamic > 
innerVectors (int outerStart, int outerSize) const
 
template<typename OtherDerived >
bool isApprox (const SparseMatrixBase< OtherDerived > &other, RealScalar prec=precision< Scalar >()) const
 
template<typename OtherDerived >
bool isApprox (const MatrixBase< OtherDerived > &other, RealScalar prec=precision< Scalar >()) const
 
bool isRValue () const
 
bool isVector () const
 
Derived & markAsRValue ()
 
template<unsigned int Added>
const SparseFlagged< Derived,
Added, 0 > 
marked () const
 
int nonZeros () const
 
RealScalar norm () const
 
const SparseCwiseUnaryOp
< ei_scalar_multiple_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator* (const Scalar &scalar) const
 
template<typename OtherDerived >
const SparseProductReturnType
< Derived, OtherDerived >
::Type 
operator* (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const SparseProductReturnType
< Derived, OtherDerived >
::Type 
operator* (const MatrixBase< OtherDerived > &other) const
 
Derived & operator*= (const Scalar &other)
 
template<typename OtherDerived >
Derived & operator*= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived >
const SparseCwiseBinaryOp
< ei_scalar_sum_op< typename
ei_traits< Derived >::Scalar >
, Derived, OtherDerived > 
operator+ (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Derived & operator+= (const SparseMatrixBase< OtherDerived > &other)
 
const SparseCwiseUnaryOp
< ei_scalar_opposite_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator- () const
 
template<typename OtherDerived >
const SparseCwiseBinaryOp
< ei_scalar_difference_op
< typename ei_traits< Derived >
::Scalar >, Derived,
OtherDerived > 
operator- (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Derived & operator-= (const SparseMatrixBase< OtherDerived > &other)
 
const SparseCwiseUnaryOp
< ei_scalar_quotient1_op
< typename ei_traits< Derived >
::Scalar >, Derived > 
operator/ (const Scalar &scalar) const
 
Derived & operator/= (const Scalar &other)
 
Derived & operator= (const Derived &other)
 
template<typename OtherDerived >
Derived & operator= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename Lhs , typename Rhs >
Derived & operator= (const SparseProduct< Lhs, Rhs, SparseTimeSparseProduct > &product)
 
int outerSize () const
 
const RealReturnType real () const
 
SparseInnerVectorSet< Derived, 1 > row (int i)
 
const SparseInnerVectorSet
< Derived, 1 > 
row (int i) const
 
int rows () const
 
int size () const
 
template<typename OtherDerived >
ei_plain_matrix_type_column_major
< OtherDerived >::type 
solveTriangular (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
void solveTriangularInPlace (MatrixBase< OtherDerived > &other) const
 
RealScalar squaredNorm () const
 
SparseInnerVectorSet< Derived,
Dynamic > 
subcols (int start, int size)
 
const SparseInnerVectorSet
< Derived, Dynamic > 
subcols (int start, int size) const
 
SparseInnerVectorSet< Derived,
Dynamic > 
subrows (int start, int size)
 
const SparseInnerVectorSet
< Derived, Dynamic > 
subrows (int start, int size) const
 
Scalar sum () const
 
Matrix< Scalar,
RowsAtCompileTime,
ColsAtCompileTime > 
toDense () const
 
SparseTranspose< Derived > transpose ()
 
const SparseTranspose< Derived > transpose () const
 
template<typename CustomUnaryOp >
const SparseCwiseUnaryOp
< CustomUnaryOp, Derived > 
unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const
 

Protected Types

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

Protected Attributes

std::vector< CompressedStorage
< Scalar > > 
m_data
 
int m_innerSize
 
- Protected Attributes inherited from SparseMatrixBase< Derived >
bool m_isRValue
 

Detailed Description

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

A sparse matrix class designed for matrix assembly purpose.

Parameters
_Scalarthe 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

Constructor & Destructor Documentation

~DynamicSparseMatrix ( )
inline

Destructor

Member Function Documentation

Scalar 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.
Scalar& 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.
void endFill ( )
inline

Does nothing. Provided for compatibility with SparseMatrix.

Scalar& 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()
Scalar& 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.

int nonZeros ( ) const
inline
Returns
the number of non zero coefficients
void resize ( int  rows,
int  cols 
)
inline

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

void startFill ( int  reserveSize = 1000)
inline

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


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