template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector class

a sparse vector class

Template parameters
_Scalar the scalar type, i.e. the type of the coefficients
_Options
_StorageIndex

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.

Base classes

template<typename Derived>
class SparseCompressedBase
Common base class for sparse [compressed]-{row|column}-storage format.

Public types

enum (anonymous) { IsColVector = internal::traits<SparseVector>::IsColVector }
enum (anonymous) { Options = _Options }
using Storage = internal::CompressedStorage<Scalar, StorageIndex>

Constructors, destructors, conversion operators

SparseVector()
SparseVector(Index size) explicit
SparseVector(Index rows, Index cols)
template<typename OtherDerived>
SparseVector(const SparseMatrixBase<OtherDerived>& other)
SparseVector(const SparseVector& other)
~SparseVector()

Public functions

auto _data() -> EIGEN_DEPRECATED Storage&
auto _data() const -> EIGEN_DEPRECATED const Storage&
auto coeff(Index row, Index col) const -> Scalar
auto coeff(Index i) const -> Scalar
auto coeffRef(Index row, Index col) -> Scalar&
auto coeffRef(Index i) -> Scalar&
auto cols() const -> Index
void conservativeResize(Index newSize)
auto data() -> Storage&
auto data() const -> const Storage&
auto endFill() -> EIGEN_DEPRECATED void
auto fill(Index r, Index c) -> EIGEN_DEPRECATED Scalar&
auto fill(Index i) -> EIGEN_DEPRECATED Scalar&
auto fillrand(Index r, Index c) -> EIGEN_DEPRECATED Scalar&
auto fillrand(Index i) -> EIGEN_DEPRECATED Scalar&
void finalize()
auto innerIndexPtr() const -> const StorageIndex*
auto innerIndexPtr() -> StorageIndex*
auto innerNonZeroPtr() const -> const StorageIndex*
auto innerNonZeroPtr() -> StorageIndex*
auto innerSize() const -> Index
auto insert(Index row, Index col) -> Scalar&
auto insert(Index i) -> Scalar&
auto insertBack(Index i) -> Scalar&
auto insertBackByOuterInner(Index outer, Index inner) -> Scalar&
auto insertBackByOuterInnerUnordered(Index outer, Index inner) -> Scalar&
auto insertBackUnordered(Index i) -> Scalar&
auto nonZeros() const -> Index
auto operator=(const SparseVector& other) -> SparseVector&
template<typename OtherDerived>
auto operator=(const SparseMatrixBase<OtherDerived>& other) -> SparseVector&
auto outerIndexPtr() const -> const StorageIndex*
auto outerIndexPtr() -> StorageIndex*
auto outerSize() const -> Index
void prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision())
void reserve(Index reserveSize)
void resize(Index rows, Index cols)
void resize(Index newSize)
void resizeNonZeros(Index size)
auto rows() const -> Index
void setZero()
auto startFill(Index reserve) -> EIGEN_DEPRECATED void
void startVec(Index outer)
auto sum() const -> Scalar
void swap(SparseVector& other)
template<int OtherOptions>
void swap(SparseMatrix<Scalar, OtherOptions, StorageIndex>& other)
auto valuePtr() const -> const Scalar*
auto valuePtr() -> Scalar*

Protected static functions

static void check_template_parameters()

Protected variables

Storage m_data
Index m_size

Friends

auto operator<<(std::ostream& s, const SparseVector& m) -> std::ostream&

Enum documentation

template<typename _Scalar, int _Options, typename _StorageIndex>
enum Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::(anonymous)

Enumerators
IsColVector

template<typename _Scalar, int _Options, typename _StorageIndex>
enum Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::(anonymous)

Enumerators
Options

Typedef documentation

template<typename _Scalar, int _Options, typename _StorageIndex>
typedef internal::CompressedStorage<Scalar, StorageIndex> Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::Storage

Function documentation

template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::SparseVector()

template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::SparseVector(Index size) explicit

template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::SparseVector(Index rows, Index cols)

template<typename _Scalar, int _Options, typename _StorageIndex> template<typename OtherDerived>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::SparseVector(const SparseMatrixBase<OtherDerived>& other)

template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::SparseVector(const SparseVector& other)

template<typename _Scalar, int _Options, typename _StorageIndex>
Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::~SparseVector()

Destructor

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED Storage& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::_data()

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED const Storage& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::_data() const

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::coeff(Index row, Index col) const

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::coeff(Index i) const

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::coeffRef(Index row, Index col)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::coeffRef(Index i)

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.

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::cols() const

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::conservativeResize(Index newSize)

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.

template<typename _Scalar, int _Options, typename _StorageIndex>
Storage& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::data()

template<typename _Scalar, int _Options, typename _StorageIndex>
const Storage& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::data() const

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::endFill()

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::fill(Index r, Index c)

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::fill(Index i)

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::fillrand(Index r, Index c)

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::fillrand(Index i)

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::finalize()

template<typename _Scalar, int _Options, typename _StorageIndex>
const StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::innerIndexPtr() const

template<typename _Scalar, int _Options, typename _StorageIndex>
StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::innerIndexPtr()

template<typename _Scalar, int _Options, typename _StorageIndex>
const StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::innerNonZeroPtr() const

template<typename _Scalar, int _Options, typename _StorageIndex>
StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::innerNonZeroPtr()

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::innerSize() const

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insert(Index row, Index col)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insert(Index i)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insertBack(Index i)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insertBackByOuterInner(Index outer, Index inner)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insertBackByOuterInnerUnordered(Index outer, Index inner)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::insertBackUnordered(Index i)

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::nonZeros() const

Returns the number of non zero coefficients

template<typename _Scalar, int _Options, typename _StorageIndex>
SparseVector& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::operator=(const SparseVector& other)

template<typename _Scalar, int _Options, typename _StorageIndex> template<typename OtherDerived>
SparseVector& Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::operator=(const SparseMatrixBase<OtherDerived>& other)

template<typename _Scalar, int _Options, typename _StorageIndex>
const StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::outerIndexPtr() const

template<typename _Scalar, int _Options, typename _StorageIndex>
StorageIndex* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::outerIndexPtr()

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::outerSize() const

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::prune(const Scalar& reference, const RealScalar& epsilon = NumTraits<RealScalar>::dummy_precision())

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

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::reserve(Index reserveSize)

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::resize(Index rows, Index cols)

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.

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::resize(Index newSize)

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

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::resizeNonZeros(Index size)

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::rows() const

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::setZero()

template<typename _Scalar, int _Options, typename _StorageIndex>
EIGEN_DEPRECATED void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::startFill(Index reserve)

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::startVec(Index outer)

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::sum() const

Overloaded for performance

template<typename _Scalar, int _Options, typename _StorageIndex>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::swap(SparseVector& other)

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

template<typename _Scalar, int _Options, typename _StorageIndex> template<int OtherOptions>
void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::swap(SparseMatrix<Scalar, OtherOptions, StorageIndex>& other)

template<typename _Scalar, int _Options, typename _StorageIndex>
const Scalar* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::valuePtr() const

template<typename _Scalar, int _Options, typename _StorageIndex>
Scalar* Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::valuePtr()

template<typename _Scalar, int _Options, typename _StorageIndex>
static void Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::check_template_parameters() protected

template<typename _Scalar, int _Options, typename _StorageIndex>
std::ostream& operator<<(std::ostream& s, const SparseVector& m)

Variable documentation

template<typename _Scalar, int _Options, typename _StorageIndex>
Storage Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::m_data protected

template<typename _Scalar, int _Options, typename _StorageIndex>
Index Eigen::SparseVector<_Scalar, _Options, _StorageIndex>::m_size protected