![]() |
Eigen
3.4.90 (git rev 9589cc4e7fd8e4538bedef80dd36c7738977a8be)
|
#include <Eigen/src/Core/Array.h>
General-purpose arrays with easy API for coefficient-wise operations.
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
.
Public Member Functions | |
constexpr | Array ()=default |
constexpr | Array (Array &&)=default |
Move constructor. | |
constexpr | Array (const Array &)=default |
template<typename OtherDerived> | |
Array (const EigenBase< OtherDerived > &other, std::enable_if_t< internal::is_convertible< typename OtherDerived::Scalar, Scalar >::value, PrivateType >=PrivateType()) | |
template<typename... ArgTypes> | |
Array (const Scalar &a0, const Scalar &a1, const Scalar &a2, const Scalar &a3, const ArgTypes &... args) | |
Construct a row of column vector with fixed size from an arbitrary number of coefficients. | |
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 Scalar &value) | |
Array (const Scalar *data) | |
Constructs a fixed-sized array initialized with coefficients starting at data. | |
constexpr | Array (const std::initializer_list< std::initializer_list< Scalar > > &list) |
Constructs an array and initializes it from the coefficients given as initializer-lists grouped by row. [c++11] | |
Array (Index dim) | |
Array (Index rows, Index cols) | |
constexpr const Scalar & | coeff (Index index) const |
constexpr const Scalar & | coeff (Index rowId, Index colId) const |
constexpr Scalar & | coeffRef (Index index) |
constexpr const Scalar & | coeffRef (Index index) const |
constexpr Scalar & | coeffRef (Index rowId, Index colId) |
constexpr const Scalar & | coeffRef (Index rowId, Index colId) const |
Array & | operator= (const Array &other) |
Assigns arrays to each other. | |
template<typename OtherDerived> | |
Array & | operator= (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived> | |
Array & | operator= (const EigenBase< OtherDerived > &other) |
Array & | operator= (const Scalar &value) |
![]() | |
constexpr const Scalar & | coeff (Index index) const |
constexpr const Scalar & | coeff (Index rowId, Index colId) const |
constexpr Scalar & | coeffRef (Index index) |
constexpr const Scalar & | coeffRef (Index index) const |
constexpr Scalar & | coeffRef (Index rowId, Index colId) |
constexpr const Scalar & | coeffRef (Index rowId, Index colId) const |
void | conservativeResize (Index rows, Index cols) |
void | conservativeResize (Index rows, NoChange_t) |
void | conservativeResize (Index size) |
void | conservativeResize (NoChange_t, Index cols) |
template<typename OtherDerived> | |
void | conservativeResizeLike (const DenseBase< OtherDerived > &other) |
constexpr Scalar * | data () |
constexpr const Scalar * | data () const |
template<typename OtherDerived> | |
Derived & | lazyAssign (const DenseBase< OtherDerived > &other) |
template<typename OtherDerived> | |
Derived & | operator= (const EigenBase< OtherDerived > &other) |
Copies the generic expression other into *this. | |
constexpr Derived & | operator= (const PlainObjectBase &other) |
constexpr void | resize (Index rows, Index cols) |
constexpr void | resize (Index rows, NoChange_t) |
constexpr void | resize (Index size) |
constexpr void | resize (NoChange_t, Index cols) |
template<typename OtherDerived> | |
void | resizeLike (const EigenBase< OtherDerived > &_other) |
Derived & | setConstant (Index rows, Index cols, const Scalar &val) |
Derived & | setConstant (Index rows, NoChange_t, const Scalar &val) |
Derived & | setConstant (Index size, const Scalar &val) |
Derived & | setConstant (NoChange_t, Index cols, const Scalar &val) |
Derived & | setOnes (Index rows, Index cols) |
Derived & | setOnes (Index rows, NoChange_t) |
Derived & | setOnes (Index size) |
Derived & | setOnes (NoChange_t, Index cols) |
Derived & | setRandom (Index rows, Index cols) |
Derived & | setRandom (Index rows, NoChange_t) |
Derived & | setRandom (Index size) |
Derived & | setRandom (NoChange_t, Index cols) |
Derived & | setZero (Index rows, Index cols) |
Derived & | setZero (Index rows, NoChange_t) |
Derived & | setZero (Index size) |
Derived & | setZero (NoChange_t, Index cols) |
Additional Inherited Members | |
![]() | |
template<typename OtherDerived> | |
constexpr Derived & | _set (const DenseBase< OtherDerived > &other) |
Copies the value of the expression other into *this with automatic resizing. | |
constexpr PlainObjectBase & | operator= (PlainObjectBase &&other) EIGEN_NOEXCEPT |
Move assignment operator. | |
template<typename OtherDerived> | |
PlainObjectBase (const DenseBase< OtherDerived > &other) | |
template<typename OtherDerived> | |
PlainObjectBase (const EigenBase< OtherDerived > &other) | |
constexpr | PlainObjectBase (const PlainObjectBase &)=default |
template<typename OtherDerived> | |
PlainObjectBase (const ReturnByValue< OtherDerived > &other) | |
Copy constructor with in-place evaluation. | |
template<typename... ArgTypes> | |
PlainObjectBase (const Scalar &a0, const Scalar &a1, const Scalar &a2, const Scalar &a3, const ArgTypes &... args) | |
Construct a row of column vector with fixed size from an arbitrary number of coefficients. | |
constexpr | PlainObjectBase (const std::initializer_list< std::initializer_list< Scalar > > &list) |
Constructs a Matrix or Array and initializes it by elements given by an initializer list of initializer lists. | |
constexpr | PlainObjectBase (PlainObjectBase &&)=default |
Move constructor. | |
|
inlineconstexprdefault |
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.
|
inline |
Construct a row of column vector with fixed size from an arbitrary number of coefficients.
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 constructor is for 1D array or vectors with more than 4 coefficients.
*this
.Example:
Output:
1 2 3 4 5 6 1 2 3
|
inlineconstexpr |
Constructs an array and initializes it from the coefficients given as initializer-lists grouped by row. [c++11]
In the general case, the constructor takes a list of rows, each row being represented as a list of coefficients:
Example:
Output:
1 2 3 3 4 5
Each of the inner initializer lists must contain the exact same number of elements, otherwise an assertion is triggered.
In the case of a compile-time column 1D array, implicit transposition from a single row is allowed. Therefore Array<int,Dynamic,1>{{1,2,3,4,5}}
is legal and the more verbose syntax Array<int,Dynamic,1>{{1},{2},{3},{4},{5}}
can be avoided:
Example:
Output:
1 2 3 4 5
In the case of fixed-sized arrays, the initializer list sizes must exactly match the array sizes, and implicit transposition is allowed for compile-time 1D arrays only.
|
inlineexplicit |
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.
Eigen::Array< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ >::Array | ( | const Scalar & | value | ) |
constructs an initialized 1x1 Array with the given coefficient
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.
Eigen::Array< Scalar_, Rows_, Cols_, Options_, MaxRows_, MaxCols_ >::Array | ( | const Scalar & | val0, |
const Scalar & | val1 ) |
constructs an initialized 2D vector with given coefficients
|
inline |
constructs an initialized 3D vector with given coefficients
|
inline |
constructs an initialized 4D vector with given coefficients
|
inlineconstexprdefault |
Copy constructor
|
inline |
|
inlineconstexpr |
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details.
|
inlineconstexpr |
This is an overloaded version of DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index,Index) const provided to by-pass the creation of an evaluator of the expression, thus saving compilation efforts.
See DenseCoeffsBase<Derived,ReadOnlyAccessors>::coeff(Index) const for details.
|
inlineconstexpr |
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.
|
inlineconstexpr |
This is the const version of coeffRef(Index) which is thus synonym of coeff(Index). It is provided for convenience.
|
inlineconstexpr |
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.
|
inlineconstexpr |
This is the const version of coeffRef(Index,Index) which is thus synonym of coeff(Index,Index). It is provided for convenience.
|
inline |
Assigns arrays to each other.
|
inline |
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.
|
inline |
The usage of using Base::operator=; fails on MSVC. Since the code below is working with GCC and MSVC, we skipped the usage of 'using'. This should be done only for operator=.
|
inline |
Set all the entries to value.