Eigen::SparseVector< Scalar_, Options_, StorageIndex_ > Class Template Reference

a sparse vector class More...

+ Inheritance diagram for Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >:

Public Types

enum  { IsColVector }
 
enum  { Options }
 
typedef internal::CompressedStorage< Scalar, StorageIndexStorage
 
- Public Types inherited from Eigen::SparseCompressedBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
typedef SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > > Base
 
- Public Types inherited from Eigen::SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
enum  
 
typedef std::conditional_t< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const SparseVector< Scalar_, Options_, StorageIndex_ > > >, Transpose< const SparseVector< Scalar_, Options_, StorageIndex_ > > > AdjointReturnType
 
typedef Transpose< const SparseVector< Scalar_, Options_, StorageIndex_ > > ConstTransposeReturnType
 
typedef Matrix< StorageIndex, Dynamic, 1 > IndexVector
 
typedef internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits< Scalar >::type >::type PacketReturnType
 
typedef internal::packet_traits< Scalar >::type PacketScalar
 
typedef SparseMatrix< Scalar, Flags &RowMajorBit ? RowMajor :ColMajor, StorageIndexPlainObject
 
typedef internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::Scalar Scalar
 
typedef Matrix< Scalar, Dynamic, 1 > ScalarVector
 
typedef SparseMatrixBase StorageBaseType
 
typedef internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::StorageIndex StorageIndex
 
typedef internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::StorageKind StorageKind
 
typedef Transpose< SparseVector< Scalar_, Options_, StorageIndex_ > > TransposeReturnType
 
typedef Scalar value_type
 
- Public Types inherited from Eigen::EigenBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::StorageKind StorageKind
 

Public Member Functions

EIGEN_DEPRECATED Storage_data ()
 
EIGEN_DEPRECATED const Storage_data () const
 
Scalar coeff (Index i) const
 
Scalar coeff (Index row, Index col) const
 
ScalarcoeffRef (Index i)
 
ScalarcoeffRef (Index row, Index col)
 
Index cols () const
 
void conservativeResize (Index newSize)
 
Storagedata ()
 
const Storagedata () const
 
EIGEN_DEPRECATED void endFill ()
 
EIGEN_DEPRECATED Scalarfill (Index i)
 
EIGEN_DEPRECATED Scalarfill (Index r, Index c)
 
EIGEN_DEPRECATED Scalarfillrand (Index i)
 
EIGEN_DEPRECATED Scalarfillrand (Index r, Index c)
 
void finalize ()
 
StorageIndexinnerIndexPtr ()
 
const StorageIndexinnerIndexPtr () const
 
StorageIndexinnerNonZeroPtr ()
 
const StorageIndexinnerNonZeroPtr () const
 
Index innerSize () const
 
Scalarinsert (Index i)
 
Scalarinsert (Index row, Index col)
 
ScalarinsertBack (Index i)
 
ScalarinsertBackByOuterInner (Index outer, Index inner)
 
ScalarinsertBackByOuterInnerUnordered (Index outer, Index inner)
 
ScalarinsertBackUnordered (Index i)
 
Index nonZeros () const
 
template<typename OtherDerived >
SparseVectoroperator= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVectoroperator= (const SparseVector &other)
 
StorageIndexouterIndexPtr ()
 
const StorageIndexouterIndexPtr () const
 
Index outerSize () const
 
Index prune (const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
 
template<class F >
Index prune (F &&keep_predicate)
 Prunes the entries of the vector based on a predicate More...
 
void reserve (Index reserveSize)
 
void resize (Index newSize)
 
void resize (Index rows, Index cols)
 
void resizeNonZeros (Index size)
 
Index rows () const
 
void setZero ()
 
 SparseVector ()
 
template<typename OtherDerived >
 SparseVector (const SparseMatrixBase< OtherDerived > &other)
 
 SparseVector (const SparseVector &other)
 
 SparseVector (Index rows, Index cols)
 
 SparseVector (Index size)
 
EIGEN_DEPRECATED void startFill (Index reserve)
 
void startVec (Index outer)
 
Scalar sum () const
 
template<int OtherOptions>
void swap (SparseMatrix< Scalar, OtherOptions, StorageIndex > &other)
 
void swap (SparseVector &other)
 
ScalarvaluePtr ()
 
const ScalarvaluePtr () const
 
 ~SparseVector ()
 
- Public Member Functions inherited from Eigen::SparseCompressedBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
Map< Array< Scalar, Dynamic, 1 > > coeffs ()
 
const Map< const Array< Scalar, Dynamic, 1 > > coeffs () const
 
StorageIndexinnerIndexPtr ()
 
const StorageIndexinnerIndexPtr () const
 
Index innerIndicesAreSorted () const
 
Index innerIndicesAreSorted (Index begin, Index end) const
 
StorageIndexinnerNonZeroPtr ()
 
const StorageIndexinnerNonZeroPtr () const
 
bool isCompressed () const
 
Index nonZeros () const
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const EigenBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const ReturnByValue< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const SparseVector< Scalar_, Options_, StorageIndex_ > &other)
 
StorageIndexouterIndexPtr ()
 
const StorageIndexouterIndexPtr () const
 
void sortInnerIndices ()
 
void sortInnerIndices (Index begin, Index end)
 
ScalarvaluePtr ()
 
const ScalarvaluePtr () const
 
- Public Member Functions inherited from Eigen::SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
const AdjointReturnType adjoint () const
 
RealScalar blueNorm () const
 
Index cols () const
 
const SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >::template CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
const CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::Scalar dot (const MatrixBase< OtherDerived > &other) const
 
Scalar dot (const MatrixBase< OtherDerived > &other) const
 
internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
const internal::eval< SparseVector< Scalar_, Options_, StorageIndex_ > >::type eval () const
 
Index innerSize () const
 
bool isApprox (const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isApprox (const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isRValue () const
 
bool isVector () const
 
SparseVector< Scalar_, Options_, StorageIndex_ > & markAsRValue ()
 
RealScalar norm () const
 
const Product< SparseVector< Scalar_, Options_, StorageIndex_ >, OtherDerived > operator* (const DiagonalBase< OtherDerived > &other) const
 
const Product< SparseVector< Scalar_, Options_, StorageIndex_ >, OtherDerived > operator* (const MatrixBase< OtherDerived > &other) const
 
const Product< SparseVector< Scalar_, Options_, StorageIndex_ >, OtherDerived, AliasFreeProduct > operator* (const SparseMatrixBase< OtherDerived > &other) const
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator*= (const Scalar &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator*= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator+= (const DiagonalBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator+= (const EigenBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator+= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator-= (const DiagonalBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator-= (const EigenBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator-= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator/= (const Scalar &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const EigenBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const ReturnByValue< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const SparseMatrixBase< OtherDerived > &other)
 
SparseVector< Scalar_, Options_, StorageIndex_ > & operator= (const SparseVector< Scalar_, Options_, StorageIndex_ > &other)
 
Index outerSize () const
 
const SparseView< SparseVector< Scalar_, Options_, StorageIndex_ > > pruned (const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
 
Index rows () const
 
SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >::template SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView () const
 
SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >::template ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView () const
 
Index size () const
 
 SparseMatrixBase ()
 
RealScalar squaredNorm () const
 
Scalar sum () const
 
DenseMatrixType toDense () const
 
TransposeReturnType transpose ()
 
const ConstTransposeReturnType transpose () const
 
const TriangularView< const SparseVector< Scalar_, Options_, StorageIndex_ >, Mode > triangularView () const
 
SparseSymmetricPermutationProduct< SparseVector< Scalar_, Options_, StorageIndex_ >, Upper|Lower > twistedBy (const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
 
- Public Member Functions inherited from Eigen::EigenBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
void addTo (Dest &dst) const
 
void applyThisOnTheLeft (Dest &dst) const
 
void applyThisOnTheRight (Dest &dst) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
SparseVector< Scalar_, Options_, StorageIndex_ > & const_cast_derived () const
 
const SparseVector< Scalar_, Options_, StorageIndex_ > & const_derived () const
 
SparseVector< Scalar_, Options_, StorageIndex_ > & derived ()
 
const SparseVector< Scalar_, Options_, StorageIndex_ > & derived () const
 
void evalTo (Dest &dst) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
void subTo (Dest &dst) const
 

Protected Member Functions

 EIGEN_STATIC_ASSERT ((Options_ &(ColMajor|RowMajor))==Options, INVALID_MATRIX_TEMPLATE_PARAMETERS) Storage m_data
 
- Protected Member Functions inherited from Eigen::SparseCompressedBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
Eigen::Map< IndexVectorinnerNonZeros ()
 
const Eigen::Map< const IndexVectorinnerNonZeros () const
 
internal::LowerBoundIndex lower_bound (Index row, Index col) const
 
 SparseCompressedBase ()
 
- Protected Member Functions inherited from Eigen::SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
SparseVector< Scalar_, Options_, StorageIndex_ > & assign (const OtherDerived &other)
 
void assignGeneric (const OtherDerived &other)
 

Protected Attributes

Index m_size
 
- Protected Attributes inherited from Eigen::SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
bool m_isRValue
 

Private Types

typedef SparseCompressedBase< SparseVectorBase
 

Additional Inherited Members

- Protected Types inherited from Eigen::SparseCompressedBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
typedef Base::IndexVector IndexVector
 
- Static Protected Member Functions inherited from Eigen::SparseMatrixBase< SparseVector< Scalar_, Options_, StorageIndex_ > >
static StorageIndex convert_index (const Index idx)
 

Detailed Description

template<typename Scalar_, int Options_, typename StorageIndex_>
class Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >

a sparse vector class

Template Parameters
Scalar_the scalar type, i.e. the type of the coefficients

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 Extending MatrixBase (and other classes) by defining the preprocessor symbol EIGEN_SPARSEVECTOR_PLUGIN.

Definition at line 66 of file SparseVector.h.

Member Typedef Documentation

◆ Base

template<typename Scalar_ , int Options_, typename StorageIndex_ >
typedef SparseCompressedBase<SparseVector> Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::Base
private

Definition at line 69 of file SparseVector.h.

◆ Storage

template<typename Scalar_ , int Options_, typename StorageIndex_ >
typedef internal::CompressedStorage<Scalar,StorageIndex> Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::Storage

Definition at line 76 of file SparseVector.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Scalar_ , int Options_, typename StorageIndex_ >
anonymous enum
Enumerator
IsColVector 

Definition at line 77 of file SparseVector.h.

77 { IsColVector = internal::traits<SparseVector>::IsColVector };

◆ anonymous enum

template<typename Scalar_ , int Options_, typename StorageIndex_ >
anonymous enum
Enumerator
Options 

Definition at line 79 of file SparseVector.h.

79  {
80  Options = Options_
81  };

Constructor & Destructor Documentation

◆ SparseVector() [1/5]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::SparseVector ( )
inline

Definition at line 285 of file SparseVector.h.

285 : m_size(0) { resize(0); }
void resize(Index rows, Index cols)
Definition: SparseVector.h:249

◆ SparseVector() [2/5]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::SparseVector ( Index  size)
inlineexplicit

◆ SparseVector() [3/5]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::SparseVector ( Index  rows,
Index  cols 
)
inline

Definition at line 289 of file SparseVector.h.

289 : m_size(0) { resize(rows,cols); }
Index cols() const
Definition: SparseVector.h:84
Index rows() const
Definition: SparseVector.h:83

◆ SparseVector() [4/5]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
template<typename OtherDerived >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::SparseVector ( const SparseMatrixBase< OtherDerived > &  other)
inline

Definition at line 292 of file SparseVector.h.

293  : m_size(0)
294  {
295  #ifdef EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
296  EIGEN_SPARSE_CREATE_TEMPORARY_PLUGIN
297  #endif
298  *this = other.derived();
299  }

◆ SparseVector() [5/5]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::SparseVector ( const SparseVector< Scalar_, Options_, StorageIndex_ > &  other)
inline

Definition at line 301 of file SparseVector.h.

302  : Base(other), m_size(0)
303  {
304  *this = other.derived();
305  }
SparseCompressedBase< SparseVector > Base
Definition: SparseVector.h:69

◆ ~SparseVector()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::~SparseVector ( )
inline

Destructor

Definition at line 367 of file SparseVector.h.

367 {}

Member Function Documentation

◆ _data() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED Storage& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::_data ( )
inline

Definition at line 413 of file SparseVector.h.

413 { return m_data; }

◆ _data() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED const Storage& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::_data ( ) const
inline

Definition at line 415 of file SparseVector.h.

415 { return m_data; }

◆ coeff() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::coeff ( Index  i) const
inline

Definition at line 109 of file SparseVector.h.

110  {
111  eigen_assert(i>=0 && i<m_size);
112  return m_data.at(StorageIndex(i));
113  }
#define eigen_assert(x)
Definition: Macros.h:902
internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::StorageIndex StorageIndex

◆ coeff() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::coeff ( Index  row,
Index  col 
) const
inline

Definition at line 104 of file SparseVector.h.

105  {
106  eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));
107  return coeff(IsColVector ? row : col);
108  }
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().
Scalar coeff(Index row, Index col) const
Definition: SparseVector.h:104

◆ coeffRef() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::coeffRef ( Index  i)
inline
Returns
a reference to the coefficient value at given index i This operation involes a log(rho*size) binary search. If the coefficient does not exist yet, then a sorted insertion into a sequential buffer is performed.

This insertion might be very costly if the number of nonzeros above i is large.

Definition at line 127 of file SparseVector.h.

128  {
129  eigen_assert(i>=0 && i<m_size);
130 
131  return m_data.atWithInsertion(StorageIndex(i));
132  }

◆ coeffRef() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::coeffRef ( Index  row,
Index  col 
)
inline

Definition at line 115 of file SparseVector.h.

116  {
117  eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));
118  return coeffRef(IsColVector ? row : col);
119  }
Scalar & coeffRef(Index row, Index col)
Definition: SparseVector.h:115

◆ cols()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::cols ( void  ) const
inline

Definition at line 84 of file SparseVector.h.

84 { return IsColVector ? 1 : m_size; }

◆ conservativeResize()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::conservativeResize ( Index  newSize)
inline

Resizes the sparse vector to newSize, while leaving old values untouched.

If the size of the vector is decreased, then the storage of the out-of bounds coefficients is kept and reserved. Call .data().squeeze() to free extra memory.

See also
reserve(), setZero()

Definition at line 272 of file SparseVector.h.

273  {
274  if (newSize < m_size)
275  {
276  Index i = 0;
277  while (i<m_data.size() && m_data.index(i)<newSize) ++i;
278  m_data.resize(i);
279  }
280  m_size = newSize;
281  }
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41

◆ data() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Storage& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::data ( )
inline

Definition at line 100 of file SparseVector.h.

100 { return m_data; }

◆ data() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
const Storage& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::data ( ) const
inline

Definition at line 102 of file SparseVector.h.

102 { return m_data; }

◆ EIGEN_STATIC_ASSERT()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::EIGEN_STATIC_ASSERT ( (Options_ &(ColMajor|RowMajor))  = =Options,
INVALID_MATRIX_TEMPLATE_PARAMETERS   
)
protected

◆ endFill()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::endFill ( )
inline

Definition at line 409 of file SparseVector.h.

409 {}

◆ fill() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::fill ( Index  i)
inline

Definition at line 389 of file SparseVector.h.

390  {
391  m_data.append(0, i);
392  return m_data.value(m_data.size()-1);
393  }

◆ fill() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::fill ( Index  r,
Index  c 
)
inline

Definition at line 382 of file SparseVector.h.

383  {
384  eigen_assert(r==0 || c==0);
385  return fill(IsColVector ? r : c);
386  }
Array33i c
EIGEN_DEPRECATED Scalar & fill(Index r, Index c)
Definition: SparseVector.h:382

◆ fillrand() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::fillrand ( Index  i)
inline

Definition at line 403 of file SparseVector.h.

404  {
405  return insert(i);
406  }
Scalar & insert(Index row, Index col)
Definition: SparseVector.h:174

◆ fillrand() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::fillrand ( Index  r,
Index  c 
)
inline

Definition at line 396 of file SparseVector.h.

397  {
398  eigen_assert(r==0 || c==0);
399  return fillrand(IsColVector ? r : c);
400  }
EIGEN_DEPRECATED Scalar & fillrand(Index r, Index c)
Definition: SparseVector.h:396

◆ finalize()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::finalize ( )
inline

Definition at line 209 of file SparseVector.h.

209 {}

◆ innerIndexPtr() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::innerIndexPtr ( )
inline

Definition at line 92 of file SparseVector.h.

92 { return m_data.indexPtr(); }

◆ innerIndexPtr() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
const StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::innerIndexPtr ( ) const
inline

Definition at line 91 of file SparseVector.h.

91 { return m_data.indexPtr(); }

◆ innerNonZeroPtr() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::innerNonZeroPtr ( )
inline

Definition at line 97 of file SparseVector.h.

97 { return 0; }

◆ innerNonZeroPtr() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
const StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::innerNonZeroPtr ( ) const
inline

Definition at line 96 of file SparseVector.h.

96 { return 0; }

◆ innerSize()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::innerSize ( ) const
inline

Definition at line 85 of file SparseVector.h.

85 { return m_size; }

◆ insert() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insert ( Index  i)
inline

Definition at line 184 of file SparseVector.h.

185  {
186  eigen_assert(i>=0 && i<m_size);
187 
188  Index startId = 0;
189  Index p = Index(m_data.size()) - 1;
190  // TODO smart realloc
191  m_data.resize(p+2,1);
192 
193  while ( (p >= startId) && (m_data.index(p) > i) )
194  {
195  m_data.index(p+1) = m_data.index(p);
196  m_data.value(p+1) = m_data.value(p);
197  --p;
198  }
199  m_data.index(p+1) = convert_index(i);
200  m_data.value(p+1) = 0;
201  return m_data.value(p+1);
202  }
float * p

◆ insert() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insert ( Index  row,
Index  col 
)
inline

Definition at line 174 of file SparseVector.h.

175  {
176  eigen_assert(IsColVector ? (col==0 && row>=0 && row<m_size) : (row==0 && col>=0 && col<m_size));
177 
178  Index inner = IsColVector ? row : col;
179  Index outer = IsColVector ? col : row;
181  eigen_assert(outer==0);
182  return insert(inner);
183  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:914

◆ insertBack()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insertBack ( Index  i)
inline

Definition at line 156 of file SparseVector.h.

157  {
158  m_data.append(0, i);
159  return m_data.value(m_data.size()-1);
160  }

◆ insertBackByOuterInner()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insertBackByOuterInner ( Index  outer,
Index  inner 
)
inline

Definition at line 150 of file SparseVector.h.

151  {
152  EIGEN_UNUSED_VARIABLE(outer);
153  eigen_assert(outer==0);
154  return insertBack(inner);
155  }
#define EIGEN_UNUSED_VARIABLE(var)
Definition: Macros.h:957
Scalar & insertBack(Index i)
Definition: SparseVector.h:156

◆ insertBackByOuterInnerUnordered()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insertBackByOuterInnerUnordered ( Index  outer,
Index  inner 
)
inline

Definition at line 162 of file SparseVector.h.

163  {
164  EIGEN_UNUSED_VARIABLE(outer);
165  eigen_assert(outer==0);
166  return insertBackUnordered(inner);
167  }
Scalar & insertBackUnordered(Index i)
Definition: SparseVector.h:168

◆ insertBackUnordered()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::insertBackUnordered ( Index  i)
inline

Definition at line 168 of file SparseVector.h.

169  {
170  m_data.append(0, i);
171  return m_data.value(m_data.size()-1);
172  }

◆ nonZeros()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::nonZeros ( ) const
inline
Returns
the number of non zero coefficients

Definition at line 142 of file SparseVector.h.

142 { return m_data.size(); }

◆ operator=() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
template<typename OtherDerived >
SparseVector& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::operator= ( const SparseMatrixBase< OtherDerived > &  other)
inline

Definition at line 340 of file SparseVector.h.

341  {
342  SparseVector tmp(other.size());
343  internal::sparse_vector_assign_selector<SparseVector,OtherDerived>::run(tmp,other.derived());
344  this->swap(tmp);
345  return *this;
346  }
void swap(SparseVector &other)
Definition: SparseVector.h:311

◆ operator=() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
SparseVector& Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::operator= ( const SparseVector< Scalar_, Options_, StorageIndex_ > &  other)
inline

Definition at line 325 of file SparseVector.h.

326  {
327  if (other.isRValue())
328  {
329  swap(other.const_cast_derived());
330  }
331  else
332  {
333  resize(other.size());
334  m_data = other.m_data;
335  }
336  return *this;
337  }

◆ outerIndexPtr() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::outerIndexPtr ( )
inline

Definition at line 95 of file SparseVector.h.

95 { return 0; }

◆ outerIndexPtr() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
const StorageIndex* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::outerIndexPtr ( ) const
inline

Definition at line 94 of file SparseVector.h.

94 { return 0; }

◆ outerSize()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::outerSize ( ) const
inline

Definition at line 86 of file SparseVector.h.

86 { return 1; }

◆ prune() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::prune ( const Scalar reference,
const RealScalar &  epsilon = NumTraits<RealScalar>::dummy_precision() 
)
inline

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

Definition at line 212 of file SparseVector.h.

212  {
213  return prune([&](const Scalar& val){ return !internal::isMuchSmallerThan(val, reference, epsilon); });
214  }
internal::traits< SparseVector< Scalar_, Options_, StorageIndex_ > >::Scalar Scalar
Index prune(const Scalar &reference, const RealScalar &epsilon=NumTraits< RealScalar >::dummy_precision())
Definition: SparseVector.h:212
bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())

◆ prune() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
template<class F >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::prune ( F &&  keep_predicate)
inline

Prunes the entries of the vector based on a predicate

Template Parameters
FType of the predicate.
Parameters
keep_predicateThe predicate that is used to test whether a value should be kept. A callable that gets passed om a Scalar value and returns a boolean. If the predicate returns true, the value is kept.
Returns
The new number of structural non-zeros.

Definition at line 224 of file SparseVector.h.

225  {
226  Index k = 0;
227  Index n = m_data.size();
228  for (Index i = 0; i < n; ++i)
229  {
230  if (keep_predicate(m_data.value(i)))
231  {
232  m_data.value(k) = std::move(m_data.value(i));
233  m_data.index(k) = m_data.index(i);
234  ++k;
235  }
236  }
237  m_data.resize(k);
238  return k;
239  }
int n

◆ reserve()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::reserve ( Index  reserveSize)
inline

Definition at line 206 of file SparseVector.h.

206 { m_data.reserve(reserveSize); }

◆ resize() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::resize ( Index  newSize)
inline

Resizes the sparse vector to newSize This method deletes all entries, thus leaving an empty sparse vector

See also
conservativeResize(), setZero()

Definition at line 259 of file SparseVector.h.

260  {
261  m_size = newSize;
262  m_data.clear();
263  }

◆ resize() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::resize ( Index  rows,
Index  cols 
)
inline

Resizes the sparse vector to rows x cols

This method is provided for compatibility with matrices. For a column vector, cols must be equal to 1. For a row vector, rows must be equal to 1.

See also
resize(Index)

Definition at line 249 of file SparseVector.h.

250  {
251  eigen_assert((IsColVector ? cols : rows)==1 && "Outer dimension must equal 1");
253  }

◆ resizeNonZeros()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::resizeNonZeros ( Index  size)
inline

Definition at line 283 of file SparseVector.h.

283 { m_data.resize(size); }

◆ rows()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::rows ( void  ) const
inline

Definition at line 83 of file SparseVector.h.

83 { return IsColVector ? m_size : 1; }

◆ setZero()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::setZero ( )
inline

Definition at line 139 of file SparseVector.h.

139 { m_data.clear(); }

◆ startFill()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
EIGEN_DEPRECATED void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::startFill ( Index  reserve)
inline

Definition at line 375 of file SparseVector.h.

376  {
377  setZero();
378  m_data.reserve(reserve);
379  }
void reserve(Index reserveSize)
Definition: SparseVector.h:206

◆ startVec()

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::startVec ( Index  outer)
inline

Definition at line 144 of file SparseVector.h.

145  {
146  EIGEN_UNUSED_VARIABLE(outer);
147  eigen_assert(outer==0);
148  }

◆ sum()

template<typename Scalar_ , int Options_, typename Index_ >
internal::traits< SparseVector< Scalar_, Options_, Index_ > >::Scalar Eigen::SparseVector< Scalar_, Options_, Index_ >::sum

Overloaded for performance

Definition at line 43 of file SparseRedux.h.

44 {
45  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
46  return Matrix<Scalar,1,Dynamic>::Map(m_data.valuePtr(), m_data.size()).sum();
47 }

◆ swap() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
template<int OtherOptions>
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::swap ( SparseMatrix< Scalar, OtherOptions, StorageIndex > &  other)
inline

Definition at line 318 of file SparseVector.h.

319  {
320  eigen_assert(other.outerSize()==1);
321  std::swap(m_size, other.m_innerSize);
322  m_data.swap(other.m_data);
323  }
void swap(scoped_array< T > &a, scoped_array< T > &b)
Definition: Memory.h:788

◆ swap() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
void Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::swap ( SparseVector< Scalar_, Options_, StorageIndex_ > &  other)
inline

Swaps the values of *this and other. Overloaded for performance: this version performs a shallow swap by swapping pointers and attributes only.

See also
SparseMatrixBase::swap()

Definition at line 311 of file SparseVector.h.

312  {
313  std::swap(m_size, other.m_size);
314  m_data.swap(other.m_data);
315  }

◆ valuePtr() [1/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Scalar* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::valuePtr ( )
inline

Definition at line 89 of file SparseVector.h.

89 { return m_data.valuePtr(); }

◆ valuePtr() [2/2]

template<typename Scalar_ , int Options_, typename StorageIndex_ >
const Scalar* Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::valuePtr ( ) const
inline

Definition at line 88 of file SparseVector.h.

88 { return m_data.valuePtr(); }

Member Data Documentation

◆ m_size

template<typename Scalar_ , int Options_, typename StorageIndex_ >
Index Eigen::SparseVector< Scalar_, Options_, StorageIndex_ >::m_size
protected

Definition at line 426 of file SparseVector.h.


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