Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends
Eigen::SparseMatrix< _Scalar, _Options, _Index > Class Template Reference

A versatible sparse matrix representation. More...

#include <SparseMatrix.h>

+ Inheritance diagram for Eigen::SparseMatrix< _Scalar, _Options, _Index >:
+ Collaboration diagram for Eigen::SparseMatrix< _Scalar, _Options, _Index >:

Classes

class  InnerIterator
 
class  ReverseInnerIterator
 
class  SingletonVector
 

Public Types

enum  { Options = _Options }
 
typedef MappedSparseMatrix< Scalar, FlagsMap
 
typedef internal::CompressedStorage< Scalar, Index > Storage
 
- Public Types inherited from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >
enum  
 
typedef internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar Scalar
 
typedef internal::packet_traits< Scalar >::type PacketScalar
 
typedef internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::StorageKind StorageKind
 
typedef internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Index Index
 
typedef internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
 
typedef SparseMatrixBase StorageBaseType
 
typedef EigenBase< SparseMatrix< _Scalar, _Options, _Index > > Base
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const SparseMatrix< _Scalar, _Options, _Index > > >, Transpose< const SparseMatrix< _Scalar, _Options, _Index > > >::type AdjointReturnType
 
typedef SparseMatrix< Scalar, Flags &RowMajorBit?RowMajor:ColMajor, Index > PlainObject
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::conditional< _HasDirectAccess, const Scalar &, Scalar >::type CoeffReturnType
 
typedef CwiseNullaryOp< internal::scalar_constant_op< Scalar >, Matrix< Scalar, Dynamic, Dynamic > > ConstantReturnType
 
typedef Matrix< Scalar, EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime), EIGEN_SIZE_MAX(RowsAtCompileTime, ColsAtCompileTime)> SquareMatrixType
 
typedef CwiseUnaryOp< internal::scalar_multiple_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > ScalarMultipleReturnType
 
typedef CwiseUnaryOp< internal::scalar_quotient1_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > ScalarQuotient1ReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > >, const SparseMatrix< _Scalar, _Options, _Index > & >::type ConjugateReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, const CwiseUnaryOp< internal::scalar_real_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > >, const SparseMatrix< _Scalar, _Options, _Index > & >::type RealReturnType
 
typedef internal::conditional< NumTraits< Scalar >::IsComplex, CwiseUnaryView< internal::scalar_real_ref_op< Scalar >, SparseMatrix< _Scalar, _Options, _Index > >, SparseMatrix< _Scalar, _Options, _Index > & >::type NonConstRealReturnType
 
typedef CwiseUnaryOp< internal::scalar_imag_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > ImagReturnType
 
typedef CwiseUnaryView< internal::scalar_imag_ref_op< Scalar >, SparseMatrix< _Scalar, _Options, _Index > > NonConstImagReturnType
 
typedef Block< SparseMatrix< _Scalar, _Options, _Index >, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::RowsAtCompileTime, 1,!IsRowMajor > ColXpr
 
typedef const Block< const SparseMatrix< _Scalar, _Options, _Index >, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::RowsAtCompileTime, 1,!IsRowMajor > ConstColXpr
 
typedef Block< SparseMatrix< _Scalar, _Options, _Index >, 1, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::ColsAtCompileTime, IsRowMajor > RowXpr
 
typedef const Block< const SparseMatrix< _Scalar, _Options, _Index >, 1, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::ColsAtCompileTime, IsRowMajor > ConstRowXpr
 
typedef Block< SparseMatrix< _Scalar, _Options, _Index >, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::RowsAtCompileTime, Dynamic,!IsRowMajor > ColsBlockXpr
 
typedef const Block< const SparseMatrix< _Scalar, _Options, _Index >, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::RowsAtCompileTime, Dynamic,!IsRowMajor > ConstColsBlockXpr
 
typedef Block< SparseMatrix< _Scalar, _Options, _Index >, Dynamic, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::ColsAtCompileTime, IsRowMajor > RowsBlockXpr
 
typedef const Block< const SparseMatrix< _Scalar, _Options, _Index >, Dynamic, internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::ColsAtCompileTime, IsRowMajor > ConstRowsBlockXpr
 
typedef VectorBlock< SparseMatrix< _Scalar, _Options, _Index > > SegmentReturnType
 
typedef const VectorBlock< const SparseMatrix< _Scalar, _Options, _Index > > ConstSegmentReturnType
 
typedef Block< SparseMatrix< _Scalar, _Options, _Index >, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > InnerVectorReturnType
 
typedef Block< const SparseMatrix< _Scalar, _Options, _Index >, IsRowMajor?1:Dynamic, IsRowMajor?Dynamic:1, true > ConstInnerVectorReturnType
 
- Public Types inherited from Eigen::EigenBase< Derived >
typedef internal::traits< Derived >::StorageKind StorageKind
 
typedef internal::traits< Derived >::Index Index
 

Public Member Functions

bool isCompressed () const
 
Index rows () const
 
Index cols () const
 
Index innerSize () const
 
Index outerSize () const
 
const Scalar * valuePtr () const
 
Scalar * valuePtr ()
 
const Index * innerIndexPtr () const
 
Index * innerIndexPtr ()
 
const Index * outerIndexPtr () const
 
Index * outerIndexPtr ()
 
const Index * innerNonZeroPtr () const
 
Index * innerNonZeroPtr ()
 
Storagedata ()
 
const Storagedata () const
 
Scalar coeff (Index row, Index col) const
 
Scalar & coeffRef (Index row, Index col)
 
Scalar & insert (Index row, Index col)
 
void setZero ()
 
Index nonZeros () const
 
void reserve (Index reserveSize)
 
template<class SizesType >
void reserve (const SizesType &reserveSizes, const typename SizesType::value_type &enableif=typename SizesType::value_type())
 
template<class SizesType >
void reserve (const SizesType &reserveSizes, const typename SizesType::Scalar &enableif=typename SizesType::Scalar())
 
Scalar & insertBack (Index row, Index col)
 
Scalar & insertBackByOuterInner (Index outer, Index inner)
 
Scalar & insertBackByOuterInnerUnordered (Index outer, Index inner)
 
void startVec (Index outer)
 
void finalize ()
 
template<typename InputIterators >
void setFromTriplets (const InputIterators &begin, const InputIterators &end)
 
void sumupDuplicates ()
 
Scalar & insertByOuterInner (Index j, Index i)
 
void makeCompressed ()
 
void uncompress ()
 
void prune (const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
 
template<typename KeepFunc >
void prune (const KeepFunc &keep=KeepFunc())
 
void conservativeResize (Index rows, Index cols)
 
void resize (Index rows, Index cols)
 
void resizeNonZeros (Index size)
 
const Diagonal< const SparseMatrixdiagonal () const
 
 SparseMatrix ()
 
 SparseMatrix (Index rows, Index cols)
 
template<typename OtherDerived >
 SparseMatrix (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived , unsigned int UpLo>
 SparseMatrix (const SparseSelfAdjointView< OtherDerived, UpLo > &other)
 
 SparseMatrix (const SparseMatrix &other)
 
template<typename OtherDerived >
 SparseMatrix (const ReturnByValue< OtherDerived > &other)
 Copy constructor with in-place evaluation.
 
void swap (SparseMatrix &other)
 
void setIdentity ()
 
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)
 
 ~SparseMatrix ()
 
Scalar sum () const
 
EIGEN_STRONG_INLINE Scalar & insertBackUncompressed (Index row, Index col)
 
template<typename OtherDerived >
EIGEN_DONT_INLINE SparseMatrix< Scalar, _Options, _Index > & operator= (const SparseMatrixBase< OtherDerived > &other)
 
- Public Member Functions inherited from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >
SparseMatrix< _Scalar, _Options, _Index > & operator= (const EigenBase< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator= (const ReturnByValue< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator= (const SparseMatrixBase< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator= (const SparseMatrix< _Scalar, _Options, _Index > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator= (const SparseSparseProduct< Lhs, Rhs > &product)
 
const SparseMatrix< _Scalar, _Options, _Index > & derived () const
 
SparseMatrix< _Scalar, _Options, _Index > & derived ()
 
SparseMatrix< _Scalar, _Options, _Index > & const_cast_derived () const
 
const CwiseUnaryOp< internal::scalar_opposite_op< typename internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > operator- () const
 
const ScalarMultipleReturnType operator* (const Scalar &scalar) const
 
const CwiseUnaryOp< internal::scalar_multiple2_op< Scalar, std::complex< Scalar > >, const SparseMatrix< _Scalar, _Options, _Index > > operator* (const std::complex< Scalar > &scalar) const
 
const SparseSparseProductReturnType< SparseMatrix< _Scalar, _Options, _Index >, OtherDerived >::Type operator* (const SparseMatrixBase< OtherDerived > &other) const
 
const SparseDiagonalProduct< SparseMatrix< _Scalar, _Options, _Index >, OtherDerived > operator* (const DiagonalBase< OtherDerived > &other) const
 
const SparseDenseProductReturnType< SparseMatrix< _Scalar, _Options, _Index >, OtherDerived >::Type operator* (const MatrixBase< OtherDerived > &other) const
 
const CwiseUnaryOp< internal::scalar_quotient1_op< typename internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > operator/ (const Scalar &scalar) const
 
internal::cast_return_type< SparseMatrix< _Scalar, _Options, _Index >, const CwiseUnaryOp< internal::scalar_cast_op< typename internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar, NewType >, const SparseMatrix< _Scalar, _Options, _Index > > >::type cast () const
 
ConjugateReturnType conjugate () const
 
RealReturnType real () const
 
NonConstRealReturnType real ()
 
const ImagReturnType imag () const
 
NonConstImagReturnType imag ()
 
const CwiseUnaryOp< CustomUnaryOp, const SparseMatrix< _Scalar, _Options, _Index > > unaryExpr (const CustomUnaryOp &func=CustomUnaryOp()) const
 Apply a unary operator coefficient-wise. More...
 
const CwiseUnaryView< CustomViewOp, const SparseMatrix< _Scalar, _Options, _Index > > unaryViewExpr (const CustomViewOp &func=CustomViewOp()) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< CustomBinaryOp, const SparseMatrix< _Scalar, _Options, _Index >, 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 SparseMatrix< _Scalar, _Options, _Index > > cwiseAbs () const
 
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs2_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > cwiseAbs2 () const
 
const CwiseUnaryOp< internal::scalar_sqrt_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > cwiseSqrt () const
 
const CwiseUnaryOp< internal::scalar_inverse_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index > > cwiseInverse () const
 
const CwiseUnaryOp< std::binder1st< std::equal_to< Scalar > >, const SparseMatrix< _Scalar, _Options, _Index > > cwiseEqual (const Scalar &s) const
 
const CwiseBinaryOp< std::equal_to< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const OtherDerived > cwiseEqual (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
EIGEN_STRONG_INLINE const EIGEN_CWISE_PRODUCT_RETURN_TYPE (SparseMatrix< _Scalar, _Options, _Index >, OtherDerived) cwiseProduct(const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
const CwiseBinaryOp< std::not_equal_to< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const OtherDerived > cwiseNotEqual (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_min_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const OtherDerived > cwiseMin (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_min_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const ConstantReturnTypecwiseMin (const Scalar &other) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_max_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const OtherDerived > cwiseMax (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_max_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const ConstantReturnTypecwiseMax (const Scalar &other) const
 
EIGEN_STRONG_INLINE const CwiseBinaryOp< internal::scalar_quotient_op< Scalar >, const SparseMatrix< _Scalar, _Options, _Index >, const OtherDerived > cwiseQuotient (const EIGEN_CURRENT_STORAGE_BASE_CLASS< OtherDerived > &other) const
 
Block< SparseMatrix< _Scalar, _Options, _Index > > block (Index startRow, Index startCol, Index blockRows, Index blockCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index > > block (Index startRow, Index startCol, Index blockRows, Index blockCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, BlockRows, BlockCols > block (Index startRow, Index startCol)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, BlockRows, BlockCols > block (Index startRow, Index startCol) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, BlockRows, BlockCols > block (Index startRow, Index startCol, Index blockRows, Index blockCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, BlockRows, BlockCols > block (Index startRow, Index startCol, Index blockRows, Index blockCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index > > topRightCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index > > topRightCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topRightCorner ()
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topRightCorner () const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topRightCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topRightCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index > > topLeftCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index > > topLeftCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topLeftCorner ()
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topLeftCorner () const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topLeftCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > topLeftCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index > > bottomRightCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index > > bottomRightCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomRightCorner ()
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomRightCorner () const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomRightCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomRightCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index > > bottomLeftCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index > > bottomLeftCorner (Index cRows, Index cCols) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomLeftCorner ()
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomLeftCorner () const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomLeftCorner (Index cRows, Index cCols)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, CRows, CCols > bottomLeftCorner (Index cRows, Index cCols) const
 
RowsBlockXpr topRows (Index n)
 
ConstRowsBlockXpr topRows (Index n) const
 
NRowsBlockXpr< N >::Type topRows ()
 
ConstNRowsBlockXpr< N >::Type topRows () const
 
RowsBlockXpr bottomRows (Index n)
 
ConstRowsBlockXpr bottomRows (Index n) const
 
NRowsBlockXpr< N >::Type bottomRows ()
 
ConstNRowsBlockXpr< N >::Type bottomRows () const
 
RowsBlockXpr middleRows (Index startRow, Index numRows)
 
ConstRowsBlockXpr middleRows (Index startRow, Index numRows) const
 
NRowsBlockXpr< N >::Type middleRows (Index startRow)
 
ConstNRowsBlockXpr< N >::Type middleRows (Index startRow) const
 
ColsBlockXpr leftCols (Index n)
 
ConstColsBlockXpr leftCols (Index n) const
 
NColsBlockXpr< N >::Type leftCols ()
 
ConstNColsBlockXpr< N >::Type leftCols () const
 
ColsBlockXpr rightCols (Index n)
 
ConstColsBlockXpr rightCols (Index n) const
 
NColsBlockXpr< N >::Type rightCols ()
 
ConstNColsBlockXpr< N >::Type rightCols () const
 
ColsBlockXpr middleCols (Index startCol, Index numCols)
 
ConstColsBlockXpr middleCols (Index startCol, Index numCols) const
 
NColsBlockXpr< N >::Type middleCols (Index startCol)
 
ConstNColsBlockXpr< N >::Type middleCols (Index startCol) const
 
ColXpr col (Index i)
 
ConstColXpr col (Index i) const
 
RowXpr row (Index i)
 
ConstRowXpr row (Index i) const
 
SegmentReturnType segment (Index start, Index vecSize)
 
ConstSegmentReturnType segment (Index start, Index vecSize) const
 
FixedSegmentReturnType< Size >::Type segment (Index start)
 
ConstFixedSegmentReturnType< Size >::Type segment (Index start) const
 
SegmentReturnType head (Index vecSize)
 
ConstSegmentReturnType head (Index vecSize) const
 
FixedSegmentReturnType< Size >::Type head ()
 
ConstFixedSegmentReturnType< Size >::Type head () const
 
SegmentReturnType tail (Index vecSize)
 
ConstSegmentReturnType tail (Index vecSize) const
 
FixedSegmentReturnType< Size >::Type tail ()
 
ConstFixedSegmentReturnType< Size >::Type tail () const
 
Index rows () const
 
Index cols () const
 
Index size () const
 
Index nonZeros () const
 
bool isVector () const
 
Index outerSize () const
 
Index innerSize () const
 
bool isRValue () const
 
SparseMatrix< _Scalar, _Options, _Index > & markAsRValue ()
 
SparseMatrix< _Scalar, _Options, _Index > & operator+= (const SparseMatrixBase< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator-= (const SparseMatrixBase< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator*= (const Scalar &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator*= (const SparseMatrixBase< OtherDerived > &other)
 
SparseMatrix< _Scalar, _Options, _Index > & operator/= (const Scalar &other)
 
EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
SparseSymmetricPermutationProduct< SparseMatrix< _Scalar, _Options, _Index >, Upper|Lower > twistedBy (const PermutationMatrix< Dynamic, Dynamic, Index > &perm) const
 
const SparseTriangularView< SparseMatrix< _Scalar, _Options, _Index >, Mode > triangularView () const
 
const SparseSelfAdjointView< SparseMatrix< _Scalar, _Options, _Index >, UpLo > selfadjointView () const
 
SparseSelfAdjointView< SparseMatrix< _Scalar, _Options, _Index >, UpLo > selfadjointView ()
 
Scalar dot (const MatrixBase< OtherDerived > &other) const
 
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
RealScalar squaredNorm () const
 
RealScalar norm () const
 
RealScalar blueNorm () const
 
Transpose< SparseMatrix< _Scalar, _Options, _Index > > transpose ()
 
const Transpose< const SparseMatrix< _Scalar, _Options, _Index > > transpose () const
 
const AdjointReturnType adjoint () const
 
InnerVectorReturnType innerVector (Index outer)
 
const ConstInnerVectorReturnType innerVector (Index outer) const
 
Block< SparseMatrix< _Scalar, _Options, _Index >, Dynamic, Dynamic, true > innerVectors (Index outerStart, Index outerSize)
 
const Block< const SparseMatrix< _Scalar, _Options, _Index >, Dynamic, Dynamic, true > innerVectors (Index outerStart, Index outerSize) const
 
void evalTo (MatrixBase< DenseDerived > &dst) const
 
Matrix< Scalar, RowsAtCompileTime, ColsAtCompileTimetoDense () const
 
bool isApprox (const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isApprox (const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
const internal::eval< SparseMatrix< _Scalar, _Options, _Index > >::type eval () const
 
Scalar sum () const
 
- Public Member Functions inherited from Eigen::EigenBase< Derived >
Derived & derived ()
 
const Derived & derived () const
 
Derived & const_cast_derived () const
 
const Derived & const_derived () const
 
Index rows () const
 
Index cols () const
 
Index size () const
 
template<typename Dest >
void evalTo (Dest &dst) const
 
template<typename Dest >
void addTo (Dest &dst) const
 
template<typename Dest >
void subTo (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheRight (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheLeft (Dest &dst) const
 

Protected Types

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

Protected Member Functions

Eigen::Map< Matrix< Index, Dynamic, 1 > > innerNonZeros ()
 
const Eigen::Map< const Matrix< Index, Dynamic, 1 > > innerNonZeros () const
 
template<class SizesType >
void reserveInnerVectors (const SizesType &reserveSizes)
 
template<typename Other >
void initAssignment (const Other &other)
 
EIGEN_DONT_INLINE Scalar & insertCompressed (Index row, Index col)
 
EIGEN_DONT_INLINE Scalar & insertUncompressed (Index row, Index col)
 
- Protected Member Functions inherited from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >
SparseMatrix< _Scalar, _Options, _Index > & assign (const OtherDerived &other)
 
void assignGeneric (const OtherDerived &other)
 

Protected Attributes

Index m_outerSize
 
Index m_innerSize
 
Index * m_outerIndex
 
Index * m_innerNonZeros
 
Storage m_data
 
- Protected Attributes inherited from Eigen::SparseMatrixBase< SparseMatrix< _Scalar, _Options, _Index > >
bool m_isRValue
 

Friends

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

Detailed Description

template<typename _Scalar, int _Options, typename _Index>
class Eigen::SparseMatrix< _Scalar, _Options, _Index >

A versatible sparse matrix representation.

This class implements a more versatile variants of the common compressed row/column storage format. Each colmun's (resp. row) non zeros are stored as a pair of value with associated row (resp. colmiun) index. All the non zeros are stored in a single large buffer. Unlike the compressed format, there might be extra space inbetween the nonzeros of two successive colmuns (resp. rows) such that insertion of new non-zero can be done with limited memory reallocation and copies.

A call to the function makeCompressed() turns the matrix into the standard compressed format compatible with many library.

More details on this storage sceheme are given in the manual pages.

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 ColMajor or RowMajor. The default is 0 which means column-major.
_Indexthe type of the indices. It has to be a signed type (e.g., short, int, std::ptrdiff_t). Default is int.

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.

Definition at line 85 of file SparseMatrix.h.

Constructor & Destructor Documentation

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

Default constructor yielding an empty 0 x 0 matrix

Definition at line 629 of file SparseMatrix.h.

630  : m_outerSize(-1), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
631  {
632  check_template_parameters();
633  resize(0, 0);
634  }
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:596
template<typename _Scalar, int _Options, typename _Index>
Eigen::SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( Index  rows,
Index  cols 
)
inline

Constructs a rows x cols empty matrix

Definition at line 637 of file SparseMatrix.h.

638  : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
639  {
640  check_template_parameters();
641  resize(rows, cols);
642  }
Index cols() const
Definition: SparseMatrix.h:121
Index rows() const
Definition: SparseMatrix.h:119
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:596
template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived >
Eigen::SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( const SparseMatrixBase< OtherDerived > &  other)
inline

Constructs a sparse matrix from the sparse expression other

Definition at line 646 of file SparseMatrix.h.

647  : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
648  {
649  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
650  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
651  check_template_parameters();
652  *this = other.derived();
653  }
template<typename _Scalar, int _Options, typename _Index>
template<typename OtherDerived , unsigned int UpLo>
Eigen::SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( const SparseSelfAdjointView< OtherDerived, UpLo > &  other)
inline

Constructs a sparse matrix from the sparse selfadjoint view other

Definition at line 657 of file SparseMatrix.h.

658  : m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
659  {
660  check_template_parameters();
661  *this = other;
662  }
template<typename _Scalar, int _Options, typename _Index>
Eigen::SparseMatrix< _Scalar, _Options, _Index >::SparseMatrix ( const SparseMatrix< _Scalar, _Options, _Index > &  other)
inline

Copy constructor (it performs a deep copy)

Definition at line 665 of file SparseMatrix.h.

666  : Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0), m_innerNonZeros(0)
667  {
668  check_template_parameters();
669  *this = other.derived();
670  }
template<typename _Scalar, int _Options, typename _Index>
Eigen::SparseMatrix< _Scalar, _Options, _Index >::~SparseMatrix ( )
inline

Destructor

Definition at line 783 of file SparseMatrix.h.

784  {
785  std::free(m_outerIndex);
786  std::free(m_innerNonZeros);
787  }

Member Function Documentation

template<typename _Scalar, int _Options, typename _Index>
Scalar Eigen::SparseMatrix< _Scalar, _Options, _Index >::coeff ( Index  row,
Index  col 
) const
inline
Returns
the value of the matrix at position i, j This function returns Scalar(0) if the element is an explicit zero

Definition at line 171 of file SparseMatrix.h.

172  {
173  eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());
174 
175  const Index outer = IsRowMajor ? row : col;
176  const Index inner = IsRowMajor ? col : row;
177  Index end = m_innerNonZeros ? m_outerIndex[outer] + m_innerNonZeros[outer] : m_outerIndex[outer+1];
178  return m_data.atInRange(m_outerIndex[outer], end, inner);
179  }
Index cols() const
Definition: SparseMatrix.h:121
Index rows() const
Definition: SparseMatrix.h:119
Scalar atInRange(size_t start, size_t end, Index key, const Scalar &defaultValue=Scalar(0)) const
template<typename _Scalar, int _Options, typename _Index>
Scalar& Eigen::SparseMatrix< _Scalar, _Options, _Index >::coeffRef ( Index  row,
Index  col 
)
inline
Returns
a non-const reference to the value of the matrix at position i, j

If the element does not exist then it is inserted via the insert(Index,Index) function which itself turns the matrix into a non compressed form if that was not the case.

This is a O(log(nnz_j)) operation (binary search) plus the cost of insert(Index,Index) function if the element does not already exist.

Definition at line 189 of file SparseMatrix.h.

190  {
191  eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());
192 
193  const Index outer = IsRowMajor ? row : col;
194  const Index inner = IsRowMajor ? col : row;
195 
196  Index start = m_outerIndex[outer];
197  Index end = m_innerNonZeros ? m_outerIndex[outer] + m_innerNonZeros[outer] : m_outerIndex[outer+1];
198  eigen_assert(end>=start && "you probably called coeffRef on a non finalized matrix");
199  if(end<=start)
200  return insert(row,col);
201  const Index p = m_data.searchLowerIndex(start,end-1,inner);
202  if((p<end) && (m_data.index(p)==inner))
203  return m_data.value(p);
204  else
205  return insert(row,col);
206  }
Index cols() const
Definition: SparseMatrix.h:121
Index rows() const
Definition: SparseMatrix.h:119
Scalar & insert(Index row, Index col)
Definition: SparseMatrix.h:220
Index searchLowerIndex(Index key) const
template<typename _Scalar, int _Options, typename _Index>
Index Eigen::SparseMatrix< _Scalar, _Options, _Index >::cols ( void  ) const
inline
Returns
the number of columns of the matrix

Definition at line 121 of file SparseMatrix.h.

121 { return IsRowMajor ? m_innerSize : m_outerSize; }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::conservativeResize ( Index  rows,
Index  cols 
)
inline

Resizes the matrix to a rows x cols matrix leaving old values untouched.

See also
resizeNonZeros(Index), reserve(), setZero()

Definition at line 532 of file SparseMatrix.h.

533  {
534  // No change
535  if (this->rows() == rows && this->cols() == cols) return;
536 
537  // If one dimension is null, then there is nothing to be preserved
538  if(rows==0 || cols==0) return resize(rows,cols);
539 
540  Index innerChange = IsRowMajor ? cols - this->cols() : rows - this->rows();
541  Index outerChange = IsRowMajor ? rows - this->rows() : cols - this->cols();
542  Index newInnerSize = IsRowMajor ? cols : rows;
543 
544  // Deals with inner non zeros
545  if (m_innerNonZeros)
546  {
547  // Resize m_innerNonZeros
548  Index *newInnerNonZeros = static_cast<Index*>(std::realloc(m_innerNonZeros, (m_outerSize + outerChange) * sizeof(Index)));
549  if (!newInnerNonZeros) internal::throw_std_bad_alloc();
550  m_innerNonZeros = newInnerNonZeros;
551 
552  for(Index i=m_outerSize; i<m_outerSize+outerChange; i++)
553  m_innerNonZeros[i] = 0;
554  }
555  else if (innerChange < 0)
556  {
557  // Inner size decreased: allocate a new m_innerNonZeros
558  m_innerNonZeros = static_cast<Index*>(std::malloc((m_outerSize+outerChange+1) * sizeof(Index)));
559  if (!m_innerNonZeros) internal::throw_std_bad_alloc();
560  for(Index i = 0; i < m_outerSize; i++)
561  m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i];
562  }
563 
564  // Change the m_innerNonZeros in case of a decrease of inner size
565  if (m_innerNonZeros && innerChange < 0)
566  {
567  for(Index i = 0; i < m_outerSize + (std::min)(outerChange, Index(0)); i++)
568  {
569  Index &n = m_innerNonZeros[i];
570  Index start = m_outerIndex[i];
571  while (n > 0 && m_data.index(start+n-1) >= newInnerSize) --n;
572  }
573  }
574 
575  m_innerSize = newInnerSize;
576 
577  // Re-allocate outer index structure if necessary
578  if (outerChange == 0)
579  return;
580 
581  Index *newOuterIndex = static_cast<Index*>(std::realloc(m_outerIndex, (m_outerSize + outerChange + 1) * sizeof(Index)));
582  if (!newOuterIndex) internal::throw_std_bad_alloc();
583  m_outerIndex = newOuterIndex;
584  if (outerChange > 0)
585  {
586  Index last = m_outerSize == 0 ? 0 : m_outerIndex[m_outerSize];
587  for(Index i=m_outerSize; i<m_outerSize+outerChange+1; i++)
588  m_outerIndex[i] = last;
589  }
590  m_outerSize += outerChange;
591  }
Index cols() const
Definition: SparseMatrix.h:121
Index rows() const
Definition: SparseMatrix.h:119
void resize(Index rows, Index cols)
Definition: SparseMatrix.h:596
template<typename _Scalar, int _Options, typename _Index>
const Diagonal<const SparseMatrix> Eigen::SparseMatrix< _Scalar, _Options, _Index >::diagonal ( ) const
inline
Returns
a const expression of the diagonal coefficients

Definition at line 626 of file SparseMatrix.h.

626 { return *this; }
template<typename _Scalar, int _Options, typename _Index>
const Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::innerIndexPtr ( ) const
inline
Returns
a const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.
See also
valuePtr(), outerIndexPtr()

Definition at line 140 of file SparseMatrix.h.

140 { return &m_data.index(0); }
template<typename _Scalar, int _Options, typename _Index>
Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::innerIndexPtr ( )
inline
Returns
a non-const pointer to the array of inner indices. This function is aimed at interoperability with other libraries.
See also
valuePtr(), outerIndexPtr()

Definition at line 144 of file SparseMatrix.h.

144 { return &m_data.index(0); }
template<typename _Scalar, int _Options, typename _Index>
const Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::innerNonZeroPtr ( ) const
inline
Returns
a const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.
Warning
it returns the null pointer 0 in compressed mode

Definition at line 158 of file SparseMatrix.h.

158 { return m_innerNonZeros; }
template<typename _Scalar, int _Options, typename _Index>
Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::innerNonZeroPtr ( )
inline
Returns
a non-const pointer to the array of the number of non zeros of the inner vectors. This function is aimed at interoperability with other libraries.
Warning
it returns the null pointer 0 in compressed mode

Definition at line 162 of file SparseMatrix.h.

162 { return m_innerNonZeros; }
template<typename _Scalar, int _Options, typename _Index>
Index Eigen::SparseMatrix< _Scalar, _Options, _Index >::innerSize ( ) const
inline
Returns
the number of rows (resp. columns) of the matrix if the storage order column major (resp. row major)

Definition at line 124 of file SparseMatrix.h.

124 { return m_innerSize; }
template<typename _Scalar, int _Options, typename _Index>
Scalar& Eigen::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.

If the matrix *this is in compressed mode, then *this is turned into uncompressed mode while reserving room for 2 non zeros per inner vector. It is strongly recommended to first call reserve(const SizesType &) to reserve a more appropriate number of elements per inner vector that better match your scenario.

This function performs a sorted insertion in O(1) if the elements of each inner vector are inserted in increasing inner index order, and in O(nnz_j) for a random insertion.

Definition at line 220 of file SparseMatrix.h.

221  {
222  eigen_assert(row>=0 && row<rows() && col>=0 && col<cols());
223 
224  if(isCompressed())
225  {
226  reserve(VectorXi::Constant(outerSize(), 2));
227  }
228  return insertUncompressed(row,col);
229  }
Index cols() const
Definition: SparseMatrix.h:121
Index outerSize() const
Definition: SparseMatrix.h:126
Index rows() const
Definition: SparseMatrix.h:119
void reserve(Index reserveSize)
Definition: SparseMatrix.h:256
bool isCompressed() const
Definition: SparseMatrix.h:116
template<typename _Scalar, int _Options, typename _Index>
bool Eigen::SparseMatrix< _Scalar, _Options, _Index >::isCompressed ( ) const
inline
Returns
whether *this is in compressed form.

Definition at line 116 of file SparseMatrix.h.

116 { return m_innerNonZeros==0; }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::makeCompressed ( )
inline

Turns the matrix into the compressed format.

Definition at line 449 of file SparseMatrix.h.

450  {
451  if(isCompressed())
452  return;
453 
454  Index oldStart = m_outerIndex[1];
455  m_outerIndex[1] = m_innerNonZeros[0];
456  for(Index j=1; j<m_outerSize; ++j)
457  {
458  Index nextOldStart = m_outerIndex[j+1];
459  Index offset = oldStart - m_outerIndex[j];
460  if(offset>0)
461  {
462  for(Index k=0; k<m_innerNonZeros[j]; ++k)
463  {
464  m_data.index(m_outerIndex[j]+k) = m_data.index(oldStart+k);
465  m_data.value(m_outerIndex[j]+k) = m_data.value(oldStart+k);
466  }
467  }
468  m_outerIndex[j+1] = m_outerIndex[j] + m_innerNonZeros[j];
469  oldStart = nextOldStart;
470  }
471  std::free(m_innerNonZeros);
472  m_innerNonZeros = 0;
473  m_data.resize(m_outerIndex[m_outerSize]);
474  m_data.squeeze();
475  }
bool isCompressed() const
Definition: SparseMatrix.h:116
template<typename _Scalar, int _Options, typename _Index>
Index Eigen::SparseMatrix< _Scalar, _Options, _Index >::nonZeros ( ) const
inline
Returns
the number of non zero coefficients

Definition at line 246 of file SparseMatrix.h.

247  {
248  if(m_innerNonZeros)
249  return innerNonZeros().sum();
250  return static_cast<Index>(m_data.size());
251  }
template<typename _Scalar, int _Options, typename _Index>
const Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::outerIndexPtr ( ) const
inline
Returns
a const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.
See also
valuePtr(), innerIndexPtr()

Definition at line 149 of file SparseMatrix.h.

149 { return m_outerIndex; }
template<typename _Scalar, int _Options, typename _Index>
Index* Eigen::SparseMatrix< _Scalar, _Options, _Index >::outerIndexPtr ( )
inline
Returns
a non-const pointer to the array of the starting positions of the inner vectors. This function is aimed at interoperability with other libraries.
See also
valuePtr(), innerIndexPtr()

Definition at line 153 of file SparseMatrix.h.

153 { return m_outerIndex; }
template<typename _Scalar, int _Options, typename _Index>
Index Eigen::SparseMatrix< _Scalar, _Options, _Index >::outerSize ( ) const
inline
Returns
the number of columns (resp. rows) of the matrix if the storage order column major (resp. row major)

Definition at line 126 of file SparseMatrix.h.

126 { return m_outerSize; }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::prune ( const Scalar &  reference,
const RealScalar epsilon = NumTraits<RealScalar>::dummy_precision() 
)
inline

Suppresses all nonzeros which are much smaller than reference under the tolerence epsilon

Definition at line 490 of file SparseMatrix.h.

491  {
492  prune(default_prunning_func(reference,epsilon));
493  }
void prune(const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
Definition: SparseMatrix.h:490
template<typename _Scalar, int _Options, typename _Index>
template<typename KeepFunc >
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::prune ( const KeepFunc &  keep = KeepFunc())
inline

Turns the matrix into compressed format, and suppresses 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 503 of file SparseMatrix.h.

504  {
505  // TODO optimize the uncompressed mode to avoid moving and allocating the data twice
506  // TODO also implement a unit test
507  makeCompressed();
508 
509  Index k = 0;
510  for(Index j=0; j<m_outerSize; ++j)
511  {
512  Index previousStart = m_outerIndex[j];
513  m_outerIndex[j] = k;
514  Index end = m_outerIndex[j+1];
515  for(Index i=previousStart; i<end; ++i)
516  {
517  if(keep(IsRowMajor?j:m_data.index(i), IsRowMajor?m_data.index(i):j, m_data.value(i)))
518  {
519  m_data.value(k) = m_data.value(i);
520  m_data.index(k) = m_data.index(i);
521  ++k;
522  }
523  }
524  }
525  m_outerIndex[m_outerSize] = k;
526  m_data.resize(k,0);
527  }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::reserve ( Index  reserveSize)
inline

Preallocates reserveSize non zeros.

Precondition: the matrix must be in compressed mode.

Definition at line 256 of file SparseMatrix.h.

257  {
258  eigen_assert(isCompressed() && "This function does not make sense in non compressed mode.");
259  m_data.reserve(reserveSize);
260  }
bool isCompressed() const
Definition: SparseMatrix.h:116
template<typename _Scalar, int _Options, typename _Index>
void Eigen::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 596 of file SparseMatrix.h.

597  {
598  const Index outerSize = IsRowMajor ? rows : cols;
599  m_innerSize = IsRowMajor ? cols : rows;
600  m_data.clear();
601  if (m_outerSize != outerSize || m_outerSize==0)
602  {
603  std::free(m_outerIndex);
604  m_outerIndex = static_cast<Index*>(std::malloc((outerSize + 1) * sizeof(Index)));
605  if (!m_outerIndex) internal::throw_std_bad_alloc();
606 
607  m_outerSize = outerSize;
608  }
609  if(m_innerNonZeros)
610  {
611  std::free(m_innerNonZeros);
612  m_innerNonZeros = 0;
613  }
614  memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(Index));
615  }
Index cols() const
Definition: SparseMatrix.h:121
Index outerSize() const
Definition: SparseMatrix.h:126
Index rows() const
Definition: SparseMatrix.h:119
template<typename _Scalar, int _Options, typename _Index>
Index Eigen::SparseMatrix< _Scalar, _Options, _Index >::rows ( void  ) const
inline
Returns
the number of rows of the matrix

Definition at line 119 of file SparseMatrix.h.

119 { return IsRowMajor ? m_outerSize : m_innerSize; }
template<typename Scalar , int _Options, typename _Index >
template<typename InputIterators >
void Eigen::SparseMatrix< Scalar, _Options, _Index >::setFromTriplets ( const InputIterators &  begin,
const InputIterators &  end 
)

Fill the matrix *this with the list of triplets defined by the iterator range begin - end.

A triplet is a tuple (i,j,value) defining a non-zero element. The input list of triplets does not have to be sorted, and can contains duplicated elements. In any case, the result is a sorted and compressed sparse matrix where the duplicates have been summed up. This is a O(n) operation, with n the number of triplet elements. The initial contents of *this is destroyed. The matrix *this must be properly resized beforehand using the SparseMatrix(Index,Index) constructor, or the resize(Index,Index) method. The sizes are not extracted from the triplet list.

The InputIterators value_type must provide the following interface:

Scalar value() const; // the value
Scalar row() const; // the row index i
Scalar col() const; // the column index j

See for instance the Eigen::Triplet template class.

Here is a typical usage example:

typedef Triplet<double> T;
std::vector<T> tripletList;
triplets.reserve(estimation_of_entries);
for(...)
{
// ...
tripletList.push_back(T(i,j,v_ij));
}
SparseMatrixType m(rows,cols);
m.setFromTriplets(tripletList.begin(), tripletList.end());
// m is ready to go!
Warning
The list of triplets is read multiple times (at least twice). Therefore, it is not recommended to define an abstract iterator over a complex data-structure that would be expensive to evaluate. The triplets should rather be explicitely stored into a std::vector for instance.

Definition at line 1010 of file SparseMatrix.h.

1011 {
1012  internal::set_from_triplets(begin, end, *this);
1013 }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::setIdentity ( )
inline

Sets *this to the identity matrix

Definition at line 695 of file SparseMatrix.h.

696  {
697  eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES");
698  this->m_data.resize(rows());
699  Eigen::Map<Matrix<Index, Dynamic, 1> >(&this->m_data.index(0), rows()).setLinSpaced(0, rows()-1);
700  Eigen::Map<Matrix<Scalar, Dynamic, 1> >(&this->m_data.value(0), rows()).setOnes();
701  Eigen::Map<Matrix<Index, Dynamic, 1> >(this->m_outerIndex, rows()+1).setLinSpaced(0, rows());
702  }
Index cols() const
Definition: SparseMatrix.h:121
Index rows() const
Definition: SparseMatrix.h:119
A matrix or vector expression mapping an existing array of data.
Definition: Map.h:104
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::setZero ( )
inline

Removes all non zeros but keep allocated memory

Definition at line 237 of file SparseMatrix.h.

238  {
239  m_data.clear();
240  memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(Index));
241  if(m_innerNonZeros)
242  memset(m_innerNonZeros, 0, (m_outerSize)*sizeof(Index));
243  }
template<typename _Scalar , int _Options, typename _Index >
internal::traits< SparseMatrix< _Scalar, _Options, _Index > >::Scalar Eigen::SparseMatrix< _Scalar, _Options, _Index >::sum ( ) const

Overloaded for performance

Definition at line 29 of file SparseRedux.h.

30 {
31  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
32  return Matrix<Scalar,1,Dynamic>::Map(&m_data.value(0), m_data.size()).sum();
33 }
Index cols() const
Definition: SparseMatrix.h:121
Scalar sum() const
Definition: SparseRedux.h:29
Index rows() const
Definition: SparseMatrix.h:119
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::swap ( SparseMatrix< _Scalar, _Options, _Index > &  other)
inline

Swaps the content of two sparse matrices of the same type. This is a fast operation that simply swaps the underlying pointers and parameters.

Definition at line 684 of file SparseMatrix.h.

685  {
686  //EIGEN_DBG_SPARSE(std::cout << "SparseMatrix:: swap\n");
687  std::swap(m_outerIndex, other.m_outerIndex);
688  std::swap(m_innerSize, other.m_innerSize);
689  std::swap(m_outerSize, other.m_outerSize);
690  std::swap(m_innerNonZeros, other.m_innerNonZeros);
691  m_data.swap(other.m_data);
692  }
template<typename _Scalar, int _Options, typename _Index>
void Eigen::SparseMatrix< _Scalar, _Options, _Index >::uncompress ( )
inline

Turns the matrix into the uncompressed mode

Definition at line 478 of file SparseMatrix.h.

479  {
480  if(m_innerNonZeros != 0)
481  return;
482  m_innerNonZeros = static_cast<Index*>(std::malloc(m_outerSize * sizeof(Index)));
483  for (int i = 0; i < m_outerSize; i++)
484  {
485  m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i];
486  }
487  }
template<typename _Scalar, int _Options, typename _Index>
const Scalar* Eigen::SparseMatrix< _Scalar, _Options, _Index >::valuePtr ( ) const
inline
Returns
a const pointer to the array of values. This function is aimed at interoperability with other libraries.
See also
innerIndexPtr(), outerIndexPtr()

Definition at line 131 of file SparseMatrix.h.

131 { return &m_data.value(0); }
template<typename _Scalar, int _Options, typename _Index>
Scalar* Eigen::SparseMatrix< _Scalar, _Options, _Index >::valuePtr ( )
inline
Returns
a non-const pointer to the array of values. This function is aimed at interoperability with other libraries.
See also
innerIndexPtr(), outerIndexPtr()

Definition at line 135 of file SparseMatrix.h.

135 { return &m_data.value(0); }

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