Eigen  5.0.1-dev
 
Loading...
Searching...
No Matches
Public Member Functions | Related Symbols | List of all members
Eigen::ArrayBase< Derived > Class Template Reference

#include <Eigen/src/Core/ArrayBase.h>

Detailed Description

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

Base class for all 1D and 2D array, and related expressions.

An array is similar to a dense vector or matrix. While matrices are mathematical objects with well defined linear algebra operators, an array is just a collection of scalar values arranged in a one or two dimensional fashion. As the main consequence, all operations applied to an array are performed coefficient wise. Furthermore, arrays support scalar math functions of the c++ standard library (e.g., std::sin(x)), and convenient constructors allowing to easily write generic code working for both scalar values and arrays.

This class is the base that is inherited by all array expression types.

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

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

See also
class MatrixBase, The class hierarchy
+ Inheritance diagram for Eigen::ArrayBase< Derived >:

Public Member Functions

MatrixWrapper< Derived > matrix ()
 
template<typename OtherDerived >
Derived & operator*= (const ArrayBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator+= (const ArrayBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator-= (const ArrayBase< OtherDerived > &other)
 
template<typename OtherDerived >
Derived & operator/= (const ArrayBase< OtherDerived > &other)
 
Derived & operator= (const ArrayBase &other)
 
Derived & operator= (const Scalar &value)
 
- Public Member Functions inherited from Eigen::DenseBase< Derived >
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
 
void fill (const Scalar &value)
 
template<unsigned int Added, unsigned int Removed>
EIGEN_DEPRECATED const Derived & flagged () const
 
const WithFormat< Derived > format (const IOFormat &fmt) const
 
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
 
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 >
EIGEN_DEPRECATED Derived & lazyAssign (const DenseBase< OtherDerived > &other)
 
template<int NaNPropagation>
internal::traits< Derived >::Scalar maxCoeff () const
 
template<int NaNPropagation, 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
 
Scalar mean () const
 
template<int NaNPropagation>
internal::traits< Derived >::Scalar minCoeff () const
 
template<int NaNPropagation, 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
 
const NestByValue< Derived > nestByValue () const
 
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.
 
constexpr Index outerSize () const
 
Scalar prod () 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, Dynamic > replicate (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, 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, 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, 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 & setLinSpaced (const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector.
 
Derived & setLinSpaced (Index size, const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector.
 
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)
 
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 >
constexpr Index cols () const noexcept
 
constexpr Index colStride () const noexcept
 
constexpr Derived & derived ()
 
constexpr const Derived & derived () const
 
constexpr Index innerStride () const noexcept
 
constexpr Index outerStride () const noexcept
 
constexpr Index rows () const noexcept
 
constexpr Index rowStride () const noexcept
 
constexpr Index size () const noexcept
 
- Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, WriteAccessors >
constexpr CoeffReturnType coeff (Index index) const
 
constexpr CoeffReturnType coeff (Index row, Index col) const
 
constexpr Scalar & coeffRef (Index index)
 
constexpr Scalar & coeffRef (Index row, Index col)
 
constexpr Index cols () const noexcept
 
constexpr Derived & derived ()
 
constexpr const Derived & derived () const
 
constexpr Scalar & operator() (Index index)
 
constexpr Scalar & operator() (Index row, Index col)
 
constexpr Scalar & operator[] (Index index)
 
constexpr Index rows () const noexcept
 
constexpr Index size () const noexcept
 
constexpr Scalar & w ()
 
constexpr CoeffReturnType w () const
 
constexpr Scalar & x ()
 
constexpr CoeffReturnType x () const
 
constexpr Scalar & y ()
 
constexpr CoeffReturnType y () const
 
constexpr Scalar & z ()
 
constexpr CoeffReturnType z () const
 
- Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, ReadOnlyAccessors >
constexpr CoeffReturnType coeff (Index index) const
 
constexpr CoeffReturnType coeff (Index row, Index col) const
 
constexpr Index cols () const noexcept
 
constexpr Derived & derived ()
 
constexpr const Derived & derived () const
 
constexpr CoeffReturnType operator() (Index index) const
 
constexpr CoeffReturnType operator() (Index row, Index col) const
 
constexpr CoeffReturnType operator[] (Index index) const
 
constexpr Index rows () const noexcept
 
constexpr Index size () const noexcept
 
constexpr CoeffReturnType w () const
 
constexpr CoeffReturnType x () const
 
constexpr CoeffReturnType y () const
 
constexpr CoeffReturnType z () const
 
- Public Member Functions inherited from Eigen::EigenBase< Derived >
constexpr Index cols () const noexcept
 
constexpr Derived & derived ()
 
constexpr const Derived & derived () const
 
constexpr Index rows () const noexcept
 
constexpr Index size () const noexcept
 

Related Symbols

(Note that these are not member symbols.)

template<typename LhsDerived , typename RhsDerived >
const std::enable_if_t< std::is_same< typename LhsDerived::Scalar, typename RhsDerived::Scalar >::value, Eigen::CwiseBinaryOp< Eigen::internal::scalar_atan2_op< typename LhsDerived::Scalar, typename RhsDerived::Scalar >, const LhsDerived, const RhsDerived > > atan2 (const Eigen::ArrayBase< LhsDerived > &x, const Eigen::ArrayBase< RhsDerived > &exponents)
 
template<typename Derived , typename ExponentDerived >
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar, typename ExponentDerived::Scalar >, const Derived, const ExponentDerived > pow (const Eigen::ArrayBase< Derived > &x, const Eigen::ArrayBase< ExponentDerived > &exponents)
 
template<typename Derived , typename ScalarExponent >
const GlobalUnaryPowReturnType< Derived, ScalarExponent > pow (const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
 
template<typename Scalar , typename Derived >
const CwiseBinaryOp< internal::scalar_pow_op< Scalar, Derived::Scalar >, Constant< Scalar >, Derived > pow (const Scalar &x, const Eigen::ArrayBase< Derived > &x)
 

Additional Inherited Members

- Public Types inherited from Eigen::DenseBase< Derived >
enum  {
  RowsAtCompileTime ,
  ColsAtCompileTime ,
  SizeAtCompileTime ,
  MaxRowsAtCompileTime ,
  MaxColsAtCompileTime ,
  MaxSizeAtCompileTime ,
  IsVectorAtCompileTime ,
  NumDimensions ,
  Flags ,
  IsRowMajor ,
  InnerSizeAtCompileTime ,
  InnerStrideAtCompileTime ,
  OuterStrideAtCompileTime
}
 
typedef random_access_iterator_type const_iterator
 
typedef Eigen::InnerIterator< Derived > InnerIterator
 
typedef random_access_iterator_type iterator
 
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 > PlainArray
 
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 > PlainMatrix
 
typedef std::conditional_t< internal::is_same< typename internal::traits< Derived >::XprKind, MatrixXpr >::value, PlainMatrix, PlainArray > PlainObject
 The plain matrix or array type corresponding to this expression.
 
typedef internal::traits< Derived >::Scalar Scalar
 
typedef internal::traits< Derived >::StorageIndex StorageIndex
 The type used to store indices.
 
typedef Scalar value_type
 
- Public Types inherited from Eigen::EigenBase< Derived >
typedef Eigen::Index Index
 The interface type of indices.
 
- Static Public Member Functions inherited from Eigen::DenseBase< Derived >
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 RandomAccessLinSpacedReturnType LinSpaced (const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector.
 
static const RandomAccessLinSpacedReturnType LinSpaced (Index size, const Scalar &low, const Scalar &high)
 Sets a linearly spaced vector.
 
static const RandomAccessLinSpacedReturnType LinSpaced (Sequential_t, const Scalar &low, const Scalar &high)
 
static const RandomAccessLinSpacedReturnType LinSpaced (Sequential_t, Index size, const Scalar &low, const Scalar &high)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr (const CustomNullaryOp &func)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr (Index rows, Index cols, const CustomNullaryOp &func)
 
template<typename CustomNullaryOp >
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr (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 ZeroReturnType Zero ()
 
static const ZeroReturnType Zero (Index rows, Index cols)
 
static const ZeroReturnType Zero (Index size)
 
- Protected Member Functions inherited from Eigen::DenseBase< Derived >
constexpr DenseBase ()=default
 

Member Function Documentation

◆ matrix()

template<typename Derived >
MatrixWrapper< Derived > Eigen::ArrayBase< Derived >::matrix ( )
inline
Returns
an Matrix expression of this array
See also
MatrixBase::array()

◆ operator*=()

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

replaces *this by *this * other coefficient wise.

Returns
a reference to *this

◆ operator+=()

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

replaces *this by *this + other.

Returns
a reference to *this

◆ operator-=()

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

replaces *this by *this - other.

Returns
a reference to *this

◆ operator/=()

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

replaces *this by *this / other coefficient wise.

Returns
a reference to *this

◆ operator=() [1/2]

template<typename Derived >
Derived & Eigen::ArrayBase< Derived >::operator= ( const ArrayBase< 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)

◆ operator=() [2/2]

template<typename Derived >
Derived & Eigen::ArrayBase< Derived >::operator= ( const Scalar &  value)
inline

Set all the entries to value.

See also
DenseBase::setConstant(), DenseBase::fill()

Friends And Related Symbol Documentation

◆ atan2()

template<typename LhsDerived , typename RhsDerived >
const std::enable_if_t< std::is_same< typename LhsDerived::Scalar, typename RhsDerived::Scalar >::value, Eigen::CwiseBinaryOp< Eigen::internal::scalar_atan2_op< typename LhsDerived::Scalar, typename RhsDerived::Scalar >, const LhsDerived, const RhsDerived > > atan2 ( const Eigen::ArrayBase< LhsDerived > &  x,
const Eigen::ArrayBase< RhsDerived > &  exponents 
)
related
Returns
an expression of the coefficient-wise atan2(x, y). x and y must be of the same type.

This function computes the coefficient-wise atan2().

See also
ArrayBase::atan2()

◆ pow() [1/3]

template<typename Derived , typename ExponentDerived >
const Eigen::CwiseBinaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar, typename ExponentDerived::Scalar >, const Derived, const ExponentDerived > pow ( const Eigen::ArrayBase< Derived > &  x,
const Eigen::ArrayBase< ExponentDerived > &  exponents 
)
related
Returns
an expression of the coefficient-wise power of x to the given array of exponents.

This function computes the coefficient-wise power.

Example:

Array<double, 1, 3> x(8, 25, 3), e(1. / 3., 0.5, 2.);
cout << "[" << x << "]^[" << e << "] = " << x.pow(e) << endl; // using ArrayBase::pow
cout << "[" << x << "]^[" << e << "] = " << pow(x, e) << endl; // using Eigen::pow
const GlobalUnaryPowReturnType< Derived, ScalarExponent > pow(const Eigen::ArrayBase< Derived > &x, const ScalarExponent &exponent)
General-purpose arrays with easy API for coefficient-wise operations.
Definition Array.h:48
constexpr Scalar & x()
Definition DenseCoeffsBase.h:377

Output:

[ 8 25  3]^[0.333   0.5     2] = 2 5 9
[ 8 25  3]^[0.333   0.5     2] = 2 5 9
See also
ArrayBase::pow()

◆ pow() [2/3]

template<typename Derived , typename ScalarExponent >
const GlobalUnaryPowReturnType< Derived, ScalarExponent > pow ( const Eigen::ArrayBase< Derived > &  x,
const ScalarExponent &  exponent 
)
related
Returns
an expression of the coefficient-wise power of x to the given constant exponent.
Template Parameters
ScalarExponentis the scalar type of exponent. It must be compatible with the scalar type of the given expression (Derived::Scalar).
See also
ArrayBase::pow()

◆ pow() [3/3]

template<typename Scalar , typename Derived >
const CwiseBinaryOp< internal::scalar_pow_op< Scalar, Derived::Scalar >, Constant< Scalar >, Derived > pow ( const Scalar &  x,
const Eigen::ArrayBase< Derived > &  x 
)
related
Returns
an expression of the coefficient-wise power of the scalar x to the given array of exponents.

This function computes the coefficient-wise power between a scalar and an array of exponents.

Template Parameters
Scalaris the scalar type of x. It must be compatible with the scalar type of the given array expression (Derived::Scalar).

Example:

Array<double, 1, 3> e(2, -3, 1. / 3.);
cout << "10^[" << e << "] = " << pow(10, e) << endl;

Output:

10^[    2    -3 0.333] =   100 0.001  2.15
See also
ArrayBase::pow()

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