11 #ifndef EIGEN_DENSEBASE_H
12 #define EIGEN_DENSEBASE_H
14 #include "./InternalHeaderCheck.h"
19 EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE)
37 #ifndef EIGEN_PARSED_BY_DOXYGEN
38 :
public DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value>
48 typedef Eigen::InnerIterator<Derived> InnerIterator;
50 typedef typename internal::traits<Derived>::StorageKind StorageKind;
58 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
61 typedef typename internal::traits<Derived>::Scalar
Scalar;
69 typedef DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value> Base;
72 using Base::const_cast_derived;
76 using Base::rowIndexByOuterInner;
77 using Base::colIndexByOuterInner;
79 using Base::coeffByOuterInner;
80 using Base::operator();
81 using Base::operator[];
87 using Base::innerStride;
88 using Base::outerStride;
89 using Base::rowStride;
90 using Base::colStride;
91 typedef typename Base::CoeffReturnType CoeffReturnType;
95 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
101 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
108 SizeAtCompileTime = (internal::size_of_xpr_at_compile_time<Derived>::ret),
113 MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
124 MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
135 MaxSizeAtCompileTime = internal::size_at_compile_time(internal::traits<Derived>::MaxRowsAtCompileTime,
136 internal::traits<Derived>::MaxColsAtCompileTime),
147 IsVectorAtCompileTime = internal::traits<Derived>::RowsAtCompileTime == 1
148 || internal::traits<Derived>::ColsAtCompileTime == 1,
154 NumDimensions = int(MaxSizeAtCompileTime) == 1 ? 0 : bool(IsVectorAtCompileTime) ? 1 : 2,
159 Flags = internal::traits<Derived>::Flags,
166 InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
167 : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
169 InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
170 OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
173 typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar;
175 enum { IsPlainObjectBase = 0 };
180 internal::traits<Derived>::RowsAtCompileTime,
181 internal::traits<Derived>::ColsAtCompileTime,
183 internal::traits<Derived>::MaxRowsAtCompileTime,
184 internal::traits<Derived>::MaxColsAtCompileTime
190 internal::traits<Derived>::RowsAtCompileTime,
191 internal::traits<Derived>::ColsAtCompileTime,
193 internal::traits<Derived>::MaxRowsAtCompileTime,
194 internal::traits<Derived>::MaxColsAtCompileTime
203 typedef std::conditional_t<internal::is_same<typename internal::traits<Derived>::XprKind,
MatrixXpr >::value,
211 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
214 return IsVectorAtCompileTime ? 1
215 : int(IsRowMajor) ? this->rows() : this->cols();
223 EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
226 return IsVectorAtCompileTime ? this->size()
227 : int(IsRowMajor) ? this->cols() : this->rows();
237 EIGEN_ONLY_USED_FOR_DEBUG(newSize);
238 eigen_assert(newSize == this->size()
239 &&
"DenseBase::resize() does not actually allow to resize.");
248 EIGEN_ONLY_USED_FOR_DEBUG(rows);
249 EIGEN_ONLY_USED_FOR_DEBUG(cols);
250 eigen_assert(rows == this->rows() && cols == this->cols()
251 &&
"DenseBase::resize() does not actually allow to resize.");
254 #ifndef EIGEN_PARSED_BY_DOXYGEN
267 template<
typename OtherDerived>
268 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
274 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
275 Derived& operator=(
const DenseBase& other);
277 template<
typename OtherDerived>
281 template<
typename OtherDerived>
285 template<
typename OtherDerived>
289 template<
typename OtherDerived>
291 Derived& operator=(
const ReturnByValue<OtherDerived>& func);
295 template<
typename OtherDerived>
297 EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
303 template<
unsigned int Added,
unsigned int Removed>
307 {
return derived(); }
309 template<
typename OtherDerived>
315 TransposeReturnType transpose();
318 const ConstTransposeReturnType transpose()
const;
320 void transposeInPlace();
322 EIGEN_DEVICE_FUNC
static const ConstantReturnType
323 Constant(
Index rows,
Index cols,
const Scalar& value);
324 EIGEN_DEVICE_FUNC
static const ConstantReturnType
325 Constant(
Index size,
const Scalar& value);
326 EIGEN_DEVICE_FUNC
static const ConstantReturnType
327 Constant(
const Scalar& value);
329 EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
330 LinSpaced(Sequential_t,
Index size,
const Scalar& low,
const Scalar& high);
331 EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
332 LinSpaced(Sequential_t,
const Scalar& low,
const Scalar& high);
334 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
335 LinSpaced(
Index size,
const Scalar& low,
const Scalar& high);
336 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
337 LinSpaced(
const Scalar& low,
const Scalar& high);
339 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
341 NullaryExpr(
Index rows,
Index cols,
const CustomNullaryOp& func);
342 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
344 NullaryExpr(
Index size,
const CustomNullaryOp& func);
345 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
347 NullaryExpr(
const CustomNullaryOp& func);
349 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero(
Index rows,
Index cols);
350 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero(
Index size);
351 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero();
352 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones(
Index rows,
Index cols);
353 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones(
Index size);
354 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones();
356 EIGEN_DEVICE_FUNC
void fill(
const Scalar& value);
357 EIGEN_DEVICE_FUNC Derived& setConstant(
const Scalar& value);
358 EIGEN_DEVICE_FUNC Derived& setLinSpaced(
Index size,
const Scalar& low,
const Scalar& high);
359 EIGEN_DEVICE_FUNC Derived& setLinSpaced(
const Scalar& low,
const Scalar& high);
360 EIGEN_DEVICE_FUNC Derived& setZero();
361 EIGEN_DEVICE_FUNC Derived& setOnes();
362 EIGEN_DEVICE_FUNC Derived& setRandom();
364 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
368 bool isMuchSmallerThan(
const RealScalar& other,
370 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
379 EIGEN_DEVICE_FUNC
inline bool hasNaN()
const;
380 EIGEN_DEVICE_FUNC
inline bool allFinite()
const;
382 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
383 Derived& operator*=(
const Scalar& other);
384 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
385 Derived& operator/=(
const Scalar& other);
387 typedef internal::add_const_on_value_type_t<typename internal::eval<Derived>::type> EvalReturnType;
396 EIGEN_STRONG_INLINE EvalReturnType
eval()
const
401 return typename internal::eval<Derived>::type(derived());
407 template<
typename OtherDerived>
408 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
411 EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
412 eigen_assert(rows()==other.
rows() && cols()==other.
cols());
413 call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
419 template<
typename OtherDerived>
420 EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
423 eigen_assert(rows()==other.rows() && cols()==other.cols());
424 call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
430 template<
bool Enable> EIGEN_DEVICE_FUNC
431 inline const std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&> forceAlignedAccessIf()
const;
432 template<
bool Enable> EIGEN_DEVICE_FUNC
433 inline std::conditional_t<Enable,ForceAlignedAccess<Derived>,Derived&> forceAlignedAccessIf();
435 EIGEN_DEVICE_FUNC Scalar sum()
const;
436 EIGEN_DEVICE_FUNC Scalar mean()
const;
437 EIGEN_DEVICE_FUNC Scalar trace()
const;
439 EIGEN_DEVICE_FUNC Scalar prod()
const;
441 template<
int NaNPropagation>
442 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar minCoeff()
const;
443 template<
int NaNPropagation>
444 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar maxCoeff()
const;
451 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar minCoeff()
const {
452 return minCoeff<PropagateFast>();
454 EIGEN_DEVICE_FUNC
inline typename internal::traits<Derived>::Scalar maxCoeff()
const {
455 return maxCoeff<PropagateFast>();
458 template<
int NaNPropagation,
typename IndexType>
460 typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col)
const;
461 template<
int NaNPropagation,
typename IndexType>
463 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col)
const;
464 template<
int NaNPropagation,
typename IndexType>
466 typename internal::traits<Derived>::Scalar minCoeff(IndexType* index)
const;
467 template<
int NaNPropagation,
typename IndexType>
469 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index)
const;
472 template<
typename IndexType>
473 EIGEN_DEVICE_FUNC
inline
474 typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col)
const {
475 return minCoeff<PropagateFast>(row, col);
477 template<
typename IndexType>
478 EIGEN_DEVICE_FUNC
inline
479 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col)
const {
480 return maxCoeff<PropagateFast>(row, col);
482 template<
typename IndexType>
483 EIGEN_DEVICE_FUNC
inline
484 typename internal::traits<Derived>::Scalar minCoeff(IndexType* index)
const {
485 return minCoeff<PropagateFast>(index);
487 template<
typename IndexType>
488 EIGEN_DEVICE_FUNC
inline
489 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index)
const {
490 return maxCoeff<PropagateFast>(index);
493 template<
typename BinaryOp>
495 Scalar redux(
const BinaryOp& func)
const;
497 template<
typename Visitor>
499 void visit(Visitor& func)
const;
517 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
518 eigen_assert(this->rows() == 1 && this->cols() == 1);
519 return derived().coeff(0,0);
522 EIGEN_DEVICE_FUNC
bool all()
const;
523 EIGEN_DEVICE_FUNC
bool any()
const;
524 EIGEN_DEVICE_FUNC
Index count()
const;
542 EIGEN_DEVICE_FUNC RowwiseReturnType rowwise();
554 EIGEN_DEVICE_FUNC ColwiseReturnType colwise();
557 static const RandomReturnType Random(
Index rows,
Index cols);
558 static const RandomReturnType Random(
Index size);
559 static const RandomReturnType Random();
561 template<
typename ThenDerived,
typename ElseDerived>
566 template<
typename ThenDerived>
570 template<
typename ElseDerived>
574 template<
int p> RealScalar lpNorm()
const;
576 template<
int RowFactor,
int ColFactor>
596 EIGEN_DEVICE_FUNC ReverseReturnType reverse();
603 EIGEN_DEVICE_FUNC
void reverseInPlace();
605 #ifdef EIGEN_PARSED_BY_DOXYGEN
614 internal::pointer_based_stl_iterator<Derived>,
615 internal::generic_randaccess_stl_iterator<Derived>
619 internal::pointer_based_stl_iterator<const Derived>,
620 internal::generic_randaccess_stl_iterator<const Derived>
621 > const_iterator_type;
625 typedef std::conditional_t<IsVectorAtCompileTime, iterator_type, void>
iterator;
627 typedef std::conditional_t<IsVectorAtCompileTime, const_iterator_type, void>
const_iterator;
637 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
638 #define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
639 #define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
640 #define EIGEN_DOC_UNARY_ADDONS(X,Y)
641 # include "../plugins/CommonCwiseUnaryOps.h"
642 # include "../plugins/BlockMethods.h"
643 # include "../plugins/IndexedViewMethods.h"
644 # include "../plugins/ReshapedMethods.h"
645 # ifdef EIGEN_DENSEBASE_PLUGIN
646 # include EIGEN_DENSEBASE_PLUGIN
648 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
649 #undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
650 #undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
651 #undef EIGEN_DOC_UNARY_ADDONS
654 template<
typename Dest>
656 inline void evalTo(Dest& )
const
658 EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
662 EIGEN_DEFAULT_COPY_CONSTRUCTOR(
DenseBase)
669 #ifdef EIGEN_INTERNAL_DEBUGGING
670 EIGEN_STATIC_ASSERT((internal::check_implication(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1,
int(IsRowMajor))
671 && internal::check_implication(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1,
int(!IsRowMajor))),
672 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
677 EIGEN_DEVICE_FUNC
explicit DenseBase(
int);
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:49
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:63
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
EIGEN_CONSTEXPR Index outerSize() const
Definition: DenseBase.h:212
void resize(Index rows, Index cols)
Definition: DenseBase.h:246
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
Definition: DenseBase.h:58
void resize(Index newSize)
Definition: DenseBase.h:235
random_access_iterator_type const_iterator
Definition: DenseBase.h:611
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
void swap(PlainObjectBase< OtherDerived > &other)
Definition: DenseBase.h:421
ConstColwiseReturnType colwise() const
Definition: DenseBase.h:551
EIGEN_CONSTEXPR Index innerSize() const
Definition: DenseBase.h:224
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:61
EIGEN_DEPRECATED Derived & lazyAssign(const DenseBase< OtherDerived > &other)
CoeffReturnType value() const
Definition: DenseBase.h:515
Scalar value_type
Definition: DenseBase.h:66
EIGEN_DEPRECATED const Derived & flagged() const
Definition: DenseBase.h:306
ConstReverseReturnType reverse() const
Definition: DenseBase.h:599
ConstRowwiseReturnType rowwise() const
Definition: DenseBase.h:539
EvalReturnType eval() const
Definition: DenseBase.h:396
const WithFormat< Derived > format(const IOFormat &fmt) const
Definition: DenseBase.h:508
random_access_iterator_type iterator
Definition: DenseBase.h:609
void swap(const DenseBase< OtherDerived > &other)
Definition: DenseBase.h:409
const Replicate< Derived, Dynamic, Dynamic > replicate(Index rowFactor, Index colFactor) const
Definition: DenseBase.h:589
Base class providing direct read/write coefficient access to matrices and arrays.
Definition: DenseCoeffsBase.h:559
EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: EigenBase.h:65
EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: EigenBase.h:62
Enforce aligned packet loads and stores regardless of what is requested.
Definition: ForceAlignedAccess.h:38
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:182
Expression which must be nested by value.
Definition: NestByValue.h:42
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:102
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:65
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:67
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition: Select.h:56
Expression of the transpose of a matrix.
Definition: Transpose.h:56
Pseudo expression providing broadcasting and partial reduction operations.
Definition: VectorwiseOp.h:188
static const lastp1_t end
Definition: IndexedViewHelper.h:183
static const Eigen::internal::all_t all
Definition: IndexedViewHelper.h:189
@ ColMajor
Definition: Constants.h:321
@ RowMajor
Definition: Constants.h:323
@ AutoAlign
Definition: Constants.h:325
const unsigned int DirectAccessBit
Definition: Constants.h:157
const unsigned int RowMajorBit
Definition: Constants.h:68
Namespace containing all symbols from the Eigen library.
Definition: Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:59
Helper class used by the comma initializer operator.
Definition: CommaInitializer.h:31
Definition: EigenBase.h:32
Eigen::Index Index
The interface type of indices.
Definition: EigenBase.h:41
Definition: Constants.h:524
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231