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
enum  
typedef internal::traits
< Derived >::Scalar 
Scalar
typedef
internal::packet_traits
< Scalar >::type 
PacketScalar
typedef internal::traits
< Derived >::StorageKind 
StorageKind
typedef internal::traits
< Derived >::Index 
Index
typedef SparseMatrixBase StorageBaseType
typedef EigenBase< Derived > Base
typedef internal::conditional
< NumTraits< Scalar >
::IsComplex, CwiseUnaryOp
< internal::scalar_conjugate_op
< Scalar >, Eigen::Transpose
< const Derived > >, Transpose
< const Derived > >::type 
AdjointReturnType
typedef SparseMatrix< Scalar,
Flags &RowMajorBit?RowMajor:ColMajor > 
PlainObject

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 ()
Storagedata ()
const Storagedata () const
Scalar coeff (Index row, Index col) const
ScalarcoeffRef (Index row, Index col)
void setZero ()
 Removes all non zeros.
Index nonZeros () const
void reserve (Index reserveSize)
 Preallocates reserveSize non zeros.
ScalarinsertBack (Index row, Index col)
ScalarinsertBackByOuterInner (Index outer, Index inner)
ScalarinsertBackByOuterInnerUnordered (Index outer, Index inner)
void startVec (Index outer)
EIGEN_DONT_INLINE Scalarinsert (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)
SparseMatrixoperator= (const SparseMatrix &other)
template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrixoperator= (const SparseMatrixBase< OtherDerived > &other)
 ~SparseMatrix ()
 Destructor.
Scalar sum () const
 Overloaded for performance.
EIGEN_DEPRECATED void startFill (Index reserveSize=1000)
EIGEN_DEPRECATED Scalarfillrand (Index row, Index col)
EIGEN_DEPRECATED Scalarfill (Index row, Index col)
EIGEN_DEPRECATED void endFill ()
const CwiseUnaryOp
< internal::scalar_opposite_op
< typename internal::traits
< Derived >::Scalar >, const
Derived > 
operator- () const
const ScalarMultipleReturnType operator* (const Scalar &scalar) const
const ScalarMultipleReturnType operator* (const RealScalar &scalar) const
const CwiseUnaryOp
< internal::scalar_multiple2_op
< Scalar, std::complex< Scalar >
>, const Derived > 
operator* (const std::complex< Scalar > &scalar) const
 Overloaded for efficient real matrix times complex scalar value.
const
SparseSparseProductReturnType
< Derived, OtherDerived >
::Type 
operator* (const SparseMatrixBase< OtherDerived > &other) const
const SparseDiagonalProduct
< Derived, OtherDerived > 
operator* (const DiagonalBase< OtherDerived > &other) const
const
SparseDenseProductReturnType
< Derived, OtherDerived >
::Type 
operator* (const MatrixBase< OtherDerived > &other) const
 sparse * dense (returns a dense object unless it is an outer product)
const CwiseUnaryOp
< internal::scalar_quotient1_op
< typename internal::traits
< Derived >::Scalar >, const
Derived > 
operator/ (const Scalar &scalar) const
internal::cast_return_type
< Derived, const CwiseUnaryOp
< internal::scalar_cast_op
< typename internal::traits
< Derived >::Scalar, NewType >
, const Derived > >::type 
cast () const
ConjugateReturnType conjugate () const
RealReturnType real () const
NonConstRealReturnType real ()
const ImagReturnType imag () const
NonConstImagReturnType imag ()
const CwiseUnaryOp
< CustomUnaryOp, const Derived > 
unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const
 Apply a unary operator coefficient-wise.
const CwiseUnaryView
< CustomViewOp, const Derived > 
unaryViewExpr (const CustomViewOp &func=CustomViewOp()) const
EIGEN_STRONG_INLINE const
CwiseBinaryOp< CustomBinaryOp,
const Derived, const
OtherDerived > 
binaryExpr (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other, const CustomBinaryOp &func=CustomBinaryOp()) const
EIGEN_STRONG_INLINE const
CwiseUnaryOp
< internal::scalar_abs_op
< Scalar >, const Derived > 
cwiseAbs () const
EIGEN_STRONG_INLINE const
CwiseUnaryOp
< internal::scalar_abs2_op
< Scalar >, const Derived > 
cwiseAbs2 () const
const CwiseUnaryOp
< internal::scalar_sqrt_op
< Scalar >, const Derived > 
cwiseSqrt () const
const CwiseUnaryOp
< internal::scalar_inverse_op
< Scalar >, const Derived > 
cwiseInverse () const
const CwiseUnaryOp
< std::binder1st
< std::equal_to< Scalar >
>, const Derived > 
cwiseEqual (const Scalar &s) const
const CwiseBinaryOp
< std::equal_to< Scalar >
, const Derived, const
OtherDerived > 
cwiseEqual (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE (Derived, OtherDerived) cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
const CwiseBinaryOp
< std::not_equal_to< Scalar >
, const Derived, const
OtherDerived > 
cwiseNotEqual (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
EIGEN_STRONG_INLINE const
CwiseBinaryOp
< internal::scalar_min_op
< Scalar >, const Derived,
const OtherDerived > 
cwiseMin (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
EIGEN_STRONG_INLINE const
CwiseBinaryOp
< internal::scalar_max_op
< Scalar >, const Derived,
const OtherDerived > 
cwiseMax (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
EIGEN_STRONG_INLINE const
CwiseBinaryOp
< internal::scalar_quotient_op
< Scalar >, const Derived,
const OtherDerived > 
cwiseQuotient (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
Index size () const
bool isVector () const
bool isRValue () const
Derived & markAsRValue ()
void assignGeneric (const OtherDerived &other)
void _experimentalNewProduct (const Lhs &lhs, const Rhs &rhs)
Derived & operator+= (const SparseMatrixBase< OtherDerived > &other)
Derived & operator-= (const SparseMatrixBase< OtherDerived > &other)
Derived & operator*= (const Scalar &other)
Derived & operator*= (const SparseMatrixBase< OtherDerived > &other)
Derived & operator/= (const Scalar &other)
EIGEN_STRONG_INLINE const
EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE 
cwiseProduct (const MatrixBase< OtherDerived > &other) const
const SparseTriangularView
< Derived, Mode > 
triangularView () const
const SparseSelfAdjointView
< Derived, UpLo > 
selfadjointView () const
SparseSelfAdjointView< Derived,
UpLo > 
selfadjointView ()
Scalar dot (const MatrixBase< OtherDerived > &other) const
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
RealScalar squaredNorm () const
RealScalar norm () const
Transpose< Derived > transpose ()
const Transpose< const Derived > transpose () const
const AdjointReturnType adjoint () const
SparseInnerVectorSet< Derived, 1 > row (Index i)
const SparseInnerVectorSet
< Derived, 1 > 
row (Index i) const
SparseInnerVectorSet< Derived, 1 > col (Index j)
const SparseInnerVectorSet
< Derived, 1 > 
col (Index j) const
SparseInnerVectorSet< Derived, 1 > innerVector (Index outer)
const SparseInnerVectorSet
< Derived, 1 > 
innerVector (Index outer) const
SparseInnerVectorSet< Derived,
Dynamic
subrows (Index start, Index size)
const SparseInnerVectorSet
< Derived, Dynamic
subrows (Index start, Index size) const
SparseInnerVectorSet< Derived,
Dynamic
subcols (Index start, Index size)
const SparseInnerVectorSet
< Derived, Dynamic
subcols (Index start, Index size) const
SparseInnerVectorSet< Derived,
Dynamic
innerVectors (Index outerStart, Index outerSize)
const SparseInnerVectorSet
< Derived, Dynamic
innerVectors (Index outerStart, Index outerSize) const
void evalTo (MatrixBase< DenseDerived > &dst) const
Matrix< Scalar,
RowsAtCompileTime,
ColsAtCompileTime > 
toDense () const
bool isApprox (const SparseMatrixBase< OtherDerived > &other, RealScalar prec=NumTraits< Scalar >::dummy_precision()) const
bool isApprox (const MatrixBase< OtherDerived > &other, RealScalar prec=NumTraits< Scalar >::dummy_precision()) const
const internal::eval< Derived >
::type 
eval () const

Protected Types

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

Protected Attributes

Index m_outerSize
Index m_innerSize
Indexm_outerIndex
CompressedStorage< Scalar, Indexm_data
bool m_isRValue

Friends

std::ostreamoperator<< (std::ostream &s, const SparseMatrix &m)
const ScalarMultipleReturnType operator* (const Scalar &scalar, const StorageBaseType &matrix)
const CwiseUnaryOp
< internal::scalar_multiple2_op
< Scalar, std::complex< Scalar >
>, const Derived > 
operator* (const std::complex< Scalar > &scalar, const StorageBaseType &matrix)
const SparseDiagonalProduct
< OtherDerived, Derived > 
operator* (const DiagonalBase< OtherDerived > &lhs, const SparseMatrixBase &rhs)
const
DenseSparseProductReturnType
< OtherDerived, Derived >
::Type 
operator* (const MatrixBase< OtherDerived > &lhs, const Derived &rhs)
 dense * sparse (return a dense object unless it is an outer product)
std::ostreamoperator<< (std::ostream &s, const SparseMatrixBase &m)

Member Typedef Documentation

Definition at line 124 of file Sparse.

typedef EigenBase<Derived> Eigen::SparseMatrixBase::Base [inherited]

Definition at line 50 of file Sparse.

typedef internal::traits<Derived>::Index Eigen::SparseMatrixBase::Index [inherited]

Definition at line 47 of file Sparse.

Definition at line 83 of file Sparse.

Definition at line 45 of file Sparse.

typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor> Eigen::SparseMatrixBase::PlainObject [inherited]

Definition at line 127 of file Sparse.

typedef internal::traits<Derived>::Scalar Eigen::SparseMatrixBase::Scalar [inherited]

Definition at line 44 of file Sparse.

Definition at line 85 of file Sparse.

Definition at line 49 of file Sparse.

typedef internal::traits<Derived>::StorageKind Eigen::SparseMatrixBase::StorageKind [inherited]

Definition at line 46 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 [inherited]

Definition at line 61 of file Sparse.

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

void Eigen::SparseMatrixBase::_experimentalNewProduct ( const Lhs &  lhs,
const Rhs &  rhs 
) [inline, inherited]
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.

const AdjointReturnType Eigen::SparseMatrixBase::adjoint ( ) const [inline, inherited]

Definition at line 430 of file Sparse.

void Eigen::SparseMatrixBase::assignGeneric ( const OtherDerived &  other) [inline, inherited]

Definition at line 211 of file Sparse.

EIGEN_STRONG_INLINE const CwiseBinaryOp<CustomBinaryOp, const Derived, const OtherDerived> Eigen::SparseMatrixBase::binaryExpr ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other,
const CustomBinaryOp &  func = CustomBinaryOp() 
) const [inline, inherited]
Returns:
an expression of the difference of *this and other
Note:
If you want to substract a given scalar from all coefficients, see Cwise::operator-().
See also:
class CwiseBinaryOp, operator-=()
Returns:
an expression of the sum of *this and other
Note:
If you want to add a given scalar to all coefficients, see Cwise::operator+().
See also:
class CwiseBinaryOp, operator+=()
Returns:
an expression of a custom coefficient-wise operator func of *this and other

The template parameter CustomBinaryOp is the type of the functor of the custom operator (see class CwiseBinaryOp for an example)

Here is an example illustrating the use of custom functors:

Output:

See also:
class CwiseBinaryOp, operator+(), operator-(), cwiseProduct()

Definition at line 58 of file Sparse.

internal::cast_return_type<Derived,const CwiseUnaryOp<internal::scalar_cast_op<typename internal::traits<Derived>::Scalar, NewType>, const Derived> >::type Eigen::SparseMatrixBase::cast ( ) const [inline, inherited]
Returns:
an expression of *this with the Scalar type casted to NewScalar.

The template parameter NewScalar is the type we are casting the scalars to.

See also:
class CwiseUnaryOp

Definition at line 108 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.

SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::col ( Index  j) [inherited]
Returns:
the i-th column of the matrix *this. For column-major matrix only.
const SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::col ( Index  j) const [inherited]
Returns:
the i-th column of the matrix *this. For column-major matrix only. (read-only version)
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.

ConjugateReturnType Eigen::SparseMatrixBase::conjugate ( ) const [inline, inherited]
Returns:
an expression of the complex conjugate of *this.
See also:
adjoint()

Definition at line 117 of file Sparse.

EIGEN_STRONG_INLINE const CwiseUnaryOp<internal::scalar_abs_op<Scalar>, const Derived> Eigen::SparseMatrixBase::cwiseAbs ( ) const [inline, inherited]
Returns:
an expression of the coefficient-wise absolute value of *this

Example:

Output:

See also:
cwiseAbs2()

Definition at line 37 of file Sparse.

EIGEN_STRONG_INLINE const CwiseUnaryOp<internal::scalar_abs2_op<Scalar>, const Derived> Eigen::SparseMatrixBase::cwiseAbs2 ( ) const [inline, inherited]
Returns:
an expression of the coefficient-wise squared absolute value of *this

Example:

Output:

See also:
cwiseAbs()

Definition at line 47 of file Sparse.

const CwiseBinaryOp<std::equal_to<Scalar>, const Derived, const OtherDerived> Eigen::SparseMatrixBase::cwiseEqual ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other) const [inline, inherited]
Returns:
an expression of the coefficient-wise == operator of *this and other
Warning:
this performs an exact comparison, which is generally a bad idea with floating-point types. In order to check for equality between two vectors or matrices with floating-point coefficients, it is generally a far better idea to use a fuzzy comparison as provided by isApprox() and isMuchSmallerThan().

Example:

Output:

See also:
cwiseNotEqual(), isApprox(), isMuchSmallerThan()

Definition at line 57 of file Sparse.

const CwiseUnaryOp<std::binder1st<std::equal_to<Scalar> >, const Derived> Eigen::SparseMatrixBase::cwiseEqual ( const Scalar s) const [inline, inherited]
Returns:
an expression of the coefficient-wise == operator of *this and a scalar s
Warning:
this performs an exact comparison, which is generally a bad idea with floating-point types. In order to check for equality between two vectors or matrices with floating-point coefficients, it is generally a far better idea to use a fuzzy comparison as provided by isApprox() and isMuchSmallerThan().
See also:
cwiseEqual(const MatrixBase<OtherDerived> &) const

Definition at line 79 of file Sparse.

const CwiseUnaryOp<internal::scalar_inverse_op<Scalar>, const Derived> Eigen::SparseMatrixBase::cwiseInverse ( ) const [inline, inherited]
Returns:
an expression of the coefficient-wise inverse of *this.

Example:

Output:

See also:
cwiseProduct()

Definition at line 67 of file Sparse.

EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_max_op<Scalar>, const Derived, const OtherDerived> Eigen::SparseMatrixBase::cwiseMax ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other) const [inline, inherited]
Returns:
an expression of the coefficient-wise max of *this and other

Example:

Output:

See also:
class CwiseBinaryOp, min()

Definition at line 104 of file Sparse.

EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_min_op<Scalar>, const Derived, const OtherDerived> Eigen::SparseMatrixBase::cwiseMin ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other) const [inline, inherited]
Returns:
an expression of the coefficient-wise min of *this and other

Example:

Output:

See also:
class CwiseBinaryOp, max()

Definition at line 90 of file Sparse.

const CwiseBinaryOp<std::not_equal_to<Scalar>, const Derived, const OtherDerived> Eigen::SparseMatrixBase::cwiseNotEqual ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other) const [inline, inherited]
Returns:
an expression of the coefficient-wise != operator of *this and other
Warning:
this performs an exact comparison, which is generally a bad idea with floating-point types. In order to check for equality between two vectors or matrices with floating-point coefficients, it is generally a far better idea to use a fuzzy comparison as provided by isApprox() and isMuchSmallerThan().

Example:

Output:

See also:
cwiseEqual(), isApprox(), isMuchSmallerThan()

Definition at line 76 of file Sparse.

EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE Eigen::SparseMatrixBase::cwiseProduct ( const MatrixBase< OtherDerived > &  other) const [inherited]
EIGEN_STRONG_INLINE const CwiseBinaryOp<internal::scalar_quotient_op<Scalar>, const Derived, const OtherDerived> Eigen::SparseMatrixBase::cwiseQuotient ( const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &  other) const [inline, inherited]
Returns:
an expression of the coefficient-wise quotient of *this and other

Example:

Output:

See also:
class CwiseBinaryOp, cwiseProduct(), cwiseInverse()

Definition at line 118 of file Sparse.

const CwiseUnaryOp<internal::scalar_sqrt_op<Scalar>, const Derived> Eigen::SparseMatrixBase::cwiseSqrt ( ) const [inline, inherited]
Returns:
an expression of the coefficient-wise square root of *this.

Example:

Output:

See also:
cwisePow(), cwiseSquare()

Definition at line 57 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.

Scalar Eigen::SparseMatrixBase::dot ( const MatrixBase< OtherDerived > &  other) const [inherited]
Scalar Eigen::SparseMatrixBase::dot ( const SparseMatrixBase< OtherDerived > &  other) const [inherited]
EIGEN_STRONG_INLINE const Eigen::SparseMatrixBase::EIGEN_CWISE_PRODUCT_RETURN_TYPE ( Derived  ,
OtherDerived   
) const [inline, inherited]
Returns:
an expression of the Schur product (coefficient wise product) of *this and other

Example:

Output:

See also:
class CwiseBinaryOp, cwiseAbs2

Definition at line 37 of file Sparse.

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

Definition at line 606 of file Sparse.

const internal::eval<Derived>::type Eigen::SparseMatrixBase::eval ( ) const [inline, inherited]
Returns:
the matrix or vector obtained by evaluating this expression.

Notice that in the case of a plain matrix or vector (not an expression) this function just returns a const reference, in order to avoid a useless copy.

Definition at line 577 of file Sparse.

void Eigen::SparseMatrixBase::evalTo ( MatrixBase< DenseDerived > &  dst) const [inline, inherited]

Definition at line 518 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.

const ImagReturnType Eigen::SparseMatrixBase::imag ( ) const [inline, inherited]
Returns:
an read-only expression of the imaginary part of *this.
See also:
real()

Definition at line 132 of file Sparse.

NonConstImagReturnType Eigen::SparseMatrixBase::imag ( ) [inline, inherited]
Returns:
a non const expression of the imaginary part of *this.
See also:
real()

Definition at line 188 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.

SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::innerVector ( Index  outer) [inherited]
Returns:
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major).
const SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::innerVector ( Index  outer) const [inherited]
Returns:
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major). Read-only.
SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::innerVectors ( Index  outerStart,
Index  outerSize 
) [inherited]
Returns:
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major).
const SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::innerVectors ( Index  outerStart,
Index  outerSize 
) const [inherited]
Returns:
the outer -th column (resp. row) of the matrix *this if *this is col-major (resp. row-major). Read-only.
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.

bool Eigen::SparseMatrixBase::isApprox ( const SparseMatrixBase< OtherDerived > &  other,
RealScalar  prec = NumTraits<Scalar>::dummy_precision() 
) const [inline, inherited]

Definition at line 532 of file Sparse.

bool Eigen::SparseMatrixBase::isApprox ( const MatrixBase< OtherDerived > &  other,
RealScalar  prec = NumTraits<Scalar>::dummy_precision() 
) const [inline, inherited]

Definition at line 537 of file Sparse.

bool Eigen::SparseMatrixBase::isRValue ( ) const [inline, inherited]

Definition at line 187 of file Sparse.

bool Eigen::SparseMatrixBase::isVector ( ) const [inline, inherited]
Returns:
true if either the number of rows or the number of columns is equal to 1. In other words, this function returns
 rows()==1 || cols()==1 
See also:
rows(), cols(), IsVectorAtCompileTime.

Definition at line 179 of file Sparse.

Derived& Eigen::SparseMatrixBase::markAsRValue ( ) [inline, inherited]

Definition at line 188 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.

RealScalar Eigen::SparseMatrixBase::norm ( ) const [inherited]
const ScalarMultipleReturnType Eigen::SparseMatrixBase::operator* ( const Scalar scalar) const [inline, inherited]
Returns:
an expression of *this scaled by the scalar factor scalar

Definition at line 65 of file Sparse.

const ScalarMultipleReturnType Eigen::SparseMatrixBase::operator* ( const RealScalar &  scalar) const [inherited]
const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived> Eigen::SparseMatrixBase::operator* ( const std::complex< Scalar > &  scalar) const [inline, inherited]

Overloaded for efficient real matrix times complex scalar value.

Definition at line 85 of file Sparse.

const SparseSparseProductReturnType<Derived,OtherDerived>::Type Eigen::SparseMatrixBase::operator* ( const SparseMatrixBase< OtherDerived > &  other) const [inherited]
const SparseDiagonalProduct<Derived,OtherDerived> Eigen::SparseMatrixBase::operator* ( const DiagonalBase< OtherDerived > &  other) const [inherited]
const SparseDenseProductReturnType<Derived,OtherDerived>::Type Eigen::SparseMatrixBase::operator* ( const MatrixBase< OtherDerived > &  other) const [inherited]

sparse * dense (returns a dense object unless it is an outer product)

Derived& Eigen::SparseMatrixBase::operator*= ( const Scalar other) [inherited]
Derived& Eigen::SparseMatrixBase::operator*= ( const SparseMatrixBase< OtherDerived > &  other) [inherited]
Derived& Eigen::SparseMatrixBase::operator+= ( const SparseMatrixBase< OtherDerived > &  other) [inherited]
const CwiseUnaryOp<internal::scalar_opposite_op<typename internal::traits<Derived>::Scalar>, const Derived> Eigen::SparseMatrixBase::operator- ( ) const [inline, inherited]
Returns:
an expression of the opposite of *this

Definition at line 60 of file Sparse.

Derived& Eigen::SparseMatrixBase::operator-= ( const SparseMatrixBase< OtherDerived > &  other) [inherited]
const CwiseUnaryOp<internal::scalar_quotient1_op<typename internal::traits<Derived>::Scalar>, const Derived> Eigen::SparseMatrixBase::operator/ ( const Scalar scalar) const [inline, inherited]
Returns:
an expression of *this divided by the scalar value scalar

Definition at line 77 of file Sparse.

Derived& Eigen::SparseMatrixBase::operator/= ( const Scalar other) [inherited]
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.

RealReturnType Eigen::SparseMatrixBase::real ( ) const [inline, inherited]
Returns:
a read-only expression of the real part of *this.
See also:
imag()

Definition at line 126 of file Sparse.

NonConstRealReturnType Eigen::SparseMatrixBase::real ( ) [inline, inherited]
Returns:
a non const expression of the real part of *this.
See also:
imag()

Definition at line 182 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.

SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::row ( Index  i) [inherited]
Returns:
the i-th row of the matrix *this. For row-major matrix only.
const SparseInnerVectorSet<Derived,1> Eigen::SparseMatrixBase::row ( Index  i) const [inherited]
Returns:
the i-th row of the matrix *this. For row-major matrix only. (read-only version)
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.

const SparseSelfAdjointView<Derived, UpLo> Eigen::SparseMatrixBase::selfadjointView ( ) const [inline, inherited]
SparseSelfAdjointView<Derived, UpLo> Eigen::SparseMatrixBase::selfadjointView ( ) [inline, inherited]
void Eigen::SparseMatrix::setZero ( ) [inline]

Removes all non zeros.

Definition at line 146 of file Sparse.

Index Eigen::SparseMatrixBase::size ( ) const [inline, inherited]
Returns:
the number of coefficients, which is rows()*cols().
See also:
rows(), cols(), SizeAtCompileTime.

Definition at line 171 of file Sparse.

RealScalar Eigen::SparseMatrixBase::squaredNorm ( ) const [inherited]
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.

SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::subcols ( Index  start,
Index  size 
) [inherited]
Returns:
the i-th column of the matrix *this. For column-major matrix only.
const SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::subcols ( Index  start,
Index  size 
) const [inherited]
Returns:
the i-th column of the matrix *this. For column-major matrix only. (read-only version)
SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::subrows ( Index  start,
Index  size 
) [inherited]
Returns:
the i-th row of the matrix *this. For row-major matrix only.
const SparseInnerVectorSet<Derived,Dynamic> Eigen::SparseMatrixBase::subrows ( Index  start,
Index  size 
) const [inherited]
Returns:
the i-th row of the matrix *this. For row-major matrix only. (read-only version)
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.

Matrix<Scalar,RowsAtCompileTime,ColsAtCompileTime> Eigen::SparseMatrixBase::toDense ( ) const [inline, inherited]

Definition at line 526 of file Sparse.

Transpose<Derived> Eigen::SparseMatrixBase::transpose ( ) [inline, inherited]

Definition at line 427 of file Sparse.

const Transpose<const Derived> Eigen::SparseMatrixBase::transpose ( ) const [inline, inherited]

Definition at line 428 of file Sparse.

const SparseTriangularView<Derived, Mode> Eigen::SparseMatrixBase::triangularView ( ) const [inline, inherited]
const CwiseUnaryOp<CustomUnaryOp, const Derived> Eigen::SparseMatrixBase::unaryExpr ( const CustomUnaryOp &  func = CustomUnaryOp()) const [inline, inherited]

Apply a unary operator coefficient-wise.

Parameters:
[in]funcFunctor implementing the unary operator
Template Parameters:
CustomUnaryOpType of func
Returns:
An expression of a custom coefficient-wise unary operator func of *this

The function ptr_fun() from the C++ standard library can be used to make functors out of normal functions.

Example:

Output:

Genuine functors allow for more possibilities, for instance it may contain a state.

Example:

Output:

See also:
class CwiseUnaryOp, class CwiseBinaryOp

Definition at line 155 of file Sparse.

const CwiseUnaryView<CustomViewOp, const Derived> Eigen::SparseMatrixBase::unaryViewExpr ( const CustomViewOp &  func = CustomViewOp()) const [inline, inherited]
Returns:
an expression of a custom coefficient-wise unary operator func of *this

The template parameter CustomUnaryOp is the type of the functor of the custom unary operator.

Example:

Output:

See also:
class CwiseUnaryOp, class CwiseBinaryOp

Definition at line 173 of file Sparse.


Friends And Related Function Documentation

const ScalarMultipleReturnType operator* ( const Scalar scalar,
const StorageBaseType matrix 
) [friend, inherited]

Definition at line 92 of file Sparse.

const CwiseUnaryOp<internal::scalar_multiple2_op<Scalar,std::complex<Scalar> >, const Derived> operator* ( const std::complex< Scalar > &  scalar,
const StorageBaseType matrix 
) [friend, inherited]

Definition at line 96 of file Sparse.

const SparseDiagonalProduct<OtherDerived,Derived> operator* ( const DiagonalBase< OtherDerived > &  lhs,
const SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > > &  rhs 
) [friend, inherited]

Definition at line 384 of file Sparse.

const DenseSparseProductReturnType<OtherDerived,Derived>::Type operator* ( const MatrixBase< OtherDerived > &  lhs,
const Derived &  rhs 
) [friend, inherited]

dense * sparse (return a dense object unless it is an outer product)

Definition at line 390 of file Sparse.

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

Definition at line 282 of file Sparse.

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.

bool Eigen::SparseMatrixBase::m_isRValue [protected, inherited]

Definition at line 703 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 Thu Oct 13 21:25:36 UTC 2011