Eigen::SparseSelfAdjointView< MatrixType, Mode_ > Class Template Reference

Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix. More...

#include <SparseSelfAdjointView.h>

+ Inheritance diagram for Eigen::SparseSelfAdjointView< MatrixType, Mode_ >:

Public Types

enum  { Mode = Mode_ , TransposeMode = ((int(Mode) & int(Upper)) ? Lower : 0) | ((int(Mode) & int(Lower)) ? Upper : 0) , RowsAtCompileTime = internal::traits<SparseSelfAdjointView>::RowsAtCompileTime , ColsAtCompileTime = internal::traits<SparseSelfAdjointView>::ColsAtCompileTime }
 
typedef EigenBase< SparseSelfAdjointViewBase
 
typedef MatrixType::Scalar Scalar
 
typedef MatrixType::StorageIndex StorageIndex
 
typedef Matrix< StorageIndex, Dynamic, 1 > VectorI
 
typedef internal::ref_selector< MatrixType >::non_const_type MatrixTypeNested
 
typedef internal::remove_all_t< MatrixTypeNestedMatrixTypeNested_
 
- Public Types inherited from Eigen::EigenBase< SparseSelfAdjointView< MatrixType, Mode_ > >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< SparseSelfAdjointView< MatrixType, Mode_ > >::StorageKind StorageKind
 

Public Member Functions

 SparseSelfAdjointView (MatrixType &matrix)
 
Index rows () const
 
Index cols () const
 
const MatrixTypeNested_matrix () const
 
std::remove_reference_t< MatrixTypeNested > & matrix ()
 
template<typename OtherDerived >
Product< SparseSelfAdjointView, OtherDerived > operator* (const SparseMatrixBase< OtherDerived > &rhs) const
 
template<typename OtherDerived >
Product< SparseSelfAdjointView, OtherDerived > operator* (const MatrixBase< OtherDerived > &rhs) const
 
template<typename DerivedU >
SparseSelfAdjointViewrankUpdate (const SparseMatrixBase< DerivedU > &u, const Scalar &alpha=Scalar(1))
 
SparseSymmetricPermutationProduct< MatrixTypeNested_, ModetwistedBy (const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
 
template<typename SrcMatrixType , int SrcMode>
SparseSelfAdjointViewoperator= (const SparseSymmetricPermutationProduct< SrcMatrixType, SrcMode > &permutedMatrix)
 
SparseSelfAdjointViewoperator= (const SparseSelfAdjointView &src)
 
template<typename SrcMatrixType , unsigned int SrcMode>
SparseSelfAdjointViewoperator= (const SparseSelfAdjointView< SrcMatrixType, SrcMode > &src)
 
void resize (Index rows, Index cols)
 
template<typename DerivedU >
SparseSelfAdjointView< MatrixType, Mode > & rankUpdate (const SparseMatrixBase< DerivedU > &u, const Scalar &alpha)
 
- Public Member Functions inherited from Eigen::EigenBase< SparseSelfAdjointView< MatrixType, Mode_ > >
constexpr EIGEN_DEVICE_FUNC SparseSelfAdjointView< MatrixType, Mode_ > & derived ()
 
constexpr EIGEN_DEVICE_FUNC const SparseSelfAdjointView< MatrixType, Mode_ > & derived () const
 
EIGEN_DEVICE_FUNC SparseSelfAdjointView< MatrixType, Mode_ > & const_cast_derived () const
 
EIGEN_DEVICE_FUNC const SparseSelfAdjointView< MatrixType, Mode_ > & const_derived () const
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
EIGEN_DEVICE_FUNC void evalTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void addTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void subTo (Dest &dst) const
 
EIGEN_DEVICE_FUNC void applyThisOnTheRight (Dest &dst) const
 
EIGEN_DEVICE_FUNC void applyThisOnTheLeft (Dest &dst) const
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< SparseSelfAdjointView< MatrixType, Mode_ >, Device > device (Device &device)
 
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DeviceWrapper< const SparseSelfAdjointView< MatrixType, Mode_ >, Device > device (Device &device) const
 

Protected Attributes

MatrixTypeNested m_matrix
 

Private Member Functions

template<typename Dest >
void evalTo (Dest &) const
 

Friends

template<typename OtherDerived >
Product< OtherDerived, SparseSelfAdjointViewoperator* (const SparseMatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
 
template<typename OtherDerived >
Product< OtherDerived, SparseSelfAdjointViewoperator* (const MatrixBase< OtherDerived > &lhs, const SparseSelfAdjointView &rhs)
 

Detailed Description

template<typename MatrixType, unsigned int Mode_>
class Eigen::SparseSelfAdjointView< MatrixType, Mode_ >

Pseudo expression to manipulate a triangular sparse matrix as a selfadjoint matrix.

Parameters
MatrixTypethe type of the dense matrix storing the coefficients
Modecan be either Lower or Upper

This class is an expression of a sefladjoint matrix from a triangular part of a matrix with given dense storage of the coefficients. It is the return type of MatrixBase::selfadjointView() and most of the time this is the only way that it is used.

See also
SparseMatrixBase::selfadjointView()

Member Typedef Documentation

◆ Base

template<typename MatrixType , unsigned int Mode_>
typedef EigenBase<SparseSelfAdjointView> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::Base

◆ MatrixTypeNested

template<typename MatrixType , unsigned int Mode_>
typedef internal::ref_selector<MatrixType>::non_const_type Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::MatrixTypeNested

◆ MatrixTypeNested_

template<typename MatrixType , unsigned int Mode_>
typedef internal::remove_all_t<MatrixTypeNested> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::MatrixTypeNested_

◆ Scalar

template<typename MatrixType , unsigned int Mode_>
typedef MatrixType::Scalar Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::Scalar

◆ StorageIndex

template<typename MatrixType , unsigned int Mode_>
typedef MatrixType::StorageIndex Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::StorageIndex

◆ VectorI

template<typename MatrixType , unsigned int Mode_>
typedef Matrix<StorageIndex, Dynamic, 1> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::VectorI

Member Enumeration Documentation

◆ anonymous enum

template<typename MatrixType , unsigned int Mode_>
anonymous enum
Enumerator
Mode 
TransposeMode 
RowsAtCompileTime 
ColsAtCompileTime 
54  {
55  Mode = Mode_,
56  TransposeMode = ((int(Mode) & int(Upper)) ? Lower : 0) | ((int(Mode) & int(Lower)) ? Upper : 0),
57  RowsAtCompileTime = internal::traits<SparseSelfAdjointView>::RowsAtCompileTime,
58  ColsAtCompileTime = internal::traits<SparseSelfAdjointView>::ColsAtCompileTime
59  };
@ Mode
Definition: SparseSelfAdjointView.h:55
@ RowsAtCompileTime
Definition: SparseSelfAdjointView.h:57
@ TransposeMode
Definition: SparseSelfAdjointView.h:56
@ ColsAtCompileTime
Definition: SparseSelfAdjointView.h:58
@ Lower
Definition: Constants.h:211
@ Upper
Definition: Constants.h:213
return int(ret)+1

Constructor & Destructor Documentation

◆ SparseSelfAdjointView()

template<typename MatrixType , unsigned int Mode_>
Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::SparseSelfAdjointView ( MatrixType matrix)
inlineexplicit
68  : m_matrix(matrix) {
69  eigen_assert(rows() == cols() && "SelfAdjointView is only for squared matrices");
70  }
#define eigen_assert(x)
Definition: Macros.h:910
const MatrixTypeNested_ & matrix() const
Definition: SparseSelfAdjointView.h:76
Index cols() const
Definition: SparseSelfAdjointView.h:73
MatrixTypeNested m_matrix
Definition: SparseSelfAdjointView.h:163
Index rows() const
Definition: SparseSelfAdjointView.h:72

References Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::cols(), eigen_assert, and Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::rows().

Member Function Documentation

◆ cols()

◆ evalTo()

template<typename MatrixType , unsigned int Mode_>
template<typename Dest >
void Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::evalTo ( Dest &  ) const
private

◆ matrix() [1/2]

template<typename MatrixType , unsigned int Mode_>
std::remove_reference_t<MatrixTypeNested>& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::matrix ( )
inline

◆ matrix() [2/2]

◆ operator*() [1/2]

template<typename MatrixType , unsigned int Mode_>
template<typename OtherDerived >
Product<SparseSelfAdjointView, OtherDerived> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator* ( const MatrixBase< OtherDerived > &  rhs) const
inline

Efficient sparse self-adjoint matrix times dense vector/matrix product

106  {
107  return Product<SparseSelfAdjointView, OtherDerived>(*this, rhs.derived());
108  }

◆ operator*() [2/2]

template<typename MatrixType , unsigned int Mode_>
template<typename OtherDerived >
Product<SparseSelfAdjointView, OtherDerived> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator* ( const SparseMatrixBase< OtherDerived > &  rhs) const
inline
Returns
an expression of the matrix product between a sparse self-adjoint matrix *this and a sparse matrix rhs.

Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product. Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.

87  {
88  return Product<SparseSelfAdjointView, OtherDerived>(*this, rhs.derived());
89  }

References Eigen::SparseMatrixBase< Derived >::derived().

◆ operator=() [1/3]

template<typename MatrixType , unsigned int Mode_>
SparseSelfAdjointView& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator= ( const SparseSelfAdjointView< MatrixType, Mode_ > &  src)
inline
141  {
142  PermutationMatrix<Dynamic, Dynamic, StorageIndex> pnull;
143  return *this = src.twistedBy(pnull);
144  }

References Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::twistedBy().

◆ operator=() [2/3]

template<typename MatrixType , unsigned int Mode_>
template<typename SrcMatrixType , unsigned int SrcMode>
SparseSelfAdjointView& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator= ( const SparseSelfAdjointView< SrcMatrixType, SrcMode > &  src)
inline
150  {
151  PermutationMatrix<Dynamic, Dynamic, StorageIndex> pnull;
152  return *this = src.twistedBy(pnull);
153  }

References Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::twistedBy().

◆ operator=() [3/3]

template<typename MatrixType , unsigned int Mode_>
template<typename SrcMatrixType , int SrcMode>
SparseSelfAdjointView& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator= ( const SparseSymmetricPermutationProduct< SrcMatrixType, SrcMode > &  permutedMatrix)
inline
136  {
138  return *this;
139  }
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR void call_assignment_no_alias_no_transpose(Dst &dst, const Src &src, const Func &func)
Definition: AssignEvaluator.h:857

References Eigen::internal::call_assignment_no_alias_no_transpose().

◆ rankUpdate() [1/2]

template<typename MatrixType , unsigned int Mode_>
template<typename DerivedU >
SparseSelfAdjointView<MatrixType, Mode>& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::rankUpdate ( const SparseMatrixBase< DerivedU > &  u,
const Scalar alpha 
)
196  {
197  SparseMatrix<Scalar, (MatrixType::Flags & RowMajorBit) ? RowMajor : ColMajor> tmp = u * u.adjoint();
198  if (alpha == Scalar(0))
199  m_matrix = tmp.template triangularView<Mode>();
200  else
201  m_matrix += alpha * tmp.template triangularView<Mode>();
202 
203  return *this;
204 }
MatrixType::Scalar Scalar
Definition: SparseSelfAdjointView.h:62
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
const unsigned int RowMajorBit
Definition: Constants.h:70
RealScalar alpha
Definition: level1_cplx_impl.h:151
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365

References Eigen::SparseMatrixBase< Derived >::adjoint(), alpha, Eigen::ColMajor, Eigen::RowMajor, Eigen::RowMajorBit, and tmp.

◆ rankUpdate() [2/2]

template<typename MatrixType , unsigned int Mode_>
template<typename DerivedU >
SparseSelfAdjointView& Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::rankUpdate ( const SparseMatrixBase< DerivedU > &  u,
const Scalar alpha = Scalar(1) 
)

Perform a symmetric rank K update of the selfadjoint matrix *this: \( this = this + \alpha ( u u^* ) \) where u is a vector or matrix.

Returns
a reference to *this

To perform \( this = this + \alpha ( u^* u ) \) you can simply call this function with u.adjoint().

◆ resize()

template<typename MatrixType , unsigned int Mode_>
void Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::resize ( Index  rows,
Index  cols 
)
inline
155  {
158  eigen_assert(rows == this->rows() && cols == this->cols() &&
159  "SparseSelfadjointView::resize() does not actually allow to resize.");
160  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:922

References Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::cols(), eigen_assert, EIGEN_ONLY_USED_FOR_DEBUG, and Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::rows().

◆ rows()

◆ twistedBy()

template<typename MatrixType , unsigned int Mode_>
SparseSymmetricPermutationProduct<MatrixTypeNested_, Mode> Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::twistedBy ( const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &  perm) const
inline
Returns
an expression of P H P^-1
131  {
132  return SparseSymmetricPermutationProduct<MatrixTypeNested_, Mode>(m_matrix, perm);
133  }

References Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::m_matrix.

Referenced by Eigen::SparseSelfAdjointView< MatrixType, Mode_ >::operator=().

Friends And Related Function Documentation

◆ operator* [1/2]

template<typename MatrixType , unsigned int Mode_>
template<typename OtherDerived >
Product<OtherDerived, SparseSelfAdjointView> operator* ( const MatrixBase< OtherDerived > &  lhs,
const SparseSelfAdjointView< MatrixType, Mode_ > &  rhs 
)
friend

Efficient dense vector/matrix times sparse self-adjoint matrix product

113  {
114  return Product<OtherDerived, SparseSelfAdjointView>(lhs.derived(), rhs);
115  }

◆ operator* [2/2]

template<typename MatrixType , unsigned int Mode_>
template<typename OtherDerived >
Product<OtherDerived, SparseSelfAdjointView> operator* ( const SparseMatrixBase< OtherDerived > &  lhs,
const SparseSelfAdjointView< MatrixType, Mode_ > &  rhs 
)
friend
Returns
an expression of the matrix product between a sparse matrix lhs and a sparse self-adjoint matrix rhs.

Note that there is no algorithmic advantage of performing such a product compared to a general sparse-sparse matrix product. Indeed, the SparseSelfadjointView operand is first copied into a temporary SparseMatrix before computing the product.

100  {
101  return Product<OtherDerived, SparseSelfAdjointView>(lhs.derived(), rhs);
102  }

Member Data Documentation

◆ m_matrix


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