11#ifndef EIGEN_DENSEBASE_H
12#define EIGEN_DENSEBASE_H
15#include "./InternalHeaderCheck.h"
20EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned, THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE)
37template <typename Derived>
39#ifndef EIGEN_PARSED_BY_DOXYGEN
40 :
public DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value>
42 :
public DenseCoeffsBase<Derived, DirectWriteAccessors>
51 typedef typename internal::traits<Derived>::StorageKind StorageKind;
59 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
62 typedef typename internal::traits<Derived>::Scalar
Scalar;
69 typedef typename NumTraits<Scalar>::Real RealScalar;
70 typedef DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value> Base;
73 using Base::coeffByOuterInner;
74 using Base::colIndexByOuterInner;
76 using Base::const_cast_derived;
78 using Base::rowIndexByOuterInner;
81 using Base::operator();
82 using Base::operator[];
83 using Base::colStride;
84 using Base::innerStride;
85 using Base::outerStride;
86 using Base::rowStride;
92 typedef typename Base::CoeffReturnType CoeffReturnType;
136 internal::traits<Derived>::MaxColsAtCompileTime),
148 internal::traits<Derived>::RowsAtCompileTime == 1 || internal::traits<Derived>::ColsAtCompileTime == 1,
161 Flags = internal::traits<Derived>::Flags,
172 InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
173 OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
176 typedef typename internal::find_best_packet<Scalar, SizeAtCompileTime>::type PacketScalar;
178 enum { IsPlainObjectBase = 0 };
183 internal::traits<Derived>::ColsAtCompileTime,
185 internal::traits<Derived>::MaxRowsAtCompileTime, internal::traits<Derived>::MaxColsAtCompileTime>
191 internal::traits<Derived>::ColsAtCompileTime,
193 internal::traits<Derived>::MaxRowsAtCompileTime, internal::traits<Derived>::MaxColsAtCompileTime>
202 typedef std::conditional_t<internal::is_same<typename internal::traits<Derived>::XprKind,
MatrixXpr>
::value,
229 EIGEN_ONLY_USED_FOR_DEBUG(newSize);
230 eigen_assert(newSize == this->size() &&
"DenseBase::resize() does not actually allow to resize.");
237 EIGEN_ONLY_USED_FOR_DEBUG(rows);
238 EIGEN_ONLY_USED_FOR_DEBUG(cols);
239 eigen_assert(rows == this->rows() && cols == this->cols() &&
240 "DenseBase::resize() does not actually allow to resize.");
243#ifndef EIGEN_PARSED_BY_DOXYGEN
256 internal::traits<Derived>::ColsAtCompileTime, 1>
257 EigenvaluesReturnType;
262 template <
typename OtherDerived>
270 template <
typename OtherDerived>
273 template <
typename OtherDerived>
276 template <
typename OtherDerived>
279 template <
typename OtherDerived>
280 EIGEN_DEVICE_FUNC Derived&
operator=(
const ReturnByValue<OtherDerived>& func);
284 template <
typename OtherDerived>
290 template <
unsigned int Added,
unsigned int Removed>
292 EIGEN_DEPRECATED
const Derived&
flagged()
const {
296 template <
typename OtherDerived>
300 EIGEN_DEVICE_FUNC TransposeReturnType transpose();
302 EIGEN_DEVICE_FUNC
const ConstTransposeReturnType
transpose()
const;
309 EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
LinSpaced(Sequential_t,
Index size,
312 EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
LinSpaced(Sequential_t,
316 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
LinSpaced(
Index size,
const Scalar& low,
318 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
LinSpaced(
const Scalar& low,
const Scalar& high);
320 EIGEN_DEVICE_FUNC
static const RandomAccessEqualSpacedReturnType EqualSpaced(
Index size,
const Scalar& low,
322 EIGEN_DEVICE_FUNC
static const RandomAccessEqualSpacedReturnType EqualSpaced(
const Scalar& low,
const Scalar& step);
324 template <
typename CustomNullaryOp>
326 const CustomNullaryOp& func);
327 template <
typename CustomNullaryOp>
329 const CustomNullaryOp& func);
330 template <
typename CustomNullaryOp>
333 EIGEN_DEVICE_FUNC
static const ZeroReturnType
Zero(
Index rows,
Index cols);
334 EIGEN_DEVICE_FUNC
static const ZeroReturnType
Zero(
Index size);
335 EIGEN_DEVICE_FUNC
static const ZeroReturnType
Zero();
336 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones(
Index rows,
Index cols);
337 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones(
Index size);
338 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones();
344 EIGEN_DEVICE_FUNC Derived& setEqualSpaced(
Index size,
const Scalar& low,
const Scalar& step);
345 EIGEN_DEVICE_FUNC Derived& setEqualSpaced(
const Scalar& low,
const Scalar& step);
346 EIGEN_DEVICE_FUNC Derived&
setZero();
347 EIGEN_DEVICE_FUNC Derived&
setOnes();
350 template <
typename OtherDerived>
352 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
353 EIGEN_DEVICE_FUNC
bool isMuchSmallerThan(
const RealScalar& other,
354 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
355 template <
typename OtherDerived>
357 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
360 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
362 const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
363 EIGEN_DEVICE_FUNC
bool isZero(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
364 EIGEN_DEVICE_FUNC
bool isOnes(
const RealScalar& prec = NumTraits<Scalar>::dummy_precision())
const;
366 EIGEN_DEVICE_FUNC
inline bool hasNaN()
const;
367 EIGEN_DEVICE_FUNC
inline bool allFinite()
const;
369 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator*=(
const Scalar& other);
370 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived& operator/=(
const Scalar& other);
372 typedef internal::add_const_on_value_type_t<typename internal::eval<Derived>::type> EvalReturnType;
381 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EvalReturnType
eval()
const {
385 return typename internal::eval<Derived>::type(derived());
391 template <
typename OtherDerived>
393 EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase, THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
394 eigen_assert(rows() == other.rows() && cols() == other.cols());
395 call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
401 template <
typename OtherDerived>
403 eigen_assert(rows() == other.rows() && cols() == other.cols());
404 call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
410 template <
bool Enable>
411 EIGEN_DEVICE_FUNC
inline const std::conditional_t<Enable, ForceAlignedAccess<Derived>, Derived&>
412 forceAlignedAccessIf()
const;
413 template <
bool Enable>
414 EIGEN_DEVICE_FUNC
inline std::conditional_t<Enable, ForceAlignedAccess<Derived>, Derived&> forceAlignedAccessIf();
418 EIGEN_DEVICE_FUNC
Scalar trace()
const;
422 template <
int NaNPropagation>
423 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar
minCoeff()
const;
424 template <
int NaNPropagation>
425 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar
maxCoeff()
const;
431 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar
minCoeff()
const {
434 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar maxCoeff()
const {
435 return maxCoeff<PropagateFast>();
438 template <
int NaNPropagation,
typename IndexType>
439 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col)
const;
440 template <
int NaNPropagation,
typename IndexType>
441 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col)
const;
442 template <
int NaNPropagation,
typename IndexType>
443 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar minCoeff(IndexType* index)
const;
444 template <
int NaNPropagation,
typename IndexType>
445 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index)
const;
448 template <
typename IndexType>
449 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col)
const {
450 return minCoeff<PropagateFast>(row, col);
452 template <
typename IndexType>
453 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col)
const {
454 return maxCoeff<PropagateFast>(row, col);
456 template <
typename IndexType>
457 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar
minCoeff(IndexType* index)
const {
460 template <
typename IndexType>
461 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index)
const {
462 return maxCoeff<PropagateFast>(index);
465 template <
typename BinaryOp>
466 EIGEN_DEVICE_FUNC
Scalar redux(
const BinaryOp& func)
const;
468 template <
typename Visitor>
469 EIGEN_DEVICE_FUNC
void visit(Visitor& func)
const;
481 EIGEN_DEVICE_FUNC CoeffReturnType
value()
const {
482 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1);
483 return derived().coeff(0, 0);
486 EIGEN_DEVICE_FUNC
bool all()
const;
487 EIGEN_DEVICE_FUNC
bool any()
const;
488 EIGEN_DEVICE_FUNC
Index count()
const;
503 EIGEN_DEVICE_FUNC
inline ConstRowwiseReturnType
rowwise()
const {
return ConstRowwiseReturnType(derived()); }
504 EIGEN_DEVICE_FUNC RowwiseReturnType rowwise();
513 EIGEN_DEVICE_FUNC
inline ConstColwiseReturnType
colwise()
const {
return ConstColwiseReturnType(derived()); }
514 EIGEN_DEVICE_FUNC ColwiseReturnType
colwise();
519 static const RandomReturnType
Random();
521 template <
typename ThenDerived,
typename ElseDerived>
522 inline EIGEN_DEVICE_FUNC
525 ThenDerived, ElseDerived, Derived>
528 template <
typename ThenDerived>
529 inline EIGEN_DEVICE_FUNC
535 template <
typename ElseDerived>
536 inline EIGEN_DEVICE_FUNC
543 RealScalar lpNorm()
const;
545 template <
int RowFactor,
int ColFactor>
562 EIGEN_DEVICE_FUNC ReverseReturnType reverse();
565 EIGEN_DEVICE_FUNC ConstReverseReturnType
reverse()
const {
return ConstReverseReturnType(derived()); }
566 EIGEN_DEVICE_FUNC
void reverseInPlace();
568#ifdef EIGEN_PARSED_BY_DOXYGEN
577 internal::pointer_based_stl_iterator<Derived>,
578 internal::generic_randaccess_stl_iterator<Derived> >
582 internal::pointer_based_stl_iterator<const Derived>,
583 internal::generic_randaccess_stl_iterator<const Derived> >
588 typedef std::conditional_t<IsVectorAtCompileTime, iterator_type, void>
iterator;
590 typedef std::conditional_t<IsVectorAtCompileTime, const_iterator_type, void>
const_iterator;
600#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
601#define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
602#define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
603#define EIGEN_DOC_UNARY_ADDONS(X, Y)
604#include "../plugins/CommonCwiseUnaryOps.inc"
605#include "../plugins/BlockMethods.inc"
606#include "../plugins/IndexedViewMethods.inc"
607#include "../plugins/ReshapedMethods.inc"
608#ifdef EIGEN_DENSEBASE_PLUGIN
609#include EIGEN_DENSEBASE_PLUGIN
611#undef EIGEN_CURRENT_STORAGE_BASE_CLASS
612#undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
613#undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
614#undef EIGEN_DOC_UNARY_ADDONS
617 template <
typename Dest>
618 EIGEN_DEVICE_FUNC
inline void evalTo(Dest&)
const {
619 EIGEN_STATIC_ASSERT((internal::is_same<Dest, void>::value),
620 THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
624 EIGEN_DEFAULT_COPY_CONSTRUCTOR(
DenseBase)
626#ifdef EIGEN_INTERNAL_DEBUGGING
627 EIGEN_DEVICE_FUNC
constexpr DenseBase() {
634 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
641 EIGEN_DEVICE_FUNC
explicit DenseBase(
int);
643 template <
typename OtherDerived>
649template <
typename DerivedA,
typename DerivedB>
650EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
652 std::enable_if_t<std::is_base_of<DenseBase<std::decay_t<DerivedA>>, std::decay_t<DerivedA>>::value &&
653 std::is_base_of<DenseBase<std::decay_t<DerivedB>>, std::decay_t<DerivedB>>::value,
655 swap(DerivedA&& a, DerivedB&& b) {
General-purpose arrays with easy API for coefficient-wise operations.
Definition ForwardDeclarations.h:399
Generic expression of a matrix where all coefficients are defined by a functor.
Definition ForwardDeclarations.h:104
Generic expression where a coefficient-wise ternary operator is applied to two expressions.
Definition ForwardDeclarations.h:110
Base class for all dense matrices, vectors, and arrays.
Definition ForwardDeclarations.h:59
EIGEN_CONSTEXPR Index outerSize() const
Definition DenseBase.h:211
internal::traits< Derived >::Scalar minCoeff() const
Definition Redux.h:457
CommaInitializer< Derived > operator<<(const Scalar &s)
Definition CommaInitializer.h:135
const WithFormat< Derived > format(const IOFormat &fmt) const
Definition DenseBase.h:478
static EIGEN_DEPRECATED const RandomAccessLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Definition CwiseNullaryOp.h:240
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:330
Scalar mean() const
Definition Redux.h:491
Derived & setOnes()
Definition CwiseNullaryOp.h:694
void resize(Index rows, Index cols)
Definition DenseBase.h:236
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.
Definition DenseBase.h:204
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
Definition DenseBase.h:59
void resize(Index newSize)
Definition DenseBase.h:228
random_access_iterator_type const_iterator
Definition DenseBase.h:574
static const CwiseNullaryOp< CustomNullaryOp, PlainObject > NullaryExpr(Index rows, Index cols, const CustomNullaryOp &func)
Definition CwiseNullaryOp.h:112
const NestByValue< Derived > nestByValue() const
Definition NestByValue.h:74
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
Definition DenseBase.h:186
void visit(Visitor &func) const
Definition Visitor.h:382
TransposeReturnType transpose()
Definition Transpose.h:162
void swap(PlainObjectBase< OtherDerived > &other)
Definition DenseBase.h:402
Eigen::InnerIterator< Derived > InnerIterator
Definition DenseBase.h:49
iterator begin()
Definition StlIterators.h:571
ConstColwiseReturnType colwise() const
Definition DenseBase.h:513
EIGEN_CONSTEXPR Index innerSize() const
Definition DenseBase.h:220
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly spaced vector.
Definition CwiseNullaryOp.h:432
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
const Replicate< Derived, RowFactor, ColFactor > replicate() const
Definition Replicate.h:109
@ IsVectorAtCompileTime
Definition DenseBase.h:147
@ SizeAtCompileTime
Definition DenseBase.h:108
@ MaxSizeAtCompileTime
Definition DenseBase.h:135
@ IsRowMajor
Definition DenseBase.h:166
@ NumDimensions
Definition DenseBase.h:154
@ Flags
Definition DenseBase.h:161
@ ColsAtCompileTime
Definition DenseBase.h:102
@ MaxColsAtCompileTime
Definition DenseBase.h:124
@ MaxRowsAtCompileTime
Definition DenseBase.h:113
@ RowsAtCompileTime
Definition DenseBase.h:96
static const ZeroReturnType Zero(Index rows, Index cols)
Definition CwiseNullaryOp.h:487
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition CwiseNullaryOp.h:186
const Replicate< Derived, Dynamic, Dynamic > replicate(Index rowFactor, Index colFactor) const
Definition DenseBase.h:556
internal::traits< Derived >::Scalar maxCoeff() const
Definition Redux.h:470
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
Definition DenseBase.h:194
CoeffReturnType value() const
Definition DenseBase.h:481
static const ConstantReturnType Ones(Index rows, Index cols)
Definition CwiseNullaryOp.h:631
Scalar value_type
Definition DenseBase.h:67
void fill(const Scalar &value)
Definition CwiseNullaryOp.h:339
ConstReverseReturnType reverse() const
Definition DenseBase.h:565
constexpr DenseBase()=default
ConstRowwiseReturnType rowwise() const
Definition DenseBase.h:503
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:682
EvalReturnType eval() const
Definition DenseBase.h:381
Derived & operator=(const DenseBase< OtherDerived > &other)
Definition Assign.h:39
Derived & setConstant(const Scalar &value)
Definition CwiseNullaryOp.h:349
Derived & setRandom()
Definition Random.h:129
void transposeInPlace()
Definition Transpose.h:320
Scalar sum() const
Definition Redux.h:481
EIGEN_DEPRECATED const Derived & flagged() const
Definition DenseBase.h:292
iterator end()
Definition StlIterators.h:597
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition Fuzzy.h:89
static const RandomReturnType Random(Index rows, Index cols)
Definition Random.h:59
const_iterator cbegin() const
Definition StlIterators.h:587
const_iterator cend() const
Definition StlIterators.h:613
Scalar prod() const
Definition Redux.h:510
EIGEN_DEPRECATED Derived & lazyAssign(const DenseBase< OtherDerived > &other)
bool allFinite() const
Definition Visitor.h:783
Derived & setZero()
Definition CwiseNullaryOp.h:554
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:538
random_access_iterator_type iterator
Definition DenseBase.h:572
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition CwiseNullaryOp.h:318
void swap(const DenseBase< OtherDerived > &other)
Definition DenseBase.h:392
Enforce aligned packet loads and stores regardless of what is requested.
Definition ForwardDeclarations.h:84
An InnerIterator allows to loop over the element of any matrix expression.
Definition ForwardDeclarations.h:189
The matrix class, also used for vectors and row-vectors.
Definition ForwardDeclarations.h:70
Expression which must be nested by value.
Definition ForwardDeclarations.h:82
Dense storage base class for matrices and arrays.
Definition ForwardDeclarations.h:61
Expression of the multiple replication of a matrix or vector.
Definition ForwardDeclarations.h:407
Expression of the reverse of a vector or matrix.
Definition ForwardDeclarations.h:409
Expression of the transpose of a matrix.
Definition ForwardDeclarations.h:100
Pseudo expression providing broadcasting and partial reduction operations.
Definition VectorwiseOp.h:192
@ ColMajor
Definition Constants.h:318
@ RowMajor
Definition Constants.h:320
@ AutoAlign
Definition Constants.h:322
const unsigned int DirectAccessBit
Definition Constants.h:159
const unsigned int RowMajorBit
Definition Constants.h:70
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
std::enable_if_t< std::is_base_of< DenseBase< std::decay_t< DerivedA > >, std::decay_t< DerivedA > >::value &&std::is_base_of< DenseBase< std::decay_t< DerivedB > >, std::decay_t< DerivedB > >::value, void > swap(DerivedA &&a, DerivedB &&b)
Definition DenseBase.h:655
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82
Helper class used by the comma initializer operator.
Definition ForwardDeclarations.h:179
Definition ForwardDeclarations.h:57
Definition Constants.h:534