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.
Derived | is 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
.
enum | { RowsAtCompileTime , ColsAtCompileTime , SizeAtCompileTime , MaxRowsAtCompileTime , MaxColsAtCompileTime , MaxSizeAtCompileTime , IsVectorAtCompileTime , NumDimensions , Flags , IsRowMajor , InnerSizeAtCompileTime , InnerStrideAtCompileTime , OuterStrideAtCompileTime } |
typedef random_access_iterator_type | const_iterator |
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 internal::conditional< internal::is_same< typename internal::traits< Derived >::XprKind, MatrixXpr >::value, PlainMatrix, PlainArray >::type | PlainObject |
The plain matrix or array type corresponding to this expression. More... |
|
typedef internal::traits< Derived >::Scalar | Scalar |
typedef internal::traits< Derived >::StorageIndex | StorageIndex |
The type used to store indices. More... |
|
typedef Scalar | value_type |
Public Types inherited from Eigen::EigenBase< Derived > | |
typedef Eigen::Index | Index |
The interface type of indices. More... |
|
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 |
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 |
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 |
EIGEN_CONSTEXPR Index | nonZeros () 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. More... |
|
EIGEN_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 > | |
const Select< Derived, ThenDerived, ElseDerived > | select (const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const |
template<typename ThenDerived > | |
const Select< Derived, ThenDerived, typename ThenDerived::ConstantReturnType > | select (const DenseBase< ThenDerived > &thenMatrix, const typename ThenDerived::Scalar &elseScalar) const |
template<typename ElseDerived > | |
const Select< Derived, typename ElseDerived::ConstantReturnType, ElseDerived > | select (const typename 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. 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) |
TransposeReturnType | transpose () |
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 |
Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, WriteAccessors > | |
Scalar & | coeffRef (Index index) |
Scalar & | coeffRef (Index row, Index col) |
EIGEN_CONSTEXPR Index | cols () const EIGEN_NOEXCEPT |
Derived & | derived () |
const Derived & | derived () const |
Scalar & | operator() (Index index) |
Scalar & | operator() (Index row, Index col) |
Scalar & | operator[] (Index index) |
EIGEN_CONSTEXPR Index | rows () const EIGEN_NOEXCEPT |
EIGEN_CONSTEXPR Index | size () const EIGEN_NOEXCEPT |
Scalar & | w () |
Scalar & | x () |
Scalar & | y () |
Scalar & | z () |
Public Member Functions inherited from Eigen::DenseCoeffsBase< Derived, ReadOnlyAccessors > | |
CoeffReturnType | coeff (Index index) const |
CoeffReturnType | coeff (Index row, Index col) 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 |
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 > | |
EIGEN_CONSTEXPR Index | cols () const EIGEN_NOEXCEPT |
Derived & | derived () |
const Derived & | derived () const |
EIGEN_CONSTEXPR Index | rows () const EIGEN_NOEXCEPT |
EIGEN_CONSTEXPR Index | size () const EIGEN_NOEXCEPT |
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. 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, 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 ConstantReturnType | Zero () |
static const ConstantReturnType | Zero (Index rows, Index cols) |
static const ConstantReturnType | Zero (Index size) |
DenseBase () | |
(Note that these are not member functions.) | |
template<typename Derived > | |
std::ostream & | operator<< (std::ostream &s, const DenseBase< Derived > &m) |
typedef random_access_iterator_type Eigen::DenseBase< Derived >::const_iterator |
This is the const version of iterator (aka read-only)
typedef random_access_iterator_type Eigen::DenseBase< Derived >::iterator |
STL-like RandomAccessIterator iterator type as returned by the begin() and end() methods.
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.
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.
typedef internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,MatrixXpr >::value, PlainMatrix, PlainArray>::type 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&.
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.
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
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
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. |
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. |
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.
|
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. |
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. |
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. |
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. |
| inlineprotected |
Default constructor. Do nothing.
| inline |
Example:
Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones()); Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwiseAbs(); // 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;
Output:
Is ( 0.68 -0.211 0.566) inside the box: 0 Is (0.597 0.823 0.605) inside the box: 1
| inline |
*this
contains only finite numbers, i.e., no NaN and no +/-INF values.
| inline |
| inline |
| inline |
const version of begin()
| inline |
| inline |
| inline |
| inline |
Example:
Matrix3d m = Matrix3d::Random(); 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;
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
| inlinestatic |
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.
| inlinestatic |
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.
| inlinestatic |
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.
| inline |
| inline |
| inline |
const version of end()
| inline |
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.
| inline |
Alias for setConstant(): sets all coefficients in this expression to val.
| inline |
*this
| inline |
See class IOFormat for some examples.
| inline |
*this
contains at least one Not A Number (NaN).
| inline |
bool Eigen::DenseBase< Derived >::isApprox | ( | const DenseBase< OtherDerived > & | other, |
const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision() | ||
) | const |
true
if *this
is approximately equal to other, within the precision determined by prec.\[ \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).*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.bool Eigen::DenseBase< Derived >::isApproxToConstant | ( | const Scalar & | val, |
const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision() | ||
) | const |
bool Eigen::DenseBase< Derived >::isConstant | ( | const Scalar & | val, |
const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision() | ||
) | const |
This is just an alias for isApproxToConstant().
bool Eigen::DenseBase< Derived >::isMuchSmallerThan | ( | const DenseBase< OtherDerived > & | other, |
const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision() | ||
) | const |
true
if the norm of *this
is much smaller than the norm of other, within the precision determined by prec.\[ \Vert v \Vert \leqslant p\,\Vert w\Vert. \]
For matrices, the comparison is done using the Hilbert-Schmidt norm.bool Eigen::DenseBase< Derived >::isMuchSmallerThan | ( | const typename NumTraits< Scalar >::Real & | other, |
const RealScalar & | prec | ||
) | const |
true
if the norm of *this
is much smaller than other, within the precision determined by prec.\[ \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.
bool Eigen::DenseBase< Derived >::isOnes | ( | const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision()
|
) | const |
Example:
Matrix3d m = Matrix3d::Ones(); 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;
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
bool Eigen::DenseBase< Derived >::isZero | ( | const RealScalar & |
prec = NumTraits<Scalar>::dummy_precision()
|
) | const |
Example:
Matrix3d m = Matrix3d::Zero(); 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
EIGEN_DEPRECATED Derived& Eigen::DenseBase< Derived >::lazyAssign | ( | const DenseBase< OtherDerived > & | other | ) |
| 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
| 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
| inlinestatic |
| inlinestatic |
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;
Output:
7 8 9 10 0 0.25 0.5 0.75 1
| inline |
*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 internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::maxCoeff | ( | IndexType * | index | ) | const |
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
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::maxCoeff | ( | IndexType * | rowId, |
IndexType * | colId | ||
) | const |
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
| inline |
| inline |
*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 internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::minCoeff | ( | IndexType * | index | ) | const |
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
internal::traits< Derived >::Scalar Eigen::DenseBase< Derived >::minCoeff | ( | IndexType * | rowId, |
IndexType * | colId | ||
) | const |
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
| inline |
| inline |
| inlinestatic |
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.
| inlinestatic |
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.
| inlinestatic |
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> using namespace Eigen; int main() { std::default_random_engine generator; std::poisson_distribution<int> distribution(4.1); auto poisson = [&] () {return distribution(generator);}; RowVectorXi v = RowVectorXi::NullaryExpr(10, poisson ); std::cout << v << "\n"; }
Output:
2 3 1 4 3 4 4 3 2 3
| inlinestatic |
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
| inlinestatic |
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
| inlinestatic |
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
| inline |
| 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:
Matrix3i m1; m1 << 1, 2, 3, 4, 5, 6, 7, 8, 9; cout << m1 << endl << endl; Matrix3i m2 = Matrix3i::Identity(); m2.block(0,0, 2,2) << 10, 11, 12, 13; cout << m2 << endl << endl; Vector2i v1; v1 << 14, 15; m2 << v1.transpose(), 16, v1, m1.block(1,1,2,2); cout << m2 << endl;
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
| inline |
Special case of the template operator=, in order to prevent the compiler from generating a default operator= (issue hit with g++ 4.1)
| inline |
Copies other into *this.
Derived & Eigen::DenseBase< Derived >::operator= | ( | const EigenBase< OtherDerived > & | other | ) |
Copies the generic expression other into *this.
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
| inline |
| inline |
Example:
Matrix3d m = Matrix3d::Random(); 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
| inlinestatic |
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.
| inlinestatic |
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.
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.
| inlinestatic |
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.
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.
| inline |
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.
const Replicate< Derived, RowFactor, ColFactor > Eigen::DenseBase< Derived >::replicate |
*this
Example:
MatrixXi m = MatrixXi::Random(2,3); cout << "Here is the matrix m:" << endl << m << endl; cout << "m.replicate<3,2>() = ..." << endl; cout << m.replicate<3,2>() << endl;
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
| inline |
*this
Example:
Vector3i v = Vector3i::Random(); cout << "Here is the vector v:" << endl << v << endl; cout << "v.replicate(2,5) = ..." << endl; cout << v.replicate(2,5) << endl;
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
| 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.
| 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.
| inline |
Example:
MatrixXi m = MatrixXi::Random(3,4); 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
| inline |
This is the const version of reverse().
| 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:
m = m.reverse().eval();
| inline |
| inline |
Example:
Matrix3d m = Matrix3d::Random(); 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
| inline |
| inline |
Version of DenseBase::select(const DenseBase&, const DenseBase&) with the else expression being a scalar value.
| inline |
Version of DenseBase::select(const DenseBase&, const DenseBase&) with the then expression being a scalar value.
| inline |
Sets all coefficients in this expression to value val.
| 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 .
| 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:
VectorXf v; v.setLinSpaced(5,0.5f,1.5f); cout << v << endl;
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 .
| inline |
Sets all coefficients in this expression to one.
Example:
Matrix4i m = Matrix4i::Random(); m.row(1).setOnes(); cout << m << endl;
Output:
7 9 -5 -3 1 1 1 1 6 -3 0 9 6 6 3 9
| 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.
Example:
Matrix4i m = Matrix4i::Zero(); m.col(1).setRandom(); cout << m << endl;
Output:
0 7 0 0 0 -2 0 0 0 6 0 0 0 6 0 0
| inline |
Sets all coefficients in this expression to zero.
Example:
Matrix4i m = Matrix4i::Random(); m.row(1).setZero(); cout << m << endl;
Output:
7 9 -5 -3 0 0 0 0 6 -3 0 9 6 6 3 9
| inline |
| inline |
swaps *this with the expression other.
| inline |
swaps *this with the matrix or array other.
| inline |
Example:
Matrix2i m = Matrix2i::Random(); 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;
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
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();
| inline |
This is the const version of transpose().
Make sure you read the warning for transpose() !
| 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().
*this
must be a resizable matrix. This excludes (non-square) fixed-size matrices, block-expressions and maps.
| inline |
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); };
| inlinestatic |
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
| inlinestatic |
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
| inlinestatic |
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
| 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.
© Eigen.
Licensed under the MPL2 License.
https://eigen.tuxfamily.org/dox/classEigen_1_1DenseBase.html