template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Array class
General-purpose arrays with easy API for coefficient-wise operations.
Contents
The Array class is very similar to the Matrix class. It provides general-purpose one- and two-dimensional arrays. The difference between the Array and the Matrix class is primarily in the API: the API for the Array class provides easy access to coefficient-wise operations, while the API for the Matrix class provides easy access to linear-algebra operations.
See documentation of class Matrix for detailed information on the template parameters storage layout.
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_ARRAY_PLUGIN
.
Base classes
-
template<typename Derived>class PlainObjectBase
- Dense storage base class for matrices and arrays.
Constructors, destructors, conversion operators
- Array()
- Array(const Scalar* data) explicit
- Constructs a fixed-sized array initialized with coefficients starting at data.
- Array(Index dim) explicit
- Array(const Scalar& value)
- Array(Index rows, Index cols)
- Array(const Scalar& val0, const Scalar& val1)
- Array(const Scalar& val0, const Scalar& val1, const Scalar& val2)
- Array(const Scalar& val0, const Scalar& val1, const Scalar& val2, const Scalar& val3)
- Array(const Array& other)
-
template<typename OtherDerived>Array(const EigenBase<OtherDerived>& other, typename internal::enable_if<internal::is_convertible<typename OtherDerived::Scalar, Scalar>::value, PrivateType>::type = PrivateType())
Public functions
- auto coeff() const -> const Scalar&
- auto coeff() const -> const Scalar&
- auto coeffRef() -> Scalar&
- auto coeffRef() -> Scalar&
- auto coeffRef() const -> const Scalar&
- auto coeffRef() const -> const Scalar&
-
template<typename OtherDerived>auto operator=(const EigenBase<OtherDerived>& other) -> Array&
- auto operator=(const Scalar& value) -> Array&
-
template<typename OtherDerived>auto operator=(const DenseBase<OtherDerived>& other) -> Array&
- auto operator=(const Array& other) -> Array&
Function documentation
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: Array()
Default constructor.
For fixed-size matrices, does nothing.
For dynamic-size matrices, creates an empty matrix of size 0. Does not allocate any array. Such a matrix is called a null matrix. This constructor is the unique way to create null matrices: resizing a matrix to 0 is not supported.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: Array(Index dim) explicit
Constructs a vector or row-vector with given dimension. 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.
Note that this is only useful for dynamic-size vectors. For fixed-size vectors, it is redundant to pass the dimension here, so it makes more sense to use the default constructor Array() instead.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: Array(Index rows,
Index cols)
constructs an uninitialized array with rows rows and cols columns.
This is useful for dynamic-size arrays. For fixed-size arrays, it is redundant to pass these parameters, so one should use the default constructor Array() instead.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: Array(const Scalar& val0,
const Scalar& val1,
const Scalar& val2,
const Scalar& val3)
constructs an initialized 4D vector with given coefficients
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: Array(const EigenBase<OtherDerived>& other,
typename internal::enable_if<internal::is_convertible<typename OtherDerived::Scalar, Scalar>::value, PrivateType>::type = PrivateType())
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
const Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeff() const
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::
See DenseCoeffsBase<Derived,ReadOnlyAccessors>::
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
const Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeff() const
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::
See DenseCoeffsBase<Derived,ReadOnlyAccessors>::
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeffRef()
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
See DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index) const for details.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeffRef()
This is an overloaded version of DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
See DenseCoeffsBase<Derived,WriteAccessors>::coeffRef(Index,Index) const for details.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
const Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeffRef() const
This is the const version of coeffRef(Index) which is thus synonym of coeff(Index). It is provided for convenience.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
const Scalar& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: coeffRef() const
This is the const version of coeffRef(Index,Index) which is thus synonym of coeff(Index,Index). It is provided for convenience.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
Array& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: operator=(const EigenBase<OtherDerived>& other)
The usage of using Base::
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
template<typename OtherDerived>
Array& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: operator=(const DenseBase<OtherDerived>& other)
Copies the value of the expression other into *this
with automatic resizing.
*this might be resized to match the dimensions of other. If *this was a null matrix (not already initialized), it will be initialized.
Note that copying a row-vector into a vector (and conversely) is allowed. The resizing, if any, is then done in the appropriate way so that row-vectors remain row-vectors and vectors remain vectors.
template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
Array& Eigen:: Array<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>:: operator=(const Array& other)
This is a special case of the templated operator=. Its purpose is to prevent a default operator= from hiding the templated operator=.