Eigen::SparseMatrixBase< Derived > Class Template Reference

Base class of any sparse matrices or sparse expressions. More...

+ Inheritance diagram for Eigen::SparseMatrixBase< Derived >:

Classes

struct  ConstSelfAdjointViewReturnType
 
struct  CwiseProductDenseReturnType
 
struct  SelfAdjointViewReturnType
 

Public Types

enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  SizeAtCompileTime ,
  MaxRowsAtCompileTime ,
  MaxColsAtCompileTime ,
  MaxSizeAtCompileTime ,
  IsVectorAtCompileTime ,
  NumDimensions ,
  Flags ,
  IsRowMajor ,
  InnerSizeAtCompileTime
}
 
typedef std::conditional_t< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const Derived > >, Transpose< const Derived > > AdjointReturnType
 
typedef Transpose< const Derived > 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< Derived >::Scalar Scalar
 
typedef Matrix< Scalar, Dynamic, 1 > ScalarVector
 
typedef SparseMatrixBase StorageBaseType
 
typedef internal::traits< Derived >::StorageIndex StorageIndex
 
typedef internal::traits< Derived >::StorageKind StorageKind
 
typedef Transpose< Derived > TransposeReturnType
 
typedef Scalar value_type
 
- Public Types inherited from Eigen::EigenBase< Derived >
typedef Eigen::Index Index
 The interface type of indices. More...
 
typedef internal::traits< Derived >::StorageKind StorageKind
 

Public Member Functions

const AdjointReturnType adjoint () const
 
RealScalar blueNorm () const
 
Index cols () const
 
template<typename OtherDerived >
const SparseMatrixBase< Derived >::template CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const CwiseProductDenseReturnType< OtherDerived >::Type cwiseProduct (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
internal::traits< Derived >::Scalar dot (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
internal::traits< Derived >::Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
Scalar dot (const SparseMatrixBase< OtherDerived > &other) const
 
const internal::eval< Derived >::type eval () const
 
Index innerSize () const
 
template<typename OtherDerived >
bool isApprox (const MatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename OtherDerived >
bool isApprox (const SparseMatrixBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isRValue () const
 
bool isVector () const
 
Derived & markAsRValue ()
 
RealScalar norm () const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived > operator* (const DiagonalBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived > operator* (const MatrixBase< OtherDerived > &other) const
 
template<typename OtherDerived >
const Product< Derived, OtherDerived, AliasFreeProductoperator* (const SparseMatrixBase< OtherDerived > &other) const
 
Derived & operator*= (const Scalar &other)
 
template<typename OtherDerived >
Derived & operator*= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const DiagonalBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const SparseMatrixBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const DiagonalBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const SparseMatrixBase< OtherDerived > &other)
 
Derived & operator/= (const Scalar &other)
 
Derived & operator= (const Derived &other)
 
template<typename OtherDerived >
Derived & operator= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const ReturnByValue< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const SparseMatrixBase< OtherDerived > &other)
 
Index outerSize () const
 
const SparseView< Derived > pruned (const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
 
Index rows () const
 
template<unsigned int UpLo>
SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
template<unsigned int UpLo>
SparseMatrixBase< Derived >::template SelfAdjointViewReturnType< UpLo >::Type selfadjointView ()
 
template<unsigned int UpLo>
ConstSelfAdjointViewReturnType< UpLo >::Type selfadjointView () const
 
template<unsigned int UpLo>
SparseMatrixBase< Derived >::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
 
template<int Mode>
const TriangularView< const Derived, Mode > triangularView () const
 
SparseSymmetricPermutationProduct< Derived, Upper|LowertwistedBy (const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &perm) const
 
- Public Member Functions inherited from Eigen::EigenBase< Derived >
template<typename Dest >
void addTo (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheLeft (Dest &dst) const
 
template<typename Dest >
void applyThisOnTheRight (Dest &dst) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & const_cast_derived () const
 
const Derived & const_derived () const
 
Derived & derived ()
 
const Derived & derived () const
 
template<typename Dest >
void evalTo (Dest &dst) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
template<typename Dest >
void subTo (Dest &dst) const
 

Protected Member Functions

template<typename OtherDerived >
Derived & assign (const OtherDerived &other)
 
template<typename OtherDerived >
void assignGeneric (const OtherDerived &other)
 

Static Protected Member Functions

static StorageIndex convert_index (const Index idx)
 

Protected Attributes

bool m_isRValue
 

Private Member Functions

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

Detailed Description

template<typename Derived>
class Eigen::SparseMatrixBase< Derived >

Base class of any sparse matrices or sparse expressions.

Template Parameters
Derivedis the derived type, e.g. a sparse matrix type, or an expression, etc.

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_SPARSEMATRIXBASE_PLUGIN.

Definition at line 28 of file SparseMatrixBase.h.

Member Typedef Documentation

◆ AdjointReturnType

template<typename Derived >
typedef std::conditional_t<NumTraits<Scalar>::IsComplex, CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Eigen::Transpose<const Derived> >, Transpose<const Derived> > Eigen::SparseMatrixBase< Derived >::AdjointReturnType

Definition at line 114 of file SparseMatrixBase.h.

◆ ConstTransposeReturnType

template<typename Derived >
typedef Transpose<const Derived> Eigen::SparseMatrixBase< Derived >::ConstTransposeReturnType

Definition at line 116 of file SparseMatrixBase.h.

◆ IndexVector

template<typename Derived >
typedef Matrix<StorageIndex,Dynamic,1> Eigen::SparseMatrixBase< Derived >::IndexVector

Definition at line 53 of file SparseMatrixBase.h.

◆ PacketReturnType

template<typename Derived >
typedef internal::add_const_on_value_type_if_arithmetic< typename internal::packet_traits<Scalar>::type >::type Eigen::SparseMatrixBase< Derived >::PacketReturnType

Definition at line 49 of file SparseMatrixBase.h.

◆ PacketScalar

template<typename Derived >
typedef internal::packet_traits<Scalar>::type Eigen::SparseMatrixBase< Derived >::PacketScalar

Definition at line 40 of file SparseMatrixBase.h.

◆ PlainObject

template<typename Derived >
typedef SparseMatrix<Scalar, Flags&RowMajorBit ? RowMajor : ColMajor, StorageIndex> Eigen::SparseMatrixBase< Derived >::PlainObject

Definition at line 119 of file SparseMatrixBase.h.

◆ Scalar

template<typename Derived >
typedef internal::traits<Derived>::Scalar Eigen::SparseMatrixBase< Derived >::Scalar

Definition at line 33 of file SparseMatrixBase.h.

◆ ScalarVector

template<typename Derived >
typedef Matrix<Scalar,Dynamic,1> Eigen::SparseMatrixBase< Derived >::ScalarVector

Definition at line 54 of file SparseMatrixBase.h.

◆ StorageBaseType

template<typename Derived >
typedef SparseMatrixBase Eigen::SparseMatrixBase< Derived >::StorageBaseType

Definition at line 51 of file SparseMatrixBase.h.

◆ StorageIndex

template<typename Derived >
typedef internal::traits<Derived>::StorageIndex Eigen::SparseMatrixBase< Derived >::StorageIndex

The integer type used to store indices within a SparseMatrix. For a SparseMatrix<Scalar,Options,IndexType> it an alias of the third template parameter IndexType.

Definition at line 45 of file SparseMatrixBase.h.

◆ StorageKind

template<typename Derived >
typedef internal::traits<Derived>::StorageKind Eigen::SparseMatrixBase< Derived >::StorageKind

Definition at line 41 of file SparseMatrixBase.h.

◆ TransposeReturnType

template<typename Derived >
typedef Transpose<Derived> Eigen::SparseMatrixBase< Derived >::TransposeReturnType

Definition at line 115 of file SparseMatrixBase.h.

◆ value_type

template<typename Derived >
typedef Scalar Eigen::SparseMatrixBase< Derived >::value_type

The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc.

It is an alias for the Scalar type

Definition at line 38 of file SparseMatrixBase.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
RowsAtCompileTime 

The number of rows at compile-time. This is just a copy of the value provided by the Derived type. If a value is not known at compile-time, it is set to the Dynamic constant.

See also
MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime
ColsAtCompileTime 

The number of columns at compile-time. This is just a copy of the value provided by the Derived type. If a value is not known at compile-time, it is set to the Dynamic constant.

See also
MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime
SizeAtCompileTime 

This is equal to the number of coefficients, i.e. the number of rows times the number of columns, or to Dynamic if this is not known at compile-time.

See also
RowsAtCompileTime, ColsAtCompileTime
MaxRowsAtCompileTime 
MaxColsAtCompileTime 
MaxSizeAtCompileTime 
IsVectorAtCompileTime 

This is set to true if either the number of rows or the number of columns is known at compile-time to be equal to 1. Indeed, in that case, we are dealing with a column-vector (if there is only one column) or with a row-vector (if there is only one row).

NumDimensions 

This value is equal to Tensor::NumDimensions, i.e. 0 for scalars, 1 for vectors, and 2 for matrices.

Flags 

This stores expression Flags flags which may or may not be inherited by new expressions constructed from this one. See the list of flags.

IsRowMajor 
InnerSizeAtCompileTime 

Definition at line 59 of file SparseMatrixBase.h.

59  {
60 
61  RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
67  ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
74  SizeAtCompileTime = (internal::size_of_xpr_at_compile_time<Derived>::ret),
81 
83 
95  Flags = internal::traits<Derived>::Flags,
100  IsRowMajor = Flags&RowMajorBit ? 1 : 0,
101 
103  : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
104 
105  #ifndef EIGEN_PARSED_BY_DOXYGEN
106  HasDirectAccess_ = (int(Flags)&DirectAccessBit) ? 1 : 0 // workaround sunCC
107  #endif
108  };
const unsigned int DirectAccessBit
Definition: Constants.h:157
const unsigned int RowMajorBit
Definition: Constants.h:68
constexpr int size_at_compile_time(int rows, int cols)
Definition: XprHelper.h:313

Constructor & Destructor Documentation

◆ SparseMatrixBase()

template<typename Derived >
Eigen::SparseMatrixBase< Derived >::SparseMatrixBase ( )
inline

Definition at line 197 of file SparseMatrixBase.h.

197 : m_isRValue(false) { /* TODO check flags */ }

Member Function Documentation

◆ adjoint()

template<typename Derived >
const AdjointReturnType Eigen::SparseMatrixBase< Derived >::adjoint ( ) const
inline

Definition at line 357 of file SparseMatrixBase.h.

357 { return AdjointReturnType(transpose()); }
std::conditional_t< NumTraits< Scalar >::IsComplex, CwiseUnaryOp< internal::scalar_conjugate_op< Scalar >, Eigen::Transpose< const Derived > >, Transpose< const Derived > > AdjointReturnType
TransposeReturnType transpose()

◆ assign()

template<typename Derived >
template<typename OtherDerived >
Derived& Eigen::SparseMatrixBase< Derived >::assign ( const OtherDerived &  other)
inlineprotected

◆ assignGeneric()

template<typename Derived >
template<typename OtherDerived >
void Eigen::SparseMatrixBase< Derived >::assignGeneric ( const OtherDerived &  other)
inlineprotected

◆ blueNorm()

template<typename Derived >
NumTraits< typename internal::traits< Derived >::Scalar >::Real Eigen::SparseMatrixBase< Derived >::blueNorm
inline

Definition at line 94 of file SparseDot.h.

95 {
96  return internal::blueNorm_impl(*this);
97 }
NumTraits< typename traits< Derived >::Scalar >::Real blueNorm_impl(const EigenBase< Derived > &_vec)
Definition: StableNorm.h:122

◆ cols()

template<typename Derived >
Index Eigen::SparseMatrixBase< Derived >::cols ( void  ) const
inline
Returns
the number of columns.
See also
rows()

Definition at line 178 of file SparseMatrixBase.h.

178 { return derived().cols(); }
Derived & derived()
Definition: EigenBase.h:48

◆ convert_index()

template<typename Derived >
static StorageIndex Eigen::SparseMatrixBase< Derived >::convert_index ( const Index  idx)
inlinestaticprotected

Definition at line 390 of file SparseMatrixBase.h.

390  {
391  return internal::convert_index<StorageIndex>(idx);
392  }

◆ cwiseProduct() [1/2]

template<typename Derived >
template<typename OtherDerived >
const SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type Eigen::SparseMatrixBase< Derived >::cwiseProduct ( const MatrixBase< OtherDerived > &  other) const
inline

Definition at line 965 of file SparseCwiseBinaryOp.h.

966 {
967  return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
968 }
CwiseBinaryOp< internal::scalar_product_op< typename ScalarBinaryOpTraits< typename internal::traits< Derived >::Scalar, typename internal::traits< OtherDerived >::Scalar >::ReturnType >, const Derived, const OtherDerived > Type

◆ cwiseProduct() [2/2]

template<typename Derived >
template<typename OtherDerived >
const CwiseProductDenseReturnType<OtherDerived>::Type Eigen::SparseMatrixBase< Derived >::cwiseProduct ( const MatrixBase< OtherDerived > &  other) const
inline

◆ dot() [1/4]

template<typename Derived >
template<typename OtherDerived >
internal::traits<Derived>::Scalar Eigen::SparseMatrixBase< Derived >::dot ( const MatrixBase< OtherDerived > &  other) const

Definition at line 20 of file SparseDot.h.

21 {
24  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
25  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
26  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
27 
28  eigen_assert(size() == other.size());
29  eigen_assert(other.size()>0 && "you are using a non initialized vector");
30 
31  internal::evaluator<Derived> thisEval(derived());
32  typename internal::evaluator<Derived>::InnerIterator i(thisEval, 0);
33  Scalar res(0);
34  while (i)
35  {
36  res += numext::conj(i.value()) * other.coeff(i.index());
37  ++i;
38  }
39  return res;
40 }
#define eigen_assert(x)
Definition: Macros.h:902
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:61
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
internal::traits< Derived >::Scalar Scalar
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_conjugate_op< typename Derived::Scalar >, const Derived > conj(const Eigen::ArrayBase< Derived > &x)

◆ dot() [2/4]

template<typename Derived >
template<typename OtherDerived >
Scalar Eigen::SparseMatrixBase< Derived >::dot ( const MatrixBase< OtherDerived > &  other) const

◆ dot() [3/4]

template<typename Derived >
template<typename OtherDerived >
internal::traits<Derived>::Scalar Eigen::SparseMatrixBase< Derived >::dot ( const SparseMatrixBase< OtherDerived > &  other) const

Definition at line 45 of file SparseDot.h.

46 {
49  EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived)
50  EIGEN_STATIC_ASSERT((internal::is_same<Scalar, typename OtherDerived::Scalar>::value),
51  YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
52 
53  eigen_assert(size() == other.size());
54 
55  internal::evaluator<Derived> thisEval(derived());
56  typename internal::evaluator<Derived>::InnerIterator i(thisEval, 0);
57 
58  internal::evaluator<OtherDerived> otherEval(other.derived());
59  typename internal::evaluator<OtherDerived>::InnerIterator j(otherEval, 0);
60 
61  Scalar res(0);
62  while (i && j)
63  {
64  if (i.index()==j.index())
65  {
66  res += numext::conj(i.value()) * j.value();
67  ++i; ++j;
68  }
69  else if (i.index()<j.index())
70  ++i;
71  else
72  ++j;
73  }
74  return res;
75 }
std::ptrdiff_t j

◆ dot() [4/4]

template<typename Derived >
template<typename OtherDerived >
Scalar Eigen::SparseMatrixBase< Derived >::dot ( const SparseMatrixBase< OtherDerived > &  other) const

◆ eval()

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

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

Definition at line 378 of file SparseMatrixBase.h.

379  { return typename internal::eval<Derived>::type(derived()); }

◆ evalTo()

template<typename Derived >
template<typename Dest >
void Eigen::SparseMatrixBase< Derived >::evalTo ( Dest &  ) const
private

◆ innerSize()

template<typename Derived >
Index Eigen::SparseMatrixBase< Derived >::innerSize ( ) const
inline
Returns
the size of the inner dimension according to the storage order, i.e., the number of rows for a columns major matrix, and the number of cols otherwise

Definition at line 192 of file SparseMatrixBase.h.

192 { return (int(Flags)&RowMajorBit) ? this->cols() : this->rows(); }

◆ isApprox() [1/2]

template<typename Derived >
template<typename OtherDerived >
bool Eigen::SparseMatrixBase< Derived >::isApprox ( const MatrixBase< OtherDerived > &  other,
const RealScalar &  prec = NumTraits<Scalar>::dummy_precision() 
) const
inline

Definition at line 369 of file SparseMatrixBase.h.

371  { return toDense().isApprox(other,prec); }
DenseMatrixType toDense() const

◆ isApprox() [2/2]

template<typename Derived >
template<typename OtherDerived >
bool Eigen::SparseMatrixBase< Derived >::isApprox ( const SparseMatrixBase< OtherDerived > &  other,
const RealScalar &  prec = NumTraits<Scalar>::dummy_precision() 
) const

Definition at line 19 of file SparseFuzzy.h.

20 {
21  const typename internal::nested_eval<Derived,2,PlainObject>::type actualA(derived());
22  std::conditional_t<bool(IsRowMajor)==bool(OtherDerived::IsRowMajor),
23  const typename internal::nested_eval<OtherDerived,2,PlainObject>::type,
24  const PlainObject> actualB(other.derived());
25 
26  return (actualA - actualB).squaredNorm() <= prec * prec * numext::mini(actualA.squaredNorm(), actualB.squaredNorm());
27 }
SparseMatrix< Scalar, Flags &RowMajorBit ? RowMajor :ColMajor, StorageIndex > PlainObject
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)

◆ isRValue()

template<typename Derived >
bool Eigen::SparseMatrixBase< Derived >::isRValue ( ) const
inline

Definition at line 194 of file SparseMatrixBase.h.

194 { return m_isRValue; }

◆ isVector()

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

Definition at line 186 of file SparseMatrixBase.h.

186 { return rows()==1 || cols()==1; }

◆ markAsRValue()

template<typename Derived >
Derived& Eigen::SparseMatrixBase< Derived >::markAsRValue ( )
inline

Definition at line 195 of file SparseMatrixBase.h.

195 { m_isRValue = true; return derived(); }

◆ norm()

template<typename Derived >
NumTraits< typename internal::traits< Derived >::Scalar >::Real Eigen::SparseMatrixBase< Derived >::norm
inline

Definition at line 86 of file SparseDot.h.

87 {
88  using std::sqrt;
89  return sqrt(squaredNorm());
90 }
const SqrtReturnType sqrt() const
RealScalar squaredNorm() const
Definition: SparseDot.h:79
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_sqrt_op< typename Derived::Scalar >, const Derived > sqrt(const Eigen::ArrayBase< Derived > &x)

◆ operator*() [1/3]

template<typename Derived >
template<typename OtherDerived >
const Product<Derived,OtherDerived> Eigen::SparseMatrixBase< Derived >::operator* ( const DiagonalBase< OtherDerived > &  other) const
inline

Definition at line 303 of file SparseMatrixBase.h.

304  { return Product<Derived,OtherDerived>(derived(), other.derived()); }

◆ operator*() [2/3]

template<typename Derived >
template<typename OtherDerived >
const Product<Derived,OtherDerived> Eigen::SparseMatrixBase< Derived >::operator* ( const MatrixBase< OtherDerived > &  other) const
inline

Definition at line 320 of file SparseMatrixBase.h.

321  { return Product<Derived,OtherDerived>(derived(), other.derived()); }

◆ operator*() [3/3]

template<typename Derived >
template<typename OtherDerived >
const Product< Derived, OtherDerived, AliasFreeProduct > Eigen::SparseMatrixBase< Derived >::operator* ( const SparseMatrixBase< OtherDerived > &  other) const
inline
Returns
an expression of the product of two sparse matrices. By default a conservative product preserving the symbolic non zeros is performed. The automatic pruning of the small values can be achieved by calling the pruned() function in which case a totally different product algorithm is employed:
C = (A*B).pruned(); // suppress numerical zeros (exact)
C = (A*B).pruned(ref);
C = (A*B).pruned(ref,epsilon);
MatrixXcf A
MatrixXf B
const SparseView< Derived > pruned(const Scalar &reference=Scalar(0), const RealScalar &epsilon=NumTraits< Scalar >::dummy_precision()) const
Definition: SparseView.h:248
where ref is a meaningful non zero reference value.

Definition at line 31 of file SparseProduct.h.

32 {
33  return Product<Derived,OtherDerived,AliasFreeProduct>(derived(), other.derived());
34 }

◆ operator*=() [1/2]

template<typename Derived >
Derived & Eigen::SparseMatrixBase< Derived >::operator*= ( const Scalar other)
inline

Definition at line 128 of file SparseCwiseUnaryOp.h.

129 {
130  typedef typename internal::evaluator<Derived>::InnerIterator EvalIterator;
131  internal::evaluator<Derived> thisEval(derived());
132  for (Index j=0; j<outerSize(); ++j)
133  for (EvalIterator i(thisEval,j); i; ++i)
134  i.valueRef() *= other;
135  return derived();
136 }
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41

◆ operator*=() [2/2]

template<typename Derived >
template<typename OtherDerived >
Derived& Eigen::SparseMatrixBase< Derived >::operator*= ( const SparseMatrixBase< OtherDerived > &  other)

◆ operator+=() [1/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator+= ( const DiagonalBase< OtherDerived > &  other)

Definition at line 948 of file SparseCwiseBinaryOp.h.

949 {
950  call_assignment_no_alias(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
951  return derived();
952 }
EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)

◆ operator+=() [2/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator+= ( const EigenBase< OtherDerived > &  other)

Implementation of SparseMatrixBase and SparseCwise functions/operators

Definition at line 916 of file SparseCwiseBinaryOp.h.

917 {
918  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
919  return derived();
920 }
void call_assignment(Dst &dst, const Src &src)

◆ operator+=() [3/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator+= ( const SparseMatrixBase< OtherDerived > &  other)
inline

Definition at line 941 of file SparseCwiseBinaryOp.h.

942 {
943  return derived() = derived() + other.derived();
944 }

◆ operator-=() [1/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator-= ( const DiagonalBase< OtherDerived > &  other)

Definition at line 956 of file SparseCwiseBinaryOp.h.

957 {
958  call_assignment_no_alias(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
959  return derived();
960 }

◆ operator-=() [2/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator-= ( const EigenBase< OtherDerived > &  other)

Definition at line 924 of file SparseCwiseBinaryOp.h.

925 {
926  call_assignment(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
927  return derived();
928 }

◆ operator-=() [3/3]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator-= ( const SparseMatrixBase< OtherDerived > &  other)
inline

Definition at line 933 of file SparseCwiseBinaryOp.h.

934 {
935  return derived() = derived() - other.derived();
936 }

◆ operator/=()

template<typename Derived >
Derived & Eigen::SparseMatrixBase< Derived >::operator/= ( const Scalar other)
inline

Definition at line 140 of file SparseCwiseUnaryOp.h.

141 {
142  typedef typename internal::evaluator<Derived>::InnerIterator EvalIterator;
143  internal::evaluator<Derived> thisEval(derived());
144  for (Index j=0; j<outerSize(); ++j)
145  for (EvalIterator i(thisEval,j); i; ++i)
146  i.valueRef() /= other;
147  return derived();
148 }

◆ operator=() [1/4]

template<typename Derived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( const Derived &  other)
inline

Definition at line 45 of file SparseAssign.h.

46 {
47  internal::call_assignment_no_alias(derived(), other.derived());
48  return derived();
49 }

◆ operator=() [2/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( const EigenBase< OtherDerived > &  other)

Definition at line 19 of file SparseAssign.h.

20 {
21  internal::call_assignment_no_alias(derived(), other.derived());
22  return derived();
23 }

◆ operator=() [3/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( const ReturnByValue< OtherDerived > &  other)

Definition at line 27 of file SparseAssign.h.

28 {
29  // TODO use the evaluator mechanism
30  other.evalTo(derived());
31  return derived();
32 }

◆ operator=() [4/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::SparseMatrixBase< Derived >::operator= ( const SparseMatrixBase< OtherDerived > &  other)
inline

Definition at line 36 of file SparseAssign.h.

37 {
38  // by default sparse evaluation do not alias, so we can safely bypass the generic call_assignment routine
39  internal::Assignment<Derived,OtherDerived,internal::assign_op<Scalar,typename OtherDerived::Scalar> >
40  ::run(derived(), other.derived(), internal::assign_op<Scalar,typename OtherDerived::Scalar>());
41  return derived();
42 }

◆ outerSize()

template<typename Derived >
Index Eigen::SparseMatrixBase< Derived >::outerSize ( ) const
inline
Returns
the size of the storage major dimension, i.e., the number of columns for a columns major matrix, and the number of rows otherwise

Definition at line 189 of file SparseMatrixBase.h.

189 { return (int(Flags)&RowMajorBit) ? this->rows() : this->cols(); }

◆ pruned()

template<typename Derived >
const SparseView< Derived > Eigen::SparseMatrixBase< Derived >::pruned ( const Scalar reference = Scalar(0),
const RealScalar &  epsilon = NumTraits<Scalar>::dummy_precision() 
) const
inline
Returns
an expression of *this with values smaller than reference * epsilon removed.

This method is typically used in conjunction with the product of two sparse matrices to automatically prune the smallest values as follows:

C = (A*B).pruned(); // suppress numerical zeros (exact)
C = (A*B).pruned(ref);
C = (A*B).pruned(ref,epsilon);

where ref is a meaningful non zero reference value.

Definition at line 248 of file SparseView.h.

250 {
251  return SparseView<Derived>(derived(), reference, epsilon);
252 }

◆ rows()

template<typename Derived >
Index Eigen::SparseMatrixBase< Derived >::rows ( void  ) const
inline
Returns
the number of rows.
See also
cols()

Definition at line 176 of file SparseMatrixBase.h.

176 { return derived().rows(); }

◆ selfadjointView() [1/4]

template<typename Derived >
template<unsigned int UpLo>
SelfAdjointViewReturnType<UpLo>::Type Eigen::SparseMatrixBase< Derived >::selfadjointView ( )
inline

◆ selfadjointView() [2/4]

template<typename Derived >
template<unsigned int UpLo>
SparseMatrixBase<Derived>::template SelfAdjointViewReturnType<UpLo>::Type Eigen::SparseMatrixBase< Derived >::selfadjointView ( )

Definition at line 187 of file SparseSelfAdjointView.h.

188 {
189  return SparseSelfAdjointView<Derived, UpLo>(derived());
190 }

◆ selfadjointView() [3/4]

template<typename Derived >
template<unsigned int UpLo>
ConstSelfAdjointViewReturnType<UpLo>::Type Eigen::SparseMatrixBase< Derived >::selfadjointView ( ) const
inline

◆ selfadjointView() [4/4]

template<typename Derived >
template<unsigned int UpLo>
SparseMatrixBase<Derived>::template ConstSelfAdjointViewReturnType<UpLo>::Type Eigen::SparseMatrixBase< Derived >::selfadjointView ( ) const

Implementation of SparseMatrixBase methods

Definition at line 180 of file SparseSelfAdjointView.h.

181 {
182  return SparseSelfAdjointView<const Derived, UpLo>(derived());
183 }

◆ size()

template<typename Derived >
Index Eigen::SparseMatrixBase< Derived >::size ( ) const
inline
Returns
the number of coefficients, which is rows()*cols().
See also
rows(), cols().

Definition at line 181 of file SparseMatrixBase.h.

181 { return rows() * cols(); }

◆ squaredNorm()

template<typename Derived >
NumTraits< typename internal::traits< Derived >::Scalar >::Real Eigen::SparseMatrixBase< Derived >::squaredNorm
inline

Definition at line 79 of file SparseDot.h.

80 {
81  return numext::real((*this).cwiseAbs2().sum());
82 }
RealReturnType real() const

◆ sum()

template<typename Derived >
internal::traits< Derived >::Scalar Eigen::SparseMatrixBase< Derived >::sum

Definition at line 19 of file SparseRedux.h.

20 {
21  eigen_assert(rows()>0 && cols()>0 && "you are using a non initialized matrix");
22  Scalar res(0);
23  internal::evaluator<Derived> thisEval(derived());
24  for (Index j=0; j<outerSize(); ++j)
25  for (typename internal::evaluator<Derived>::InnerIterator iter(thisEval,j); iter; ++iter)
26  res += iter.value();
27  return res;
28 }

◆ toDense()

template<typename Derived >
DenseMatrixType Eigen::SparseMatrixBase< Derived >::toDense ( ) const
inline

Definition at line 359 of file SparseMatrixBase.h.

360  {
361  return DenseMatrixType(derived());
362  }

◆ transpose() [1/2]

template<typename Derived >
TransposeReturnType Eigen::SparseMatrixBase< Derived >::transpose ( )
inline

Definition at line 355 of file SparseMatrixBase.h.

355 { return TransposeReturnType(derived()); }
Transpose< Derived > TransposeReturnType

◆ transpose() [2/2]

template<typename Derived >
const ConstTransposeReturnType Eigen::SparseMatrixBase< Derived >::transpose ( ) const
inline

Definition at line 356 of file SparseMatrixBase.h.

356 { return ConstTransposeReturnType(derived()); }
Transpose< const Derived > ConstTransposeReturnType

◆ triangularView()

template<typename Derived >
template<int Mode>
const TriangularView< const Derived, Mode > Eigen::SparseMatrixBase< Derived >::triangularView
inline

Definition at line 184 of file SparseTriangularView.h.

185 {
186  return TriangularView<const Derived, Mode>(derived());
187 }

◆ twistedBy()

template<typename Derived >
SparseSymmetricPermutationProduct<Derived,Upper|Lower> Eigen::SparseMatrixBase< Derived >::twistedBy ( const PermutationMatrix< Dynamic, Dynamic, StorageIndex > &  perm) const
inline
Returns
an expression of P H P^-1 where H is the matrix represented by *this

Definition at line 330 of file SparseMatrixBase.h.

331  {
332  return SparseSymmetricPermutationProduct<Derived,Upper|Lower>(derived(), perm);
333  }

Member Data Documentation

◆ m_isRValue

template<typename Derived >
bool Eigen::SparseMatrixBase< Derived >::m_isRValue
protected

Definition at line 388 of file SparseMatrixBase.h.


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