Eigen::DenseBase< Derived > Class Template Reference

Base class for all dense matrices, vectors, and arrays. More...

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

Public Types

enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  SizeAtCompileTime ,
  MaxRowsAtCompileTime ,
  MaxColsAtCompileTime ,
  MaxSizeAtCompileTime ,
  IsVectorAtCompileTime ,
  NumDimensions ,
  Flags ,
  IsRowMajor ,
  InnerSizeAtCompileTime ,
  InnerStrideAtCompileTime ,
  OuterStrideAtCompileTime
}
 
enum  { IsPlainObjectBase }
 
typedef DenseCoeffsBase< Derived, internal::accessors_level< Derived >::valueBase
 
typedef Base::CoeffReturnType CoeffReturnType
 
typedef VectorwiseOp< Derived, VerticalColwiseReturnType
 
typedef random_access_iterator_type const_iterator
 
typedef const VectorwiseOp< const Derived, VerticalConstColwiseReturnType
 
typedef const Reverse< const Derived, BothDirectionsConstReverseReturnType
 
typedef const VectorwiseOp< const Derived, HorizontalConstRowwiseReturnType
 
typedef Transpose< const Derived > ConstTransposeReturnType
 
typedef internal::add_const_on_value_type_t< typename internal::eval< Derived >::type > EvalReturnType
 
typedef random_access_iterator_type iterator
 
typedef internal::find_best_packet< Scalar, SizeAtCompileTime >::type PacketScalar
 
typedef Array< typename internal::traits< Derived >::Scalar, internal::traits< Derived >::RowsAtCompileTime, internal::traits< Derived >::ColsAtCompileTime, AutoAlign|(internal::traits< Derived >::Flags &RowMajorBit ? RowMajor :ColMajor), internal::traits< Derived >::MaxRowsAtCompileTime, internal::traits< Derived >::MaxColsAtCompileTimePlainArray
 
typedef Matrix< typename internal::traits< Derived >::Scalar, internal::traits< Derived >::RowsAtCompileTime, internal::traits< Derived >::ColsAtCompileTime, AutoAlign|(internal::traits< Derived >::Flags &RowMajorBit ? RowMajor :ColMajor), internal::traits< Derived >::MaxRowsAtCompileTime, internal::traits< Derived >::MaxColsAtCompileTimePlainMatrix
 
typedef std::conditional_t< internal::is_same< typename internal::traits< Derived >::XprKind, MatrixXpr >::value, PlainMatrix, PlainArrayPlainObject
 The plain matrix or array type corresponding to this expression. More...
 
typedef CwiseNullaryOp< internal::scalar_random_op< Scalar >, PlainObjectRandomReturnType
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef Reverse< Derived, BothDirectionsReverseReturnType
 
typedef VectorwiseOp< Derived, HorizontalRowwiseReturnType
 
typedef internal::traits< Derived >::Scalar Scalar
 
typedef internal::traits< Derived >::StorageIndex StorageIndex
 The type used to store indices. More...
 
typedef internal::traits< Derived >::StorageKind StorageKind
 
typedef Transpose< Derived > TransposeReturnType
 
typedef Scalar value_type
 
- Public Types inherited from Eigen::DenseCoeffsBase< Derived, DirectWriteAccessors >
typedef DenseCoeffsBase< Derived, WriteAccessorsBase
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::traits< Derived >::Scalar Scalar
 
- Public Types inherited from Eigen::DenseCoeffsBase< Derived, WriteAccessors >
typedef DenseCoeffsBase< Derived, ReadOnlyAccessorsBase
 
typedef internal::packet_traits< Scalar >::type PacketScalar
 
typedef NumTraits< Scalar >::Real RealScalar
 
typedef internal::traits< Derived >::Scalar Scalar
 
typedef internal::traits< Derived >::StorageKind StorageKind
 
- Public Types inherited from Eigen::DenseCoeffsBase< Derived, ReadOnlyAccessors >
typedef EigenBase< Derived > Base
 
typedef std::conditional_t< bool(internal::traits< Derived >::Flags &LvalueBit), const Scalar &, std::conditional_t< internal::is_arithmetic< Scalar >::value, Scalar, const Scalar > > CoeffReturnType
 
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 internal::traits< Derived >::Scalar Scalar
 
typedef internal::traits< Derived >::StorageKind StorageKind
 
- 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

bool all () const
 
bool allFinite () const
 
bool any () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
ColwiseReturnType colwise ()
 
ConstColwiseReturnType colwise () const
 
Index count () const
 
iterator end ()
 
const_iterator end () const
 
EvalReturnType eval () const
 
template<typename Dest >
void evalTo (Dest &) const
 
void fill (const Scalar &value)
 
template<unsigned int Added, unsigned int Removed>
EIGEN_DEPRECATED const Derived & flagged () const
 
ForceAlignedAccess< Derived > forceAlignedAccess ()
 
const ForceAlignedAccess< Derived > forceAlignedAccess () const
 
template<bool Enable>
std::conditional_t< Enable, ForceAlignedAccess< Derived >, Derived & > forceAlignedAccessIf ()
 
template<bool Enable>
const std::conditional_t< Enable, ForceAlignedAccess< Derived >, Derived & > forceAlignedAccessIf () const
 
const WithFormat< Derived > format (const IOFormat &fmt) const
 
bool hasNaN () const
 
EIGEN_CONSTEXPR Index innerSize () const
 
template<typename OtherDerived >
bool isApprox (const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isApproxToConstant (const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isConstant (const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename OtherDerived >
bool isMuchSmallerThan (const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isMuchSmallerThan (const RealScalar &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename Derived >
bool isMuchSmallerThan (const typename NumTraits< Scalar >::Real &other, const RealScalar &prec) const
 
bool isOnes (const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
bool isZero (const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
 
template<typename OtherDerived >
Derived & lazyAssign (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
EIGEN_DEPRECATED Derived & lazyAssign (const DenseBase< OtherDerived > &other)
 
template<int p>
RealScalar lpNorm () const
 
template<int NaNPropagation>
internal::traits< Derived >::Scalar maxCoeff () const
 
internal::traits< Derived >::Scalar maxCoeff () const
 
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar maxCoeff (IndexType *index) const
 
template<typename IndexType >
internal::traits< Derived >::Scalar maxCoeff (IndexType *index) const
 
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar maxCoeff (IndexType *row, IndexType *col) const
 
template<typename IndexType >
internal::traits< Derived >::Scalar maxCoeff (IndexType *row, IndexType *col) const
 
Scalar mean () const
 
template<int NaNPropagation>
internal::traits< Derived >::Scalar minCoeff () const
 
internal::traits< Derived >::Scalar minCoeff () const
 
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar minCoeff (IndexType *index) const
 
template<typename IndexType >
internal::traits< Derived >::Scalar minCoeff (IndexType *index) const
 
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar minCoeff (IndexType *row, IndexType *col) const
 
template<typename IndexType >
internal::traits< Derived >::Scalar minCoeff (IndexType *row, IndexType *col) const
 
const NestByValue< Derived > nestByValue () const
 
Derived & operator*= (const Scalar &other)
 
template<typename OtherDerived >
Derived & operator+= (const EigenBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const EigenBase< OtherDerived > &other)
 
Derived & operator/= (const Scalar &other)
 
template<typename OtherDerived >
CommaInitializer< Derived > operator<< (const DenseBase< OtherDerived > &other)
 
CommaInitializer< Derived > operator<< (const Scalar &s)
 
Derived & operator= (const DenseBase &other)
 
template<typename OtherDerived >
Derived & operator= (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator= (const EigenBase< OtherDerived > &other)
 Copies the generic expression other into *this. More...
 
template<typename OtherDerived >
Derived & operator= (const ReturnByValue< OtherDerived > &func)
 
EIGEN_CONSTEXPR Index outerSize () const
 
Scalar prod () const
 
template<typename BinaryOp >
Scalar redux (const BinaryOp &func) const
 
template<typename Func >
internal::traits< Derived >::Scalar redux (const Func &func) const
 
template<int RowFactor, int ColFactor>
const Replicate< Derived, RowFactor, ColFactor > replicate () const
 
const Replicate< Derived, Dynamic, Dynamicreplicate (Index rowFactor, Index colFactor) const
 
void resize (Index newSize)
 
void resize (Index rows, Index cols)
 
ReverseReturnType reverse ()
 
ConstReverseReturnType reverse () const
 
void reverseInPlace ()
 
RowwiseReturnType rowwise ()
 
ConstRowwiseReturnType rowwise () const
 
template<typename ThenDerived , typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenDerived >::Scalar, typename DenseBase< ElseDerived >::Scalar, Scalar >, ThenDerived, ElseDerived, Derived > select (const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const
 
template<typename ThenDerived , typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenDerived >::Scalar, typename DenseBase< ElseDerived >::Scalar, typename DenseBase< Derived >::Scalar >, ThenDerived, ElseDerived, Derived > select (const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const
 
template<typename ThenDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenDerived >::Scalar, typename DenseBase< ThenDerived >::Scalar, Scalar >, ThenDerived, typename DenseBase< ThenDerived >::ConstantReturnType, Derived > select (const DenseBase< ThenDerived > &thenMatrix, const typename DenseBase< ThenDerived >::Scalar &elseScalar) const
 
template<typename ThenDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenDerived >::Scalar, typename DenseBase< ThenDerived >::Scalar, typename DenseBase< Derived >::Scalar >, ThenDerived, typename DenseBase< ThenDerived >::ConstantReturnType, Derived > select (const DenseBase< ThenDerived > &thenMatrix, const typename DenseBase< ThenDerived >::Scalar &elseScalar) const
 
template<typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ElseDerived >::Scalar, typename DenseBase< ElseDerived >::Scalar, Scalar >, typename DenseBase< ElseDerived >::ConstantReturnType, ElseDerived, Derived > select (const typename DenseBase< ElseDerived >::Scalar &thenScalar, const DenseBase< ElseDerived > &elseMatrix) const
 
template<typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ElseDerived >::Scalar, typename DenseBase< ElseDerived >::Scalar, typename DenseBase< Derived >::Scalar >, typename DenseBase< ElseDerived >::ConstantReturnType, ElseDerived, Derived > select (const typename DenseBase< ElseDerived >::Scalar &thenScalar, const DenseBase< ElseDerived > &elseMatrix) const
 
Derived & setConstant (const Scalar &value)
 
Derived & setEqualSpaced (const Scalar &low, const Scalar &step)
 
Derived & setEqualSpaced (Index size, const Scalar &low, const Scalar &step)
 
Derived & setLinSpaced (const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector. More...
 
Derived & setLinSpaced (Index size, const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector. More...
 
Derived & setOnes ()
 
Derived & setRandom ()
 
Derived & setZero ()
 
Scalar sum () const
 
template<typename OtherDerived >
void swap (const DenseBase< OtherDerived > &other)
 
template<typename OtherDerived >
void swap (PlainObjectBase< OtherDerived > &other)
 
Scalar trace () const
 
TransposeReturnType transpose ()
 
const ConstTransposeReturnType transpose () const
 
void transposeInPlace ()
 
CoeffReturnType value () const
 
template<typename Visitor >
void visit (Visitor &func) const
 
- Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, DirectWriteAccessors >
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index colStride () const EIGEN_NOEXCEPT
 
Derived & derived ()
 
const Derived & derived () const
 
EIGEN_CONSTEXPR Index innerStride () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index outerStride () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index rowStride () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index stride () const EIGEN_NOEXCEPT
 
- Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, WriteAccessors >
ScalarcoeffRef (Index index)
 
ScalarcoeffRef (Index row, Index col)
 
ScalarcoeffRefByOuterInner (Index outer, Index inner)
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & derived ()
 
const Derived & derived () const
 
Scalaroperator() (Index index)
 
Scalaroperator() (Index row, Index col)
 
Scalaroperator[] (Index index)
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
Scalarw ()
 
Scalarx ()
 
Scalary ()
 
Scalarz ()
 
- Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, ReadOnlyAccessors >
CoeffReturnType coeff (Index index) const
 
CoeffReturnType coeff (Index row, Index col) const
 
CoeffReturnType coeffByOuterInner (Index outer, Index inner) const
 
Index colIndexByOuterInner (Index outer, Index inner) const
 
EIGEN_CONSTEXPR Index cols () const EIGEN_NOEXCEPT
 
Derived & derived ()
 
const Derived & derived () const
 
CoeffReturnType operator() (Index index) const
 
CoeffReturnType operator() (Index row, Index col) const
 
CoeffReturnType operator[] (Index index) const
 
template<int LoadMode>
PacketReturnType packet (Index index) const
 
template<int LoadMode>
PacketReturnType packet (Index row, Index col) const
 
template<int LoadMode>
PacketReturnType packetByOuterInner (Index outer, Index inner) const
 
Index rowIndexByOuterInner (Index outer, Index inner) const
 
EIGEN_CONSTEXPR Index rows () const EIGEN_NOEXCEPT
 
EIGEN_CONSTEXPR Index size () const EIGEN_NOEXCEPT
 
CoeffReturnType w () const
 
CoeffReturnType x () const
 
CoeffReturnType y () const
 
CoeffReturnType z () 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
 

Static Public Member Functions

static const ConstantReturnType Constant (const Scalar &value)
 
static const ConstantReturnType Constant (Index rows, Index cols, const Scalar &value)
 
static const ConstantReturnType Constant (Index size, const Scalar &value)
 
static const RandomAccessEqualSpacedReturnType EqualSpaced (const Scalar &low, const Scalar &step)
 
static const RandomAccessEqualSpacedReturnType EqualSpaced (Index size, const Scalar &low, const Scalar &step)
 
static const RandomAccessLinSpacedReturnType LinSpaced (const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector. More...
 
static const RandomAccessLinSpacedReturnType LinSpaced (Index size, const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector. More...
 
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced (Sequential_t, const Scalar &low, const Scalar &high)
 
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced (Sequential_t, Index size, const Scalar &low, const Scalar &high)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObjectNullaryExpr (const CustomNullaryOp &func)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObjectNullaryExpr (Index rows, Index cols, const CustomNullaryOp &func)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObjectNullaryExpr (Index size, const CustomNullaryOp &func)
 
static const ConstantReturnType Ones ()
 
static const ConstantReturnType Ones (Index rows, Index cols)
 
static const ConstantReturnType Ones (Index size)
 
static const RandomReturnType Random ()
 
static const RandomReturnType Random (Index rows, Index cols)
 
static const RandomReturnType Random (Index size)
 
static const ConstantReturnType Zero ()
 
static const ConstantReturnType Zero (Index rows, Index cols)
 
static const ConstantReturnType Zero (Index size)
 

Protected Member Functions

constexpr DenseBase ()
 
- Protected Member Functions inherited from Eigen::DenseCoeffsBase< Derived, ReadOnlyAccessors >
void coeffRef ()
 
void coeffRefByOuterInner ()
 
void colStride ()
 
void copyCoeff ()
 
void copyCoeffByOuterInner ()
 
void copyPacket ()
 
void copyPacketByOuterInner ()
 
void innerStride ()
 
void outerStride ()
 
void rowStride ()
 
void stride ()
 
void writePacket ()
 
void writePacketByOuterInner ()
 

Private Member Functions

template<typename OtherDerived >
 DenseBase (const DenseBase< OtherDerived > &)
 
 DenseBase (int)
 
 DenseBase (int, int)
 

Related Functions

(Note that these are not member functions.)

template<typename Derived >
std::ostream & operator<< (std::ostream &s, const DenseBase< Derived > &m)
 

Detailed Description

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

Base class for all dense matrices, vectors, and arrays.

This class is the base that is inherited by all dense objects (matrix, vector, arrays, and related expression types). The common Eigen API for dense objects is contained in this class.

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

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

See also
The class hierarchy

Definition at line 36 of file DenseBase.h.

Member Typedef Documentation

◆ Base

template<typename Derived >
typedef DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value> Eigen::DenseBase< Derived >::Base

Definition at line 69 of file DenseBase.h.

◆ CoeffReturnType

template<typename Derived >
typedef Base::CoeffReturnType Eigen::DenseBase< Derived >::CoeffReturnType

Definition at line 91 of file DenseBase.h.

◆ ColwiseReturnType

template<typename Derived >
typedef VectorwiseOp<Derived, Vertical> Eigen::DenseBase< Derived >::ColwiseReturnType

Definition at line 537 of file DenseBase.h.

◆ const_iterator

template<typename Derived >
typedef random_access_iterator_type Eigen::DenseBase< Derived >::const_iterator

This is the const version of iterator (aka read-only)

Definition at line 630 of file DenseBase.h.

◆ ConstColwiseReturnType

template<typename Derived >
typedef const VectorwiseOp<const Derived, Vertical> Eigen::DenseBase< Derived >::ConstColwiseReturnType

Definition at line 538 of file DenseBase.h.

◆ ConstReverseReturnType

template<typename Derived >
typedef const Reverse<const Derived, BothDirections> Eigen::DenseBase< Derived >::ConstReverseReturnType

Definition at line 614 of file DenseBase.h.

◆ ConstRowwiseReturnType

template<typename Derived >
typedef const VectorwiseOp<const Derived, Horizontal> Eigen::DenseBase< Derived >::ConstRowwiseReturnType

Definition at line 536 of file DenseBase.h.

◆ ConstTransposeReturnType

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

Definition at line 318 of file DenseBase.h.

◆ EvalReturnType

template<typename Derived >
typedef internal::add_const_on_value_type_t<typename internal::eval<Derived>::type> Eigen::DenseBase< Derived >::EvalReturnType

Definition at line 396 of file DenseBase.h.

◆ iterator

template<typename Derived >
typedef random_access_iterator_type Eigen::DenseBase< Derived >::iterator

STL-like RandomAccessIterator iterator type as returned by the begin() and end() methods.

Definition at line 628 of file DenseBase.h.

◆ PacketScalar

template<typename Derived >
typedef internal::find_best_packet<Scalar,SizeAtCompileTime>::type Eigen::DenseBase< Derived >::PacketScalar

Definition at line 173 of file DenseBase.h.

◆ PlainArray

template<typename Derived >
typedef Array<typename internal::traits<Derived>::Scalar, internal::traits<Derived>::RowsAtCompileTime, internal::traits<Derived>::ColsAtCompileTime, AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), internal::traits<Derived>::MaxRowsAtCompileTime, internal::traits<Derived>::MaxColsAtCompileTime > Eigen::DenseBase< Derived >::PlainArray

The plain array type corresponding to this expression.

See also
PlainObject

Definition at line 195 of file DenseBase.h.

◆ PlainMatrix

template<typename Derived >
typedef Matrix<typename internal::traits<Derived>::Scalar, internal::traits<Derived>::RowsAtCompileTime, internal::traits<Derived>::ColsAtCompileTime, AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor), internal::traits<Derived>::MaxRowsAtCompileTime, internal::traits<Derived>::MaxColsAtCompileTime > Eigen::DenseBase< Derived >::PlainMatrix

The plain matrix type corresponding to this expression.

See also
PlainObject

Definition at line 185 of file DenseBase.h.

◆ PlainObject

template<typename Derived >
typedef std::conditional_t<internal::is_same<typename internal::traits<Derived>::XprKind,MatrixXpr >::value, PlainMatrix, PlainArray> Eigen::DenseBase< Derived >::PlainObject

The plain matrix or array type corresponding to this expression.

This is not necessarily exactly the return type of eval(). In the case of plain matrices, the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed that the return type of eval() is either PlainObject or const PlainObject&.

Definition at line 204 of file DenseBase.h.

◆ RandomReturnType

template<typename Derived >
typedef CwiseNullaryOp<internal::scalar_random_op<Scalar>,PlainObject> Eigen::DenseBase< Derived >::RandomReturnType

Definition at line 565 of file DenseBase.h.

◆ RealScalar

template<typename Derived >
typedef NumTraits<Scalar>::Real Eigen::DenseBase< Derived >::RealScalar

Definition at line 68 of file DenseBase.h.

◆ ReverseReturnType

template<typename Derived >
typedef Reverse<Derived, BothDirections> Eigen::DenseBase< Derived >::ReverseReturnType

Definition at line 613 of file DenseBase.h.

◆ RowwiseReturnType

template<typename Derived >
typedef VectorwiseOp<Derived, Horizontal> Eigen::DenseBase< Derived >::RowwiseReturnType

Definition at line 535 of file DenseBase.h.

◆ Scalar

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

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

Definition at line 61 of file DenseBase.h.

◆ StorageIndex

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

The type used to store indices.

This typedef is relevant for types that store multiple indices such as PermutationMatrix or Transpositions, otherwise it defaults to Eigen::Index

See also
Preprocessor directives, Eigen::Index, SparseMatrixBase.

Definition at line 58 of file DenseBase.h.

◆ StorageKind

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

Definition at line 50 of file DenseBase.h.

◆ TransposeReturnType

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

Definition at line 315 of file DenseBase.h.

◆ value_type

template<typename Derived >
typedef Scalar Eigen::DenseBase< 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 66 of file DenseBase.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 

This value is equal to the maximum possible number of rows that this expression might have. If this expression might have an arbitrarily high number of rows, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also
RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
MaxColsAtCompileTime 

This value is equal to the maximum possible number of columns that this expression might have. If this expression might have an arbitrarily high number of columns, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also
ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
MaxSizeAtCompileTime 

This value is equal to the maximum possible number of coefficients that this expression might have. If this expression might have an arbitrarily high number of coefficients, this value is set to Dynamic.

This value is useful to know when evaluating an expression, in order to determine whether it is possible to avoid doing a dynamic memory allocation.

See also
SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
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 

True if this expression has row-major storage order.

InnerSizeAtCompileTime 
InnerStrideAtCompileTime 
OuterStrideAtCompileTime 

Definition at line 93 of file DenseBase.h.

93  {
94 
95  RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
101  ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
108  SizeAtCompileTime = (internal::size_of_xpr_at_compile_time<Derived>::ret),
113  MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
124  MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
135  MaxSizeAtCompileTime = internal::size_at_compile_time(internal::traits<Derived>::MaxRowsAtCompileTime,
136  internal::traits<Derived>::MaxColsAtCompileTime),
147  IsVectorAtCompileTime = internal::traits<Derived>::RowsAtCompileTime == 1
148  || internal::traits<Derived>::ColsAtCompileTime == 1,
159  Flags = internal::traits<Derived>::Flags,
164  IsRowMajor = int(Flags) & RowMajorBit,
167  : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
168 
169  InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
170  OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
171  };
@ OuterStrideAtCompileTime
Definition: DenseBase.h:170
@ InnerStrideAtCompileTime
Definition: DenseBase.h:169
const unsigned int RowMajorBit
Definition: Constants.h:68
constexpr int size_at_compile_time(int rows, int cols)
Definition: XprHelper.h:313

◆ anonymous enum

template<typename Derived >
anonymous enum
Enumerator
IsPlainObjectBase 

Definition at line 175 of file DenseBase.h.

175 { IsPlainObjectBase = 0 };

Constructor & Destructor Documentation

◆ DenseBase() [1/4]

template<typename Derived >
constexpr Eigen::DenseBase< Derived >::DenseBase ( )
inlineconstexprprotected

Default constructor. Do nothing.

Definition at line 683 of file DenseBase.h.

683  {
684  /* Just checks for self-consistency of the flags.
685  * Only do it when debugging Eigen, as this borders on paranoia and could slow compilation down
686  */
687 #ifdef EIGEN_INTERNAL_DEBUGGING
690  INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
691 #endif
692  }
#define EIGEN_STATIC_ASSERT(X, MSG)
Definition: StaticAssert.h:26
constexpr bool check_implication(bool a, bool b)
Definition: Meta.h:579

◆ DenseBase() [2/4]

template<typename Derived >
Eigen::DenseBase< Derived >::DenseBase ( int  )
explicitprivate

◆ DenseBase() [3/4]

template<typename Derived >
Eigen::DenseBase< Derived >::DenseBase ( int  ,
int   
)
private

◆ DenseBase() [4/4]

template<typename Derived >
template<typename OtherDerived >
Eigen::DenseBase< Derived >::DenseBase ( const DenseBase< OtherDerived > &  )
explicitprivate

Member Function Documentation

◆ all()

template<typename Derived >
bool Eigen::DenseBase< Derived >::all
inline
Returns
true if all coefficients are true

Example:

// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
cout << "Is (" << p0.transpose() << ") inside the box: "
<< ((boxMin.array()<p0.array()).all() && (boxMax.array()>p0.array()).all()) << endl;
cout << "Is (" << p1.transpose() << ") inside the box: "
<< ((boxMin.array()<p1.array()).all() && (boxMax.array()>p1.array()).all()) << endl;
Vector3f boxMin(Vector3f::Zero())
Vector3f p0
Vector3f boxMax(Vector3f::Ones())
Vector3f p1
static const ConstantReturnType Ones()
static const ConstantReturnType Zero()
bool all() const
Definition: Visitor.h:788
static const RandomReturnType Random()
Definition: Random.h:114
Matrix< float, 3, 1 > Vector3f
3×1 vector of type float.
Definition: Matrix.h:501

Output:

Is (  0.68 -0.211  0.566) inside the box: 0
Is (0.597 0.823 0.605) inside the box: 1
See also
any(), Cwise::operator<()

Definition at line 788 of file Visitor.h.

788  {
789  using Visitor = internal::all_visitor<Scalar>;
790  using impl = internal::visit_impl<Derived, Visitor, /*ShortCircuitEvaulation*/true>;
791  Visitor visitor;
792  impl::run(derived(), visitor);
793  return visitor.res;
794 }

◆ allFinite()

template<typename Derived >
bool Eigen::DenseBase< Derived >::allFinite
inline
Returns
true if *this contains only finite numbers, i.e., no NaN and no +/-INF values.
See also
hasNaN()

Definition at line 835 of file Visitor.h.

835  {
836  return derived().array().isFinite().all();
837 }

◆ any()

template<typename Derived >
bool Eigen::DenseBase< Derived >::any
inline
Returns
true if at least one coefficient is true
See also
all()

Definition at line 801 of file Visitor.h.

801  {
802  using Visitor = internal::any_visitor<Scalar>;
803  using impl = internal::visit_impl<Derived, Visitor, /*ShortCircuitEvaulation*/true>;
804  Visitor visitor;
805  impl::run(derived(), visitor);
806  return visitor.res;
807 }

◆ begin() [1/2]

template<typename Derived >
DenseBase< Derived >::iterator Eigen::DenseBase< Derived >::begin
inline

returns an iterator to the first element of the 1D vector or array This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also
end(), cbegin()

Definition at line 410 of file StlIterators.h.

411 {
413  return iterator(derived(), 0);
414 }
#define EIGEN_STATIC_ASSERT_VECTOR_ONLY(TYPE)
Definition: StaticAssert.h:36
random_access_iterator_type iterator
Definition: DenseBase.h:628

◆ begin() [2/2]

template<typename Derived >
DenseBase< Derived >::const_iterator Eigen::DenseBase< Derived >::begin
inline

const version of begin()

Definition at line 418 of file StlIterators.h.

419 {
420  return cbegin();
421 }
const_iterator cbegin() const
Definition: StlIterators.h:428

◆ cbegin()

template<typename Derived >
DenseBase< Derived >::const_iterator Eigen::DenseBase< Derived >::cbegin
inline

returns a read-only const_iterator to the first element of the 1D vector or array This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also
cend(), begin()

Definition at line 428 of file StlIterators.h.

429 {
431  return const_iterator(derived(), 0);
432 }
random_access_iterator_type const_iterator
Definition: DenseBase.h:630

◆ cend()

template<typename Derived >
DenseBase< Derived >::const_iterator Eigen::DenseBase< Derived >::cend
inline

returns a read-only const_iterator to the element following the last element of the 1D vector or array This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also
begin(), cend()

Definition at line 457 of file StlIterators.h.

458 {
460  return const_iterator(derived(), size());
461 }
EIGEN_CONSTEXPR Index size() const EIGEN_NOEXCEPT
Definition: EigenBase.h:69

◆ colwise() [1/2]

template<typename Derived >
DenseBase< Derived >::ColwiseReturnType Eigen::DenseBase< Derived >::colwise
inline
Returns
a writable VectorwiseOp wrapper of *this providing additional partial reduction operations
See also
rowwise(), class VectorwiseOp, Reductions, visitors and broadcasting

Definition at line 764 of file VectorwiseOp.h.

765 {
766  return ColwiseReturnType(derived());
767 }
VectorwiseOp< Derived, Vertical > ColwiseReturnType
Definition: DenseBase.h:537

◆ colwise() [2/2]

template<typename Derived >
ConstColwiseReturnType Eigen::DenseBase< Derived >::colwise ( ) const
inline
Returns
a VectorwiseOp wrapper of *this broadcasting and partial reductions

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each column:" << endl << m.colwise().sum() << endl;
cout << "Here is the maximum absolute value of each column:"
<< endl << m.cwiseAbs().colwise().maxCoeff() << endl;
Matrix3f m
Matrix< double, 3, 3 > Matrix3d
3×3 matrix of type double.
Definition: Matrix.h:502

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each column:
  1.04  0.815 -0.238
Here is the maximum absolute value of each column:
 0.68 0.823 0.536
See also
rowwise(), class VectorwiseOp, Reductions, visitors and broadcasting

Definition at line 560 of file DenseBase.h.

560  {
562  }
const VectorwiseOp< const Derived, Vertical > ConstColwiseReturnType
Definition: DenseBase.h:538

◆ Constant() [1/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Constant ( const Scalar value)
inlinestatic
Returns
an expression of a constant matrix of value value

This variant is only for fixed-size DenseBase types. For dynamic-size types, you need to use the variants taking size arguments.

The template parameter CustomNullaryOp is the type of the functor.

See also
class CwiseNullaryOp

Definition at line 229 of file CwiseNullaryOp.h.

230 {
232  return DenseBase<Derived>::NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_constant_op<Scalar>(value));
233 }
#define EIGEN_STATIC_ASSERT_FIXED_SIZE(TYPE)
Definition: StaticAssert.h:41
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr(Index rows, Index cols, const CustomNullaryOp &func)
CoeffReturnType value() const
Definition: DenseBase.h:524

◆ Constant() [2/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Constant ( Index  rows,
Index  cols,
const Scalar value 
)
inlinestatic
Returns
an expression of a constant matrix of value value

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this DenseBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also
class CwiseNullaryOp

Definition at line 191 of file CwiseNullaryOp.h.

192 {
193  return DenseBase<Derived>::NullaryExpr(rows, cols, internal::scalar_constant_op<Scalar>(value));
194 }
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62

◆ Constant() [3/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Constant ( Index  size,
const Scalar value 
)
inlinestatic
Returns
an expression of a constant matrix of value value

The parameter size is the size of the returned vector. Must be compatible with this DenseBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also
class CwiseNullaryOp

Definition at line 213 of file CwiseNullaryOp.h.

214 {
215  return DenseBase<Derived>::NullaryExpr(size, internal::scalar_constant_op<Scalar>(value));
216 }

◆ count()

template<typename Derived >
Index Eigen::DenseBase< Derived >::count
Returns
the number of coefficients which evaluate to true
See also
all(), any()

Definition at line 815 of file Visitor.h.

816 {
817  using Visitor = internal::count_visitor<Scalar>;
818  using impl = internal::visit_impl<Derived, Visitor, /*ShortCircuitEvaulation*/false>;
819  Visitor visitor;
820  impl::run(derived(), visitor);
821  return visitor.res;
822 
823 }

◆ end() [1/2]

template<typename Derived >
DenseBase< Derived >::iterator Eigen::DenseBase< Derived >::end
inline

returns an iterator to the element following the last element of the 1D vector or array This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

See also
begin(), cend()

Definition at line 439 of file StlIterators.h.

440 {
442  return iterator(derived(), size());
443 }

◆ end() [2/2]

template<typename Derived >
DenseBase< Derived >::const_iterator Eigen::DenseBase< Derived >::end
inline

const version of end()

Definition at line 447 of file StlIterators.h.

448 {
449  return cend();
450 }
const_iterator cend() const
Definition: StlIterators.h:457

◆ EqualSpaced() [1/2]

template<typename Derived >
const DenseBase< Derived >::RandomAccessEqualSpacedReturnType Eigen::DenseBase< Derived >::EqualSpaced ( const Scalar low,
const Scalar step 
)
inlinestatic

Definition at line 318 of file CwiseNullaryOp.h.

318  {
320  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::equalspaced_op<Scalar>(low, step));
321 }

◆ EqualSpaced() [2/2]

template<typename Derived >
const DenseBase< Derived >::RandomAccessEqualSpacedReturnType Eigen::DenseBase< Derived >::EqualSpaced ( Index  size,
const Scalar low,
const Scalar step 
)
inlinestatic

Definition at line 311 of file CwiseNullaryOp.h.

311  {
313  return DenseBase<Derived>::NullaryExpr(size, internal::equalspaced_op<Scalar>(low, step));
314 }

◆ eval()

template<typename Derived >
EvalReturnType Eigen::DenseBase< 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.

Warning
Be careful with eval() and the auto C++ keyword, as detailed in this page .

Definition at line 405 of file DenseBase.h.

406  {
407  // Even though MSVC does not honor strong inlining when the return type
408  // is a dynamic matrix, we desperately need strong inlining for fixed
409  // size types on MSVC.
410  return typename internal::eval<Derived>::type(derived());
411  }

◆ evalTo()

template<typename Derived >
template<typename Dest >
void Eigen::DenseBase< Derived >::evalTo ( Dest &  ) const
inline

Definition at line 675 of file DenseBase.h.

676  {
677  EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
678  }

◆ fill()

template<typename Derived >
void Eigen::DenseBase< Derived >::fill ( const Scalar val)
inline

Alias for setConstant(): sets all coefficients in this expression to val.

See also
setConstant(), Constant(), class CwiseNullaryOp

Definition at line 351 of file CwiseNullaryOp.h.

352 {
353  setConstant(val);
354 }
Derived & setConstant(const Scalar &value)

◆ flagged()

template<typename Derived >
template<unsigned int Added, unsigned int Removed>
EIGEN_DEPRECATED const Derived& Eigen::DenseBase< Derived >::flagged ( ) const
inline
Deprecated:
it now returns *this

Definition at line 308 of file DenseBase.h.

309  { return derived(); }

◆ forceAlignedAccess() [1/2]

template<typename Derived >
ForceAlignedAccess<Derived> Eigen::DenseBase< Derived >::forceAlignedAccess ( )
inline

◆ forceAlignedAccess() [2/2]

template<typename Derived >
const ForceAlignedAccess<Derived> Eigen::DenseBase< Derived >::forceAlignedAccess ( ) const
inline

◆ forceAlignedAccessIf() [1/2]

template<typename Derived >
template<bool Enable>
std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&> Eigen::DenseBase< Derived >::forceAlignedAccessIf ( )
inline

◆ forceAlignedAccessIf() [2/2]

template<typename Derived >
template<bool Enable>
const std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&> Eigen::DenseBase< Derived >::forceAlignedAccessIf ( ) const
inline

◆ format()

template<typename Derived >
const WithFormat<Derived> Eigen::DenseBase< Derived >::format ( const IOFormat fmt) const
inline
Returns
a WithFormat proxy object allowing to print a matrix the with given format fmt.

See class IOFormat for some examples.

See also
class IOFormat, class WithFormat

Definition at line 517 of file DenseBase.h.

518  {
519  return WithFormat<Derived>(derived(), fmt);
520  }

◆ hasNaN()

template<typename Derived >
bool Eigen::DenseBase< Derived >::hasNaN
inline

Definition at line 826 of file Visitor.h.

826  {
827  return derived().cwiseTypedNotEqual(derived()).any();
828 }

◆ innerSize()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::DenseBase< Derived >::innerSize ( ) const
inline
Returns
the inner size.
Note
For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension with respect to the storage order, i.e., the number of rows for a column-major matrix, and the number of columns for a row-major matrix.

Definition at line 224 of file DenseBase.h.

225  {
226  return IsVectorAtCompileTime ? this->size()
227  : int(IsRowMajor) ? this->cols() : this->rows();
228  }

◆ isApprox()

template<typename Derived >
template<typename OtherDerived >
bool Eigen::DenseBase< Derived >::isApprox ( const DenseBase< OtherDerived > &  other,
const RealScalar prec = NumTraits<Scalar>::dummy_precision() 
) const
Returns
true if *this is approximately equal to other, within the precision determined by prec.
Note
The fuzzy compares are done multiplicatively. Two vectors \( v \) and \( w \) are considered to be approximately equal within precision \( p \) if

\[ \Vert v - w \Vert \leqslant p\,\min(\Vert v\Vert, \Vert w\Vert). \]

For matrices, the comparison is done using the Hilbert-Schmidt norm (aka Frobenius norm L2 norm).
Because of the multiplicativeness of this comparison, one can't use this function to check whether *this is approximately equal to the zero matrix or vector. Indeed, isApprox(zero) returns false unless *this itself is exactly the zero matrix or vector. If you want to test whether *this is zero, use internal::isMuchSmallerThan(const RealScalar&, RealScalar) instead.
See also
internal::isMuchSmallerThan(const RealScalar&, RealScalar) const

Definition at line 105 of file Fuzzy.h.

109 {
110  return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
111 }

◆ isApproxToConstant()

template<typename Derived >
bool Eigen::DenseBase< Derived >::isApproxToConstant ( const Scalar val,
const RealScalar prec = NumTraits<Scalar>::dummy_precision() 
) const
Returns
true if all coefficients in this matrix are approximately equal to val, to within precision prec

Definition at line 325 of file CwiseNullaryOp.h.

327 {
328  typename internal::nested_eval<Derived,1>::type self(derived());
329  for(Index j = 0; j < cols(); ++j)
330  for(Index i = 0; i < rows(); ++i)
331  if(!internal::isApprox(self.coeff(i, j), val, prec))
332  return false;
333  return true;
334 }
CoeffReturnType coeff(Index row, Index col) const
bool isApprox(const Scalar &x, const Scalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
std::ptrdiff_t j

◆ isConstant()

template<typename Derived >
bool Eigen::DenseBase< Derived >::isConstant ( const Scalar val,
const RealScalar prec = NumTraits<Scalar>::dummy_precision() 
) const

This is just an alias for isApproxToConstant().

Returns
true if all coefficients in this matrix are approximately equal to value, to within precision prec

Definition at line 340 of file CwiseNullaryOp.h.

342 {
343  return isApproxToConstant(val, prec);
344 }
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const

◆ isMuchSmallerThan() [1/3]

template<typename Derived >
template<typename OtherDerived >
bool Eigen::DenseBase< Derived >::isMuchSmallerThan ( const DenseBase< OtherDerived > &  other,
const RealScalar prec = NumTraits<Scalar>::dummy_precision() 
) const
Returns
true if the norm of *this is much smaller than the norm of other, within the precision determined by prec.
Note
The fuzzy compares are done multiplicatively. A vector \( v \) is considered to be much smaller than a vector \( w \) within precision \( p \) if

\[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \]

For matrices, the comparison is done using the Hilbert-Schmidt norm.
See also
isApprox(), isMuchSmallerThan(const RealScalar&, RealScalar) const

Definition at line 147 of file Fuzzy.h.

151 {
152  return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
153 }

◆ isMuchSmallerThan() [2/3]

template<typename Derived >
bool Eigen::DenseBase< Derived >::isMuchSmallerThan ( const RealScalar other,
const RealScalar prec = NumTraitsScalar >::dummy_precision() 
) const

◆ isMuchSmallerThan() [3/3]

template<typename Derived >
template<typename Derived >
bool Eigen::DenseBase< Derived >::isMuchSmallerThan ( const typename NumTraits< Scalar >::Real &  other,
const RealScalar prec 
) const
Returns
true if the norm of *this is much smaller than other, within the precision determined by prec.
Note
The fuzzy compares are done multiplicatively. A vector \( v \) is considered to be much smaller than \( x \) within precision \( p \) if

\[ \Vert v \Vert \leqslant p\,\vert x\vert. \]

For matrices, the comparison is done using the Hilbert-Schmidt norm. For this reason, the value of the reference scalar other should come from the Hilbert-Schmidt norm of a reference matrix of same dimensions.

See also
isApprox(), isMuchSmallerThan(const DenseBase<OtherDerived>&, RealScalar) const

Definition at line 127 of file Fuzzy.h.

131 {
132  return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
133 }

◆ isOnes()

template<typename Derived >
bool Eigen::DenseBase< Derived >::isOnes ( const RealScalar prec = NumTraits<Scalar>::dummy_precision()) const
Returns
true if *this is approximately equal to the matrix where all coefficients are equal to 1, within the precision given by prec.

Example:

m(0,2) += 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isOnes() returns: " << m.isOnes() << endl;
cout << "m.isOnes(1e-3) returns: " << m.isOnes(1e-3) << endl;
Array< double, 1, 3 > e(1./3., 0.5, 2.)

Output:

Here's the matrix m:
1 1 1
1 1 1
1 1 1
m.isOnes() returns: 0
m.isOnes(1e-3) returns: 1
See also
class CwiseNullaryOp, Ones()

Definition at line 713 of file CwiseNullaryOp.h.

715 {
716  return isApproxToConstant(Scalar(1), prec);
717 }
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61

◆ isZero()

template<typename Derived >
bool Eigen::DenseBase< Derived >::isZero ( const RealScalar prec = NumTraits<Scalar>::dummy_precision()) const
Returns
true if *this is approximately equal to the zero matrix, within the precision given by prec.

Example:

m(0,2) = 1e-4;
cout << "Here's the matrix m:" << endl << m << endl;
cout << "m.isZero() returns: " << m.isZero() << endl;
cout << "m.isZero(1e-3) returns: " << m.isZero(1e-3) << endl;

Output:

Here's the matrix m:
     0      0 0.0001
     0      0      0
     0      0      0
m.isZero() returns: 0
m.isZero(1e-3) returns: 1
See also
class CwiseNullaryOp, Zero()

Definition at line 557 of file CwiseNullaryOp.h.

558 {
559  typename internal::nested_eval<Derived,1>::type self(derived());
560  for(Index j = 0; j < cols(); ++j)
561  for(Index i = 0; i < rows(); ++i)
562  if(!internal::isMuchSmallerThan(self.coeff(i, j), static_cast<Scalar>(1), prec))
563  return false;
564  return true;
565 }
bool isMuchSmallerThan(const Scalar &x, const OtherScalar &y, const typename NumTraits< Scalar >::Real &precision=NumTraits< Scalar >::dummy_precision())

◆ lazyAssign() [1/2]

template<typename Derived >
template<typename OtherDerived >
Derived& Eigen::DenseBase< Derived >::lazyAssign ( const DenseBase< OtherDerived > &  other)
inline

Definition at line 22 of file Assign.h.

23 {
24  enum{
25  SameType = internal::is_same<typename Derived::Scalar,typename OtherDerived::Scalar>::value
26  };
27 
29  EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(Derived,OtherDerived)
30  EIGEN_STATIC_ASSERT(SameType,YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
31 
32  eigen_assert(rows() == other.rows() && cols() == other.cols());
34 
35  return derived();
36 }
#define eigen_assert(x)
Definition: Macros.h:902
#define EIGEN_STATIC_ASSERT_LVALUE(Derived)
Definition: StaticAssert.h:96
#define EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(TYPE0, TYPE1)
Definition: StaticAssert.h:86
EIGEN_CONSTEXPR void call_assignment_no_alias(Dst &dst, const Src &src, const Func &func)

◆ lazyAssign() [2/2]

template<typename Derived >
template<typename OtherDerived >
EIGEN_DEPRECATED Derived& Eigen::DenseBase< Derived >::lazyAssign ( const DenseBase< OtherDerived > &  other)

◆ LinSpaced() [1/4]

template<typename Derived >
const DenseBase< Derived >::RandomAccessLinSpacedReturnType Eigen::DenseBase< Derived >::LinSpaced ( const Scalar low,
const Scalar high 
)
inlinestatic

Sets a linearly spaced vector.

The function generates 'size' equally spaced values in the closed interval [low,high]. When size is set to 1, a vector of length 1 containing 'high' is returned.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Example:

cout << VectorXi::LinSpaced(4,7,10).transpose() << endl;
cout << VectorXd::LinSpaced(5,0.0,1.0).transpose() << endl;
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)

Output:

 7  8  9 10
   0 0.25  0.5 0.75    1

For integer scalar types, an even spacing is possible if and only if the length of the range, i.e., high-low is a scalar multiple of size-1, or if size is a scalar multiple of the number of values high-low+1 (meaning each value can be repeated the same number of time). If one of these two considions is not satisfied, then high is lowered to the largest value satisfying one of this constraint. Here are some examples:

Example:

cout << "Even spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,4).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,8).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,15).transpose() << endl;
cout << "Uneven spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,7).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,9).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,16).transpose() << endl;

Output:

Even spacing inputs:
1 1 2 2 3 3 4 4
1 2 3 4 5 6 7 8
 1  3  5  7  9 11 13 15
Uneven spacing inputs:
1 1 2 2 3 3 4 4
1 2 3 4 5 6 7 8
 1  3  5  7  9 11 13 15
See also
setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp Special version for fixed size types which does not require the size parameter.

Definition at line 302 of file CwiseNullaryOp.h.

303 {
306  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar>(low,high,Derived::SizeAtCompileTime));
307 }

◆ LinSpaced() [2/4]

template<typename Derived >
const DenseBase< Derived >::RandomAccessLinSpacedReturnType Eigen::DenseBase< Derived >::LinSpaced ( Index  size,
const Scalar low,
const Scalar high 
)
inlinestatic

Sets a linearly spaced vector.

The function generates 'size' equally spaced values in the closed interval [low,high]. When size is set to 1, a vector of length 1 containing 'high' is returned.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Example:

cout << VectorXi::LinSpaced(4,7,10).transpose() << endl;
cout << VectorXd::LinSpaced(5,0.0,1.0).transpose() << endl;

Output:

 7  8  9 10
   0 0.25  0.5 0.75    1

For integer scalar types, an even spacing is possible if and only if the length of the range, i.e., high-low is a scalar multiple of size-1, or if size is a scalar multiple of the number of values high-low+1 (meaning each value can be repeated the same number of time). If one of these two considions is not satisfied, then high is lowered to the largest value satisfying one of this constraint. Here are some examples:

Example:

cout << "Even spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,4).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,8).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,15).transpose() << endl;
cout << "Uneven spacing inputs:" << endl;
cout << VectorXi::LinSpaced(8,1,7).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,9).transpose() << endl;
cout << VectorXi::LinSpaced(8,1,16).transpose() << endl;

Output:

Even spacing inputs:
1 1 2 2 3 3 4 4
1 2 3 4 5 6 7 8
 1  3  5  7  9 11 13 15
Uneven spacing inputs:
1 1 2 2 3 3 4 4
1 2 3 4 5 6 7 8
 1  3  5  7  9 11 13 15
See also
setLinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp

Definition at line 290 of file CwiseNullaryOp.h.

291 {
293  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low,high,size));
294 }

◆ LinSpaced() [3/4]

template<typename Derived >
EIGEN_DEPRECATED const DenseBase< Derived >::RandomAccessLinSpacedReturnType Eigen::DenseBase< Derived >::LinSpaced ( Sequential_t  ,
const Scalar low,
const Scalar high 
)
inlinestatic
Deprecated:
because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(const Scalar&,const Scalar&)
See also
LinSpaced(const Scalar&, const Scalar&)

Definition at line 258 of file CwiseNullaryOp.h.

259 {
262  return DenseBase<Derived>::NullaryExpr(Derived::SizeAtCompileTime, internal::linspaced_op<Scalar>(low,high,Derived::SizeAtCompileTime));
263 }

◆ LinSpaced() [4/4]

template<typename Derived >
EIGEN_DEPRECATED const DenseBase< Derived >::RandomAccessLinSpacedReturnType Eigen::DenseBase< Derived >::LinSpaced ( Sequential_t  ,
Index  size,
const Scalar low,
const Scalar high 
)
inlinestatic
Deprecated:
because of accuracy loss. In Eigen 3.3, it is an alias for LinSpaced(Index,const Scalar&,const Scalar&)

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Example:

cout << VectorXi::LinSpaced(Sequential,4,7,10).transpose() << endl;
cout << VectorXd::LinSpaced(Sequential,5,0.0,1.0).transpose() << endl;
@ Sequential
Definition: Constants.h:363

Output:

 7  8  9 10
   0 0.25  0.5 0.75    1
See also
LinSpaced(Index,const Scalar&, const Scalar&), setLinSpaced(Index,const Scalar&,const Scalar&)

Definition at line 246 of file CwiseNullaryOp.h.

247 {
249  return DenseBase<Derived>::NullaryExpr(size, internal::linspaced_op<Scalar>(low,high,size));
250 }

◆ lpNorm()

template<typename Derived >
template<int p>
RealScalar Eigen::DenseBase< Derived >::lpNorm ( ) const

◆ maxCoeff() [1/6]

template<typename Derived >
template<int NaNPropagation>
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::maxCoeff
inline
Returns
the maximum of all coefficients of *this. In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN
Warning
the matrix must be not empty, otherwise an assertion is triggered.

Definition at line 533 of file Redux.h.

534 {
535  return derived().redux(Eigen::internal::scalar_max_op<Scalar,Scalar, NaNPropagation>());
536 }

◆ maxCoeff() [2/6]

template<typename Derived >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::maxCoeff ( ) const
inline

Definition at line 463 of file DenseBase.h.

463  {
464  return maxCoeff<PropagateFast>();
465  }

◆ maxCoeff() [3/6]

template<typename Derived >
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::maxCoeff ( IndexType *  index) const
Returns
the maximum of all coefficients of *this and puts in *index its location.

In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN

Warning
the matrix must be not empty, otherwise an assertion is triggered.
See also
DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visitor(), DenseBase::maxCoeff()

Definition at line 769 of file Visitor.h.

770 {
771  eigen_assert(this->rows()>0 && this->cols()>0 && "you are using an empty matrix");
772 
774  internal::minmax_coeff_visitor<Derived, false, NaNPropagation> maxVisitor;
775  this->visit(maxVisitor);
776  *index = (RowsAtCompileTime==1) ? maxVisitor.col : maxVisitor.row;
777  return maxVisitor.res;
778 }
void visit(Visitor &func) const
Definition: Visitor.h:413

◆ maxCoeff() [4/6]

template<typename Derived >
template<typename IndexType >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::maxCoeff ( IndexType *  index) const
inline

Definition at line 498 of file DenseBase.h.

498  {
499  return maxCoeff<PropagateFast>(index);
500  }

◆ maxCoeff() [5/6]

template<typename Derived >
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::maxCoeff ( IndexType *  rowId,
IndexType *  colId 
) const
Returns
the maximum of all coefficients of *this and puts in *row and *col its location.

In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN

Warning
the matrix must be not empty, otherwise an assertion is triggered.
See also
DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visit(), DenseBase::maxCoeff()

Definition at line 744 of file Visitor.h.

745 {
746  eigen_assert(this->rows()>0 && this->cols()>0 && "you are using an empty matrix");
747 
748  internal::minmax_coeff_visitor<Derived, false, NaNPropagation> maxVisitor;
749  this->visit(maxVisitor);
750  *rowPtr = maxVisitor.row;
751  if (colPtr) *colPtr = maxVisitor.col;
752  return maxVisitor.res;
753 }

◆ maxCoeff() [6/6]

template<typename Derived >
template<typename IndexType >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::maxCoeff ( IndexType *  row,
IndexType *  col 
) const
inline

Definition at line 488 of file DenseBase.h.

488  {
489  return maxCoeff<PropagateFast>(row, col);
490  }
RowXpr row(Index i)
This is the const version of row(). *‍/.
ColXpr col(Index i)
This is the const version of col().

◆ mean()

template<typename Derived >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::mean
inline
Returns
the mean of all coefficients of *this
See also
trace(), prod(), sum()

Definition at line 559 of file Redux.h.

560 {
561 #ifdef __INTEL_COMPILER
562  #pragma warning push
563  #pragma warning ( disable : 2259 )
564 #endif
565  return Scalar(derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>())) / Scalar(this->size());
566 #ifdef __INTEL_COMPILER
567  #pragma warning pop
568 #endif
569 }
Scalar redux(const BinaryOp &func) const

◆ minCoeff() [1/6]

template<typename Derived >
template<int NaNPropagation>
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::minCoeff
inline
Returns
the minimum of all coefficients of *this. In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is minimum of elements that are not NaN
Warning
the matrix must be not empty, otherwise an assertion is triggered.

Definition at line 518 of file Redux.h.

519 {
520  return derived().redux(Eigen::internal::scalar_min_op<Scalar,Scalar, NaNPropagation>());
521 }

◆ minCoeff() [2/6]

template<typename Derived >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::minCoeff ( ) const
inline

Definition at line 460 of file DenseBase.h.

460  {
461  return minCoeff<PropagateFast>();
462  }

◆ minCoeff() [3/6]

template<typename Derived >
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::minCoeff ( IndexType *  index) const
Returns
the minimum of all coefficients of *this and puts in *index its location.

In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN

Warning
the matrix must be not empty, otherwise an assertion is triggered.
See also
DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::visit(), DenseBase::minCoeff()

Definition at line 718 of file Visitor.h.

719 {
720  eigen_assert(this->rows() > 0 && this->cols() > 0 && "you are using an empty matrix");
722 
723  internal::minmax_coeff_visitor<Derived, true, NaNPropagation> minVisitor;
724  this->visit(minVisitor);
725  *index = IndexType((RowsAtCompileTime==1) ? minVisitor.col : minVisitor.row);
726  return minVisitor.res;
727 }

◆ minCoeff() [4/6]

template<typename Derived >
template<typename IndexType >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::minCoeff ( IndexType *  index) const
inline

Definition at line 493 of file DenseBase.h.

493  {
494  return minCoeff<PropagateFast>(index);
495  }

◆ minCoeff() [5/6]

template<typename Derived >
template<int NaNPropagation, typename IndexType >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::minCoeff ( IndexType *  rowId,
IndexType *  colId 
) const
Returns
the minimum of all coefficients of *this and puts in *row and *col its location.

In case *this contains NaN, NaNPropagation determines the behavior: NaNPropagation == PropagateFast : undefined NaNPropagation == PropagateNaN : result is NaN NaNPropagation == PropagateNumbers : result is maximum of elements that are not NaN

Warning
the matrix must be not empty, otherwise an assertion is triggered.
See also
DenseBase::minCoeff(Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visit(), DenseBase::minCoeff()

Definition at line 693 of file Visitor.h.

694 {
695  eigen_assert(this->rows()>0 && this->cols()>0 && "you are using an empty matrix");
696 
697  internal::minmax_coeff_visitor<Derived, true, NaNPropagation> minVisitor;
698  this->visit(minVisitor);
699  *rowId = minVisitor.row;
700  if (colId) *colId = minVisitor.col;
701  return minVisitor.res;
702 }

◆ minCoeff() [6/6]

template<typename Derived >
template<typename IndexType >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::minCoeff ( IndexType *  row,
IndexType *  col 
) const
inline

Definition at line 483 of file DenseBase.h.

483  {
484  return minCoeff<PropagateFast>(row, col);
485  }

◆ nestByValue()

template<typename Derived >
const NestByValue< Derived > Eigen::DenseBase< Derived >::nestByValue
inline
Returns
an expression of the temporary version of *this.

Definition at line 79 of file NestByValue.h.

80 {
81  return NestByValue<Derived>(derived());
82 }

◆ NullaryExpr() [1/3]

template<typename Derived >
template<typename CustomNullaryOp >
const CwiseNullaryOp< CustomNullaryOp, PlainObject > Eigen::DenseBase< Derived >::NullaryExpr ( const CustomNullaryOp &  func)
inlinestatic
Returns
an expression of a matrix defined by a custom functor func

This variant is only for fixed-size DenseBase types. For dynamic-size types, you need to use the variants taking size arguments.

The template parameter CustomNullaryOp is the type of the functor.

See also
class CwiseNullaryOp

Definition at line 171 of file CwiseNullaryOp.h.

172 {
173  return CwiseNullaryOp<CustomNullaryOp, PlainObject>(RowsAtCompileTime, ColsAtCompileTime, func);
174 }

◆ NullaryExpr() [2/3]

template<typename Derived >
template<typename CustomNullaryOp >
const CwiseNullaryOp< CustomNullaryOp, PlainObject > Eigen::DenseBase< Derived >::NullaryExpr ( Index  rows,
Index  cols,
const CustomNullaryOp &  func 
)
inlinestatic
Returns
an expression of a matrix defined by a custom functor func

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

See also
class CwiseNullaryOp

Definition at line 116 of file CwiseNullaryOp.h.

117 {
118  return CwiseNullaryOp<CustomNullaryOp, PlainObject>(rows, cols, func);
119 }

◆ NullaryExpr() [3/3]

template<typename Derived >
template<typename CustomNullaryOp >
const CwiseNullaryOp< CustomNullaryOp, PlainObject > Eigen::DenseBase< Derived >::NullaryExpr ( Index  size,
const CustomNullaryOp &  func 
)
inlinestatic
Returns
an expression of a matrix defined by a custom functor func

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

The template parameter CustomNullaryOp is the type of the functor.

Here is an example with C++11 random generators:

#include <Eigen/Core>
#include <iostream>
#include <random>
int main() {
std::default_random_engine generator;
std::poisson_distribution<int> distribution(4.1);
auto poisson = [&] () {return distribution(generator);};
std::cout << v << "\n";
}
Array< int, Dynamic, 1 > v
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
int main(int, char **)
Definition: class_Block.cpp:18

Output:

2 3 1 4 3 4 4 3 2 3
See also
class CwiseNullaryOp

Definition at line 147 of file CwiseNullaryOp.h.

148 {
150  if(RowsAtCompileTime == 1) return CwiseNullaryOp<CustomNullaryOp, PlainObject>(1, size, func);
151  else return CwiseNullaryOp<CustomNullaryOp, PlainObject>(size, 1, func);
152 }

◆ Ones() [1/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Ones
inlinestatic
Returns
an expression of a fixed-size matrix or vector where all coefficients equal one.

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << Matrix2d::Ones() << endl;
cout << 6 * RowVector4i::Ones() << endl;

Output:

1 1
1 1
6 6 6 6
See also
Ones(Index), Ones(Index,Index), isOnes(), class Ones

Definition at line 699 of file CwiseNullaryOp.h.

700 {
701  return Constant(Scalar(1));
702 }
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)

◆ Ones() [2/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Ones ( Index  rows,
Index  cols 
)
inlinestatic
Returns
an expression of a matrix where all coefficients equal one.

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Ones() should be used instead.

Example:

cout << MatrixXi::Ones(2,3) << endl;

Output:

1 1 1
1 1 1
See also
Ones(), Ones(Index), isOnes(), class Ones

Definition at line 659 of file CwiseNullaryOp.h.

660 {
661  return Constant(rows, cols, Scalar(1));
662 }

◆ Ones() [3/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Ones ( Index  newSize)
inlinestatic
Returns
an expression of a vector where all coefficients equal one.

The parameter newSize is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Ones() should be used instead.

Example:

cout << 6 * RowVectorXi::Ones(4) << endl;
cout << VectorXf::Ones(2) << endl;

Output:

6 6 6 6
1
1
See also
Ones(), Ones(Index,Index), isOnes(), class Ones

Definition at line 682 of file CwiseNullaryOp.h.

683 {
684  return Constant(newSize, Scalar(1));
685 }

◆ operator*=()

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

Definition at line 20 of file SelfCwiseBinaryOp.h.

21 {
22  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::mul_assign_op<Scalar,Scalar>());
23  return derived();
24 }
void call_assignment(Dst &dst, const Src &src)

◆ operator+=()

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

Definition at line 145 of file EigenBase.h.

146 {
147  call_assignment(derived(), other.derived(), internal::add_assign_op<Scalar,typename OtherDerived::Scalar>());
148  return derived();
149 }

◆ operator-=()

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

Definition at line 154 of file EigenBase.h.

155 {
156  call_assignment(derived(), other.derived(), internal::sub_assign_op<Scalar,typename OtherDerived::Scalar>());
157  return derived();
158 }

◆ operator/=()

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

Definition at line 41 of file SelfCwiseBinaryOp.h.

42 {
43  internal::call_assignment(this->derived(), PlainObject::Constant(rows(),cols(),other), internal::div_assign_op<Scalar,Scalar>());
44  return derived();
45 }

◆ operator<<() [1/2]

template<typename Derived >
template<typename OtherDerived >
CommaInitializer< Derived > Eigen::DenseBase< Derived >::operator<< ( const DenseBase< OtherDerived > &  other)
inline
See also
operator<<(const Scalar&)

Definition at line 1 of file CommaInitializer.h.

160 {
161  return CommaInitializer<Derived>(*static_cast<Derived *>(this), other);
162 }

◆ operator<<() [2/2]

template<typename Derived >
CommaInitializer< Derived > Eigen::DenseBase< Derived >::operator<< ( const Scalar s)
inline

Convenient operator to set the coefficients of a matrix.

The coefficients must be provided in a row major order and exactly match the size of the matrix. Otherwise an assertion is raised.

Example:

m1 << 1, 2, 3,
4, 5, 6,
7, 8, 9;
cout << m1 << endl << endl;
m2.block(0,0, 2,2) << 10, 11, 12, 13;
cout << m2 << endl << endl;
v1 << 14, 15;
m2 << v1.transpose(), 16,
v1, m1.block(1,1,2,2);
cout << m2 << endl;
Matrix3d m1
Definition: IOFormat.cpp:2
MatrixType m2(n_dims)
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9;Map< RowVectorXf > v1(M1.data(), M1.size())
static const IdentityReturnType Identity()
Matrix< int, 2, 1 > Vector2i
2×1 vector of type int.
Definition: Matrix.h:500
Matrix< int, 3, 3 > Matrix3i
3×3 matrix of type int.
Definition: Matrix.h:500

Output:

1 2 3
4 5 6
7 8 9

10 11  0
12 13  0
 0  0  1

14 15 16
14  5  6
15  8  9
Note
According the c++ standard, the argument expressions of this comma initializer are evaluated in arbitrary order.
See also
CommaInitializer::finished(), class CommaInitializer

Definition at line 1 of file CommaInitializer.h.

151 {
152  return CommaInitializer<Derived>(*static_cast<Derived*>(this), s);
153 }

◆ operator=() [1/4]

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

Special case of the template operator=, in order to prevent the compiler from generating a default operator= (issue hit with g++ 4.1)

Definition at line 49 of file Assign.h.

50 {
51  internal::call_assignment(derived(), other.derived());
52  return derived();
53 }

◆ operator=() [2/4]

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

Copies other into *this.

Returns
a reference to *this.

Definition at line 41 of file Assign.h.

42 {
43  internal::call_assignment(derived(), other.derived());
44  return derived();
45 }

◆ operator=() [3/4]

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

Copies the generic expression other into *this.

Implementation of matrix base methods

The expression must provide a (templated) evalTo(Derived& dst) const function which does the actual job. In practice, this allows any user to write its own special matrix without having to modify MatrixBase

Returns
a reference to *this.

Definition at line 136 of file EigenBase.h.

137 {
138  call_assignment(derived(), other.derived());
139  return derived();
140 }

◆ operator=() [4/4]

template<typename Derived >
template<typename OtherDerived >
Derived & Eigen::DenseBase< Derived >::operator= ( const ReturnByValue< OtherDerived > &  func)

Definition at line 86 of file ReturnByValue.h.

87 {
88  other.evalTo(derived());
89  return derived();
90 }

◆ outerSize()

template<typename Derived >
EIGEN_CONSTEXPR Index Eigen::DenseBase< Derived >::outerSize ( ) const
inline
Returns
the outer size.
Note
For a vector, this returns just 1. For a matrix (non-vector), this is the major dimension with respect to the storage order, i.e., the number of columns for a column-major matrix, and the number of rows for a row-major matrix.

Definition at line 212 of file DenseBase.h.

213  {
214  return IsVectorAtCompileTime ? 1
215  : int(IsRowMajor) ? this->rows() : this->cols();
216  }

◆ prod()

template<typename Derived >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::prod
inline
Returns
the product of all coefficients of *this

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the product of all the coefficients:" << endl << m.prod() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the product of all the coefficients:
0.0019
See also
sum(), mean(), trace()

Definition at line 580 of file Redux.h.

581 {
582  if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0))
583  return Scalar(1);
584  return derived().redux(Eigen::internal::scalar_product_op<Scalar>());
585 }
const int Dynamic
Definition: Constants.h:24

◆ Random() [1/3]

template<typename Derived >
const DenseBase< Derived >::RandomReturnType Eigen::DenseBase< Derived >::Random
inlinestatic
Returns
a fixed-size random matrix or vector expression

Numbers are uniformly spread through their whole definition range for integer types, and in the [-1:1] range for floating point scalar types.

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << 100 * Matrix2i::Random() << endl;

Output:

 700  600
-200  600

This expression has the "evaluate before nesting" flag so that it will be evaluated into a temporary matrix whenever it is nested in a larger expression. This prevents unexpected behavior with expressions involving random matrices.

Warning
This function is not re-entrant.
See also
DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random(Index)

Definition at line 114 of file Random.h.

115 {
116  return NullaryExpr(RowsAtCompileTime, ColsAtCompileTime, internal::scalar_random_op<Scalar>());
117 }

◆ Random() [2/3]

template<typename Derived >
const DenseBase< Derived >::RandomReturnType Eigen::DenseBase< Derived >::Random ( Index  rows,
Index  cols 
)
inlinestatic
Returns
a random matrix expression

Numbers are uniformly spread through their whole definition range for integer types, and in the [-1:1] range for floating point scalar types.

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

Warning
This function is not re-entrant.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Random() should be used instead.

Example:

cout << MatrixXi::Random(2,3) << endl;

Output:

 7  6  9
-2  6 -6

This expression has the "evaluate before nesting" flag so that it will be evaluated into a temporary matrix whenever it is nested in a larger expression. This prevents unexpected behavior with expressions involving random matrices.

See DenseBase::NullaryExpr(Index, const CustomNullaryOp&) for an example using C++11 random generators.

See also
DenseBase::setRandom(), DenseBase::Random(Index), DenseBase::Random()

Definition at line 57 of file Random.h.

58 {
59  return NullaryExpr(rows, cols, internal::scalar_random_op<Scalar>());
60 }

◆ Random() [3/3]

template<typename Derived >
const DenseBase< Derived >::RandomReturnType Eigen::DenseBase< Derived >::Random ( Index  size)
inlinestatic
Returns
a random vector expression

Numbers are uniformly spread through their whole definition range for integer types, and in the [-1:1] range for floating point scalar types.

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Warning
This function is not re-entrant.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Random() should be used instead.

Example:

cout << VectorXi::Random(2) << endl;

Output:

 7
-2

This expression has the "evaluate before nesting" flag so that it will be evaluated into a temporary vector whenever it is nested in a larger expression. This prevents unexpected behavior with expressions involving random matrices.

See also
DenseBase::setRandom(), DenseBase::Random(Index,Index), DenseBase::Random()

Definition at line 88 of file Random.h.

89 {
90  return NullaryExpr(size, internal::scalar_random_op<Scalar>());
91 }

◆ redux() [1/2]

template<typename Derived >
template<typename BinaryOp >
Scalar Eigen::DenseBase< Derived >::redux ( const BinaryOp func) const

◆ redux() [2/2]

template<typename Derived >
template<typename Func >
internal::traits<Derived>::Scalar Eigen::DenseBase< Derived >::redux ( const Func &  func) const
inline

Part 4 : public API

Returns
the result of a full redux operation on the whole matrix or vector using func

The template parameter BinaryOp is the type of the functor func which must be an associative operator. Both current C++98 and C++11 functor styles are handled.

Warning
the matrix must be not empty, otherwise an assertion is triggered.
See also
DenseBase::sum(), DenseBase::minCoeff(), DenseBase::maxCoeff(), MatrixBase::colwise(), MatrixBase::rowwise()

Definition at line 496 of file Redux.h.

497 {
498  eigen_assert(this->rows()>0 && this->cols()>0 && "you are using an empty matrix");
499 
500  typedef typename internal::redux_evaluator<Derived> ThisEvaluator;
501  ThisEvaluator thisEval(derived());
502 
503  // The initial expression is passed to the reducer as an additional argument instead of
504  // passing it as a member of redux_evaluator to help
505  return internal::redux_impl<Func, ThisEvaluator>::run(thisEval, func, derived());
506 }

◆ replicate() [1/2]

template<typename Derived >
template<int RowFactor, int ColFactor>
const Replicate< Derived, RowFactor, ColFactor > Eigen::DenseBase< Derived >::replicate
Returns
an expression of the replication of *this

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "m.replicate<3,2>() = ..." << endl;
cout << m.replicate<3,2>() << endl;
Matrix< int, Dynamic, Dynamic > MatrixXi
Dynamic×Dynamic matrix of type int.
Definition: Matrix.h:500

Output:

Here is the matrix m:
 7  6  9
-2  6 -6
m.replicate<3,2>() = ...
 7  6  9  7  6  9
-2  6 -6 -2  6 -6
 7  6  9  7  6  9
-2  6 -6 -2  6 -6
 7  6  9  7  6  9
-2  6 -6 -2  6 -6
See also
VectorwiseOp::replicate(), DenseBase::replicate(Index,Index), class Replicate

Definition at line 121 of file Replicate.h.

122 {
123  return Replicate<Derived,RowFactor,ColFactor>(derived());
124 }

◆ replicate() [2/2]

template<typename Derived >
const Replicate<Derived, Dynamic, Dynamic> Eigen::DenseBase< Derived >::replicate ( Index  rowFactor,
Index  colFactor 
) const
inline
Returns
an expression of the replication of *this

Example:

cout << "Here is the vector v:" << endl << v << endl;
cout << "v.replicate(2,5) = ..." << endl;
cout << v.replicate(2,5) << endl;
Matrix< int, 3, 1 > Vector3i
3×1 vector of type int.
Definition: Matrix.h:500

Output:

Here is the vector v:
 7
-2
 6
v.replicate(2,5) = ...
 7  7  7  7  7
-2 -2 -2 -2 -2
 6  6  6  6  6
 7  7  7  7  7
-2 -2 -2 -2 -2
 6  6  6  6  6
See also
VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate

Definition at line 608 of file DenseBase.h.

609  {
610  return Replicate<Derived, Dynamic, Dynamic>(derived(), rowFactor, colFactor);
611  }

◆ resize() [1/2]

template<typename Derived >
void Eigen::DenseBase< Derived >::resize ( Index  newSize)
inline

Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does nothing else.

Definition at line 235 of file DenseBase.h.

236  {
237  EIGEN_ONLY_USED_FOR_DEBUG(newSize);
238  eigen_assert(newSize == this->size()
239  && "DenseBase::resize() does not actually allow to resize.");
240  }
#define EIGEN_ONLY_USED_FOR_DEBUG(x)
Definition: Macros.h:914

◆ resize() [2/2]

template<typename Derived >
void Eigen::DenseBase< Derived >::resize ( Index  rows,
Index  cols 
)
inline

Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does nothing else.

Definition at line 246 of file DenseBase.h.

247  {
250  eigen_assert(rows == this->rows() && cols == this->cols()
251  && "DenseBase::resize() does not actually allow to resize.");
252  }

◆ reverse() [1/2]

template<typename Derived >
DenseBase< Derived >::ReverseReturnType Eigen::DenseBase< Derived >::reverse
inline
Returns
an expression of the reverse of *this.

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the reverse of m:" << endl << m.reverse() << endl;
cout << "Here is the coefficient (1,0) in the reverse of m:" << endl
<< m.reverse()(1,0) << endl;
cout << "Let us overwrite this coefficient with the value 4." << endl;
m.reverse()(1,0) = 4;
cout << "Now the matrix m is:" << endl << m << endl;

Output:

Here is the matrix m:
 7  6 -3  1
-2  9  6  0
 6 -6 -5  3
Here is the reverse of m:
 3 -5 -6  6
 0  6  9 -2
 1 -3  6  7
Here is the coefficient (1,0) in the reverse of m:
0
Let us overwrite this coefficient with the value 4.
Now the matrix m is:
 7  6 -3  1
-2  9  6  4
 6 -6 -5  3

Definition at line 122 of file Reverse.h.

123 {
124  return ReverseReturnType(derived());
125 }
Reverse< Derived, BothDirections > ReverseReturnType
Definition: DenseBase.h:613

◆ reverse() [2/2]

template<typename Derived >
ConstReverseReturnType Eigen::DenseBase< Derived >::reverse ( ) const
inline

This is the const version of reverse().

Definition at line 618 of file DenseBase.h.

619  {
621  }
const Reverse< const Derived, BothDirections > ConstReverseReturnType
Definition: DenseBase.h:614

◆ reverseInPlace()

template<typename Derived >
void Eigen::DenseBase< Derived >::reverseInPlace
inline

This is the "in place" version of reverse: it reverses *this.

In most cases it is probably better to simply use the reversed expression of a matrix. However, when reversing the matrix data itself is really needed, then this "in-place" version is probably the right choice because it provides the following additional benefits:

  • less error prone: doing the same operation with .reverse() requires special care:
    m = m.reverse().eval();
  • this API enables reverse operations without the need for a temporary
  • it allows future optimizations (cache friendliness, etc.)
See also
VectorwiseOp::reverseInPlace(), reverse()

Definition at line 143 of file Reverse.h.

144 {
145  if(cols()>rows())
146  {
147  Index half = cols()/2;
148  leftCols(half).swap(rightCols(half).reverse());
149  if((cols()%2)==1)
150  {
151  Index half2 = rows()/2;
152  col(half).head(half2).swap(col(half).tail(half2).reverse());
153  }
154  }
155  else
156  {
157  Index half = rows()/2;
158  topRows(half).swap(bottomRows(half).reverse());
159  if((rows()%2)==1)
160  {
161  Index half2 = cols()/2;
162  row(half).head(half2).swap(row(half).tail(half2).reverse());
163  }
164  }
165 }
NRowsBlockXpr<... >::Type topRows(NRowsType n)
Definition: BlockMethods.h:570
NColsBlockXpr<... >::Type leftCols(NColsType n)
Definition: BlockMethods.h:797
NColsBlockXpr<... >::Type rightCols(NColsType n)
Definition: BlockMethods.h:872
NRowsBlockXpr<... >::Type bottomRows(NRowsType n)
Definition: BlockMethods.h:645
FixedSegmentReturnType<... >::Type tail(NType n)
ReverseReturnType reverse()
Definition: Reverse.h:122

◆ rowwise() [1/2]

template<typename Derived >
DenseBase< Derived >::RowwiseReturnType Eigen::DenseBase< Derived >::rowwise
inline
Returns
a writable VectorwiseOp wrapper of *this providing additional partial reduction operations
See also
colwise(), class VectorwiseOp, Reductions, visitors and broadcasting

Definition at line 778 of file VectorwiseOp.h.

779 {
780  return RowwiseReturnType(derived());
781 }
VectorwiseOp< Derived, Horizontal > RowwiseReturnType
Definition: DenseBase.h:535

◆ rowwise() [2/2]

template<typename Derived >
ConstRowwiseReturnType Eigen::DenseBase< Derived >::rowwise ( ) const
inline
Returns
a VectorwiseOp wrapper of *this for broadcasting and partial reductions

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the sum of each row:" << endl << m.rowwise().sum() << endl;
cout << "Here is the maximum absolute value of each row:"
<< endl << m.cwiseAbs().rowwise().maxCoeff() << endl;

Output:

Here is the matrix m:
  0.68  0.597  -0.33
-0.211  0.823  0.536
 0.566 -0.605 -0.444
Here is the sum of each row:
 0.948
  1.15
-0.483
Here is the maximum absolute value of each row:
 0.68
0.823
0.605
See also
colwise(), class VectorwiseOp, Reductions, visitors and broadcasting

Definition at line 548 of file DenseBase.h.

548  {
550  }
const VectorwiseOp< const Derived, Horizontal > ConstRowwiseReturnType
Definition: DenseBase.h:536

◆ select() [1/6]

template<typename Derived >
template<typename ThenDerived , typename ElseDerived >
CwiseTernaryOp<internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar, Scalar>, ThenDerived, ElseDerived, Derived> Eigen::DenseBase< Derived >::select ( const DenseBase< ThenDerived > &  thenMatrix,
const DenseBase< ElseDerived > &  elseMatrix 
) const
inline

◆ select() [2/6]

template<typename Derived >
template<typename ThenDerived , typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar, typename DenseBase<Derived>::Scalar>, ThenDerived, ElseDerived, Derived> Eigen::DenseBase< Derived >::select ( const DenseBase< ThenDerived > &  thenMatrix,
const DenseBase< ElseDerived > &  elseMatrix 
) const
inline
Returns
a matrix where each coefficient (i,j) is equal to thenMatrix(i,j) if *this(i,j) != Scalar(0), and elseMatrix(i,j) otherwise.

Example:

MatrixXi m(3, 3);
m << 1, 2, 3,
4, 5, 6,
7, 8, 9;
m = (m.array() >= 5).select(-m, m);
cout << m << endl;
CwiseTernaryOp< internal::scalar_boolean_select_op< typename DenseBase< ThenDerived >::Scalar, typename DenseBase< ElseDerived >::Scalar, Scalar >, ThenDerived, ElseDerived, Derived > select(const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const

Output:

 1  2  3
 4 -5 -6
-7 -8 -9
See also
DenseBase::bitwiseSelect(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&)

Definition at line 131 of file Select.h.

132  {
133  using Op = internal::scalar_boolean_select_op<
136  return CwiseTernaryOp<Op, ThenDerived, ElseDerived, Derived>(
137  thenMatrix.derived(), elseMatrix.derived(), derived(), Op());
138 }

◆ select() [3/6]

template<typename Derived >
template<typename ThenDerived >
CwiseTernaryOp<internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ThenDerived>::Scalar, Scalar>, ThenDerived, typename DenseBase<ThenDerived>::ConstantReturnType, Derived> Eigen::DenseBase< Derived >::select ( const DenseBase< ThenDerived > &  thenMatrix,
const typename DenseBase< ThenDerived >::Scalar elseScalar 
) const
inline

◆ select() [4/6]

template<typename Derived >
template<typename ThenDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op<typename DenseBase<ThenDerived>::Scalar, typename DenseBase<ThenDerived>::Scalar, typename DenseBase<Derived>::Scalar>, ThenDerived, typename DenseBase<ThenDerived>::ConstantReturnType, Derived> Eigen::DenseBase< Derived >::select ( const DenseBase< ThenDerived > &  thenMatrix,
const typename DenseBase< ThenDerived >::Scalar elseScalar 
) const
inline

Version of DenseBase::select(const DenseBase&, const DenseBase&) with the else expression being a scalar value.

See also
DenseBase::booleanSelect(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select

Definition at line 151 of file Select.h.

153  {
154  using ElseConstantType =
155  typename DenseBase<ThenDerived>::ConstantReturnType;
156  using Op = internal::scalar_boolean_select_op<
159  return CwiseTernaryOp<Op, ThenDerived, ElseConstantType, Derived>(
160  thenMatrix.derived(), ElseConstantType(rows(), cols(), elseScalar),
161  derived(), Op());
162 }

◆ select() [5/6]

template<typename Derived >
template<typename ElseDerived >
CwiseTernaryOp<internal::scalar_boolean_select_op<typename DenseBase<ElseDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar, Scalar>, typename DenseBase<ElseDerived>::ConstantReturnType, ElseDerived, Derived> Eigen::DenseBase< Derived >::select ( const typename DenseBase< ElseDerived >::Scalar thenScalar,
const DenseBase< ElseDerived > &  elseMatrix 
) const
inline

◆ select() [6/6]

template<typename Derived >
template<typename ElseDerived >
CwiseTernaryOp< internal::scalar_boolean_select_op<typename DenseBase<ElseDerived>::Scalar, typename DenseBase<ElseDerived>::Scalar, typename DenseBase<Derived>::Scalar>, typename DenseBase<ElseDerived>::ConstantReturnType, ElseDerived, Derived> Eigen::DenseBase< Derived >::select ( const typename DenseBase< ElseDerived >::Scalar thenScalar,
const DenseBase< ElseDerived > &  elseMatrix 
) const
inline

Version of DenseBase::select(const DenseBase&, const DenseBase&) with the then expression being a scalar value.

See also
DenseBase::booleanSelect(const DenseBase<ThenDerived>&, const DenseBase<ElseDerived>&) const, class Select

Definition at line 176 of file Select.h.

178  {
179  using ThenConstantType =
180  typename DenseBase<ElseDerived>::ConstantReturnType;
181  using Op = internal::scalar_boolean_select_op<
184  return CwiseTernaryOp<Op, ThenConstantType, ElseDerived, Derived>(
185  ThenConstantType(rows(), cols(), thenScalar), elseMatrix.derived(),
186  derived(), Op());
187 }

◆ setConstant()

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setConstant ( const Scalar val)
inline

Sets all coefficients in this expression to value val.

See also
fill(), setConstant(Index,const Scalar&), setConstant(Index,Index,const Scalar&), setZero(), setOnes(), Constant(), class CwiseNullaryOp, setZero(), setOnes()

Definition at line 361 of file CwiseNullaryOp.h.

362 {
363  return derived() = Constant(rows(), cols(), val);
364 }

◆ setEqualSpaced() [1/2]

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setEqualSpaced ( const Scalar low,
const Scalar step 
)
inline

Definition at line 479 of file CwiseNullaryOp.h.

480  {
482  return setEqualSpaced(size(), low, step);
483 }
Derived & setEqualSpaced(Index size, const Scalar &low, const Scalar &step)

◆ setEqualSpaced() [2/2]

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setEqualSpaced ( Index  size,
const Scalar low,
const Scalar step 
)
inline

Definition at line 473 of file CwiseNullaryOp.h.

474  {
476  return derived() = Derived::NullaryExpr(newSize, internal::equalspaced_op<Scalar>(low, step));
477 }

◆ setLinSpaced() [1/2]

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setLinSpaced ( const Scalar low,
const Scalar high 
)
inline

Sets a linearly spaced vector.

The function fills *this with equally spaced values in the closed interval [low,high]. When size is set to 1, a vector of length 1 containing 'high' is returned.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

For integer scalar types, do not miss the explanations on the definition of even spacing .

See also
LinSpaced(Index,const Scalar&,const Scalar&), setLinSpaced(Index, const Scalar&, const Scalar&), CwiseNullaryOp

Definition at line 466 of file CwiseNullaryOp.h.

467 {
469  return setLinSpaced(size(), low, high);
470 }
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.

◆ setLinSpaced() [2/2]

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setLinSpaced ( Index  newSize,
const Scalar low,
const Scalar high 
)
inline

Sets a linearly spaced vector.

The function generates 'size' equally spaced values in the closed interval [low,high]. When size is set to 1, a vector of length 1 containing 'high' is returned.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

Example:

v.setLinSpaced(5,0.5f,1.5f);
cout << v << endl;
Matrix< float, Dynamic, 1 > VectorXf
Dynamic×1 vector of type float.
Definition: Matrix.h:501

Output:

 0.5
0.75
   1
1.25
 1.5

For integer scalar types, do not miss the explanations on the definition of even spacing .

See also
LinSpaced(Index,const Scalar&,const Scalar&), CwiseNullaryOp

Definition at line 446 of file CwiseNullaryOp.h.

447 {
449  return derived() = Derived::NullaryExpr(newSize, internal::linspaced_op<Scalar>(low,high,newSize));
450 }

◆ setOnes()

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setOnes
inline

Sets all coefficients in this expression to one.

Example:

m.row(1).setOnes();
cout << m << endl;
Matrix< int, 4, 4 > Matrix4i
4×4 matrix of type int.
Definition: Matrix.h:500

Output:

 7  9 -5 -3
 1  1  1  1
 6 -3  0  9
 6  6  3  9
See also
class CwiseNullaryOp, Ones()

Definition at line 727 of file CwiseNullaryOp.h.

728 {
729  return setConstant(Scalar(1));
730 }

◆ setRandom()

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setRandom
inline

Sets all coefficients in this expression to random values.

Numbers are uniformly spread through their whole definition range for integer types, and in the [-1:1] range for floating point scalar types.

Warning
This function is not re-entrant.

Example:

m.col(1).setRandom();
cout << m << endl;

Output:

 0  7  0  0
 0 -2  0  0
 0  6  0  0
 0  6  0  0
See also
class CwiseNullaryOp, setRandom(Index), setRandom(Index,Index)

Definition at line 132 of file Random.h.

133 {
134  return *this = Random(rows(), cols());
135 }

◆ setZero()

template<typename Derived >
Derived & Eigen::DenseBase< Derived >::setZero
inline

Sets all coefficients in this expression to zero.

Example:

m.row(1).setZero();
cout << m << endl;

Output:

 7  9 -5 -3
 0  0  0  0
 6 -3  0  9
 6  6  3  9
See also
class CwiseNullaryOp, Zero()

Definition at line 575 of file CwiseNullaryOp.h.

576 {
577  return setConstant(Scalar(0));
578 }

◆ sum()

template<typename Derived >
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::sum
inline
Returns
the sum of all coefficients of *this

If *this is empty, then the value 0 is returned.

See also
trace(), prod(), mean()

Definition at line 546 of file Redux.h.

547 {
548  if(SizeAtCompileTime==0 || (SizeAtCompileTime==Dynamic && size()==0))
549  return Scalar(0);
550  return derived().redux(Eigen::internal::scalar_sum_op<Scalar,Scalar>());
551 }

◆ swap() [1/2]

template<typename Derived >
template<typename OtherDerived >
void Eigen::DenseBase< Derived >::swap ( const DenseBase< OtherDerived > &  other)
inline

swaps *this with the expression other.

Definition at line 418 of file DenseBase.h.

419  {
420  EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
421  eigen_assert(rows()==other.rows() && cols()==other.cols());
422  call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
423  }

◆ swap() [2/2]

template<typename Derived >
template<typename OtherDerived >
void Eigen::DenseBase< Derived >::swap ( PlainObjectBase< OtherDerived > &  other)
inline

swaps *this with the matrix or array other.

Definition at line 430 of file DenseBase.h.

431  {
432  eigen_assert(rows()==other.rows() && cols()==other.cols());
433  call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
434  }

◆ trace()

template<typename Derived >
Scalar Eigen::DenseBase< Derived >::trace ( ) const

◆ transpose() [1/2]

template<typename Derived >
DenseBase< Derived >::TransposeReturnType Eigen::DenseBase< Derived >::transpose
inline
Returns
an expression of the transpose of *this.

Example:

cout << "Here is the matrix m:" << endl << m << endl;
cout << "Here is the transpose of m:" << endl << m.transpose() << endl;
cout << "Here is the coefficient (1,0) in the transpose of m:" << endl
<< m.transpose()(1,0) << endl;
cout << "Let us overwrite this coefficient with the value 0." << endl;
m.transpose()(1,0) = 0;
cout << "Now the matrix m is:" << endl << m << endl;
Matrix< int, 2, 2 > Matrix2i
2×2 matrix of type int.
Definition: Matrix.h:500

Output:

Here is the matrix m:
 7  6
-2  6
Here is the transpose of m:
 7 -2
 6  6
Here is the coefficient (1,0) in the transpose of m:
6
Let us overwrite this coefficient with the value 0.
Now the matrix m is:
 7  0
-2  6
Warning
If you want to replace a matrix by its own transpose, do NOT do this:
m = m.transpose(); // bug!!! caused by aliasing effect
Instead, use the transposeInPlace() method:
m.transposeInPlace();
which gives Eigen good opportunities for optimization, or alternatively you can also do:
m = m.transpose().eval();
See also
transposeInPlace(), adjoint()

Definition at line 184 of file Transpose.h.

185 {
186  return TransposeReturnType(derived());
187 }
Transpose< Derived > TransposeReturnType
Definition: DenseBase.h:315

◆ transpose() [2/2]

template<typename Derived >
const DenseBase< Derived >::ConstTransposeReturnType Eigen::DenseBase< Derived >::transpose
inline

This is the const version of transpose().

Make sure you read the warning for transpose() !

See also
transposeInPlace(), adjoint()

Definition at line 197 of file Transpose.h.

198 {
200 }
Transpose< const Derived > ConstTransposeReturnType
Definition: DenseBase.h:318

◆ transposeInPlace()

template<typename Derived >
void Eigen::DenseBase< Derived >::transposeInPlace
inline

This is the "in place" version of transpose(): it replaces *this by its own transpose. Thus, doing

m.transposeInPlace();

has the same effect on m as doing

m = m.transpose().eval();

and is faster and also safer because in the latter line of code, forgetting the eval() results in a bug caused by aliasing.

Notice however that this method is only useful if you want to replace a matrix by its own transpose. If you just need the transpose of a matrix, use transpose().

Note
if the matrix is not square, then *this must be a resizable matrix. This excludes (non-square) fixed-size matrices, block-expressions and maps.
See also
transpose(), adjoint(), adjointInPlace()

Definition at line 346 of file Transpose.h.

347 {
349  && "transposeInPlace() called on a non-square non-resizable matrix");
350  internal::inplace_transpose_selector<Derived>::run(derived());
351 }

◆ value()

template<typename Derived >
CoeffReturnType Eigen::DenseBase< Derived >::value ( ) const
inline
Returns
the unique coefficient of a 1x1 expression

Definition at line 524 of file DenseBase.h.

525  {
527  eigen_assert(this->rows() == 1 && this->cols() == 1);
528  return derived().coeff(0,0);
529  }
#define EIGEN_STATIC_ASSERT_SIZE_1x1(TYPE)
Definition: StaticAssert.h:91

◆ visit()

template<typename Derived >
template<typename Visitor >
void Eigen::DenseBase< Derived >::visit ( Visitor &  visitor) const

Applies the visitor visitor to the whole coefficients of the matrix or vector.

The template parameter Visitor is the type of the visitor and provides the following interface:

struct MyVisitor {
// called for the first coefficient
void init(const Scalar& value, Index i, Index j);
// called for all other coefficients
void operator() (const Scalar& value, Index i, Index j);
};
Note
compared to one or two for loops, visitors offer automatic unrolling for small fixed size matrix.
if the matrix is empty, then the visitor is left unchanged.
See also
minCoeff(Index*,Index*), maxCoeff(Index*,Index*), DenseBase::redux()

Definition at line 413 of file Visitor.h.

414 {
415  using impl = internal::visit_impl<Derived, Visitor, /*ShortCircuitEvaulation*/false>;
416  impl::run(derived(), visitor);
417 }

◆ Zero() [1/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Zero
inlinestatic
Returns
an expression of a fixed-size zero matrix or vector.

This variant is only for fixed-size MatrixBase types. For dynamic-size types, you need to use the variants taking size arguments.

Example:

cout << Matrix2d::Zero() << endl;
cout << RowVector4i::Zero() << endl;

Output:

0 0
0 0
0 0 0 0
See also
Zero(Index), Zero(Index,Index)

Definition at line 543 of file CwiseNullaryOp.h.

544 {
545  return Constant(Scalar(0));
546 }

◆ Zero() [2/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Zero ( Index  rows,
Index  cols 
)
inlinestatic
Returns
an expression of a zero matrix.

The parameters rows and cols are the number of rows and of columns of the returned matrix. Must be compatible with this MatrixBase type.

This variant is meant to be used for dynamic-size matrix types. For fixed-size types, it is redundant to pass rows and cols as arguments, so Zero() should be used instead.

Example:

cout << MatrixXi::Zero(2,3) << endl;

Output:

0 0 0
0 0 0
See also
Zero(), Zero(Index)

Definition at line 503 of file CwiseNullaryOp.h.

504 {
505  return Constant(rows, cols, Scalar(0));
506 }

◆ Zero() [3/3]

template<typename Derived >
const DenseBase< Derived >::ConstantReturnType Eigen::DenseBase< Derived >::Zero ( Index  size)
inlinestatic
Returns
an expression of a zero vector.

The parameter size is the size of the returned vector. Must be compatible with this MatrixBase type.

This is only for vectors (either row-vectors or column-vectors), i.e. matrices which are known at compile-time to have either one row or one column.

This variant is meant to be used for dynamic-size vector types. For fixed-size types, it is redundant to pass size as argument, so Zero() should be used instead.

Example:

cout << RowVectorXi::Zero(4) << endl;
cout << VectorXf::Zero(2) << endl;

Output:

0 0 0 0
0
0
See also
Zero(), Zero(Index,Index)

Definition at line 526 of file CwiseNullaryOp.h.

527 {
528  return Constant(size, Scalar(0));
529 }

Friends And Related Function Documentation

◆ operator<<()

template<typename Derived >
std::ostream & operator<< ( std::ostream &  s,
const DenseBase< Derived > &  m 
)
related

Outputs the matrix, to the given stream.

If you wish to print the matrix with a format different than the default, use DenseBase::format().

It is also possible to change the default format by defining EIGEN_DEFAULT_IO_FORMAT before including Eigen headers. If not defined, this will automatically be defined to Eigen::IOFormat(), that is the Eigen::IOFormat with default parameters.

See also
DenseBase::format()

Definition at line 249 of file IO.h.

252 {
254 }
#define EIGEN_DEFAULT_IO_FORMAT
Definition: Macros.h:1065
std::ostream & print_matrix(std::ostream &s, const Derived &_m, const IOFormat &fmt)
Definition: IO.h:133

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