11 #ifndef EIGEN_DENSEBASE_H
12 #define EIGEN_DENSEBASE_H
20 static inline void check_DenseIndex_is_signed() {
21 EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE);
42 #ifndef EIGEN_PARSED_BY_DOXYGEN
43 :
public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
44 typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>
46 :
public DenseCoeffsBase<Derived>
47 #endif // not EIGEN_PARSED_BY_DOXYGEN
50 using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
52 using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
59 typedef Eigen::InnerIterator<Derived> InnerIterator;
61 typedef typename internal::traits<Derived>::StorageKind StorageKind;
69 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
72 typedef typename internal::traits<Derived>::Scalar
Scalar;
81 typedef internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
84 using Base::const_cast_derived;
88 using Base::rowIndexByOuterInner;
89 using Base::colIndexByOuterInner;
91 using Base::coeffByOuterInner;
92 using Base::operator();
93 using Base::operator[];
99 using Base::innerStride;
100 using Base::outerStride;
101 using Base::rowStride;
102 using Base::colStride;
103 typedef typename Base::CoeffReturnType CoeffReturnType;
120 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
121 internal::traits<Derived>::ColsAtCompileTime>::ret),
149 internal::traits<Derived>::MaxColsAtCompileTime>::ret),
161 || internal::traits<Derived>::MaxColsAtCompileTime == 1,
167 Flags = internal::traits<Derived>::Flags,
177 InnerStrideAtCompileTime =
internal::inner_stride_at_compile_time<Derived>::ret,
178 OuterStrideAtCompileTime =
internal::outer_stride_at_compile_time<Derived>::ret
181 typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar;
183 enum { IsPlainObjectBase = 0 };
188 internal::traits<Derived>::RowsAtCompileTime,
189 internal::traits<Derived>::ColsAtCompileTime,
191 internal::traits<Derived>::MaxRowsAtCompileTime,
192 internal::traits<Derived>::MaxColsAtCompileTime
198 internal::traits<Derived>::RowsAtCompileTime,
199 internal::traits<Derived>::ColsAtCompileTime,
201 internal::traits<Derived>::MaxRowsAtCompileTime,
202 internal::traits<Derived>::MaxColsAtCompileTime
211 typedef typename internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,
MatrixXpr >
::value,
232 : int(
IsRowMajor) ? this->rows() : this->cols();
244 : int(
IsRowMajor) ? this->cols() : this->rows();
254 EIGEN_ONLY_USED_FOR_DEBUG(newSize);
255 eigen_assert(newSize == this->size()
256 &&
"DenseBase::resize() does not actually allow to resize.");
265 EIGEN_ONLY_USED_FOR_DEBUG(rows);
266 EIGEN_ONLY_USED_FOR_DEBUG(cols);
267 eigen_assert(rows == this->rows() && cols == this->cols()
268 &&
"DenseBase::resize() does not actually allow to resize.");
271 #ifndef EIGEN_PARSED_BY_DOXYGEN
281 #endif // not EIGEN_PARSED_BY_DOXYGEN
284 template<
typename OtherDerived>
294 template<
typename OtherDerived>
298 template<
typename OtherDerived>
302 template<
typename OtherDerived>
306 template<
typename OtherDerived>
308 Derived&
operator=(
const ReturnByValue<OtherDerived>& func);
313 template<
typename OtherDerived>
321 template<
unsigned int Added,
unsigned int Removed>
324 {
return derived(); }
326 template<
typename OtherDerived>
335 ConstTransposeReturnType
transpose()
const;
339 EIGEN_DEVICE_FUNC
static const ConstantReturnType
341 EIGEN_DEVICE_FUNC
static const ConstantReturnType
343 EIGEN_DEVICE_FUNC
static const ConstantReturnType
346 EIGEN_DEVICE_FUNC
static const SequentialLinSpacedReturnType
347 LinSpaced(Sequential_t, Index size,
const Scalar& low,
const Scalar& high);
348 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
349 LinSpaced(Index size,
const Scalar& low,
const Scalar& high);
350 EIGEN_DEVICE_FUNC
static const SequentialLinSpacedReturnType
351 LinSpaced(Sequential_t,
const Scalar& low,
const Scalar& high);
352 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
355 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
357 NullaryExpr(Index rows, Index cols,
const CustomNullaryOp& func);
358 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
360 NullaryExpr(Index size,
const CustomNullaryOp& func);
361 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
363 NullaryExpr(
const CustomNullaryOp& func);
365 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Zero(Index rows, Index cols);
366 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Zero(Index size);
367 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Zero();
368 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones(Index rows, Index cols);
369 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones(Index size);
370 EIGEN_DEVICE_FUNC
static const ConstantReturnType
Ones();
372 EIGEN_DEVICE_FUNC
void fill(
const Scalar&
value);
374 EIGEN_DEVICE_FUNC Derived&
setLinSpaced(Index size,
const Scalar& low,
const Scalar& high);
375 EIGEN_DEVICE_FUNC Derived&
setLinSpaced(
const Scalar& low,
const Scalar& high);
377 EIGEN_DEVICE_FUNC Derived&
setOnes();
380 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
384 bool isMuchSmallerThan(
const RealScalar& other,
386 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
395 inline bool hasNaN()
const;
399 inline Derived& operator*=(
const Scalar& other);
401 inline Derived& operator/=(
const Scalar& other);
403 typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;
412 EIGEN_STRONG_INLINE EvalReturnType
eval()
const
417 return typename internal::eval<Derived>::type(derived());
423 template<
typename OtherDerived>
427 EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
428 eigen_assert(rows()==other.rows() && cols()==other.cols());
429 call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
435 template<
typename OtherDerived>
439 eigen_assert(rows()==other.rows() && cols()==other.cols());
440 call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
446 template<
bool Enable> EIGEN_DEVICE_FUNC
447 inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf()
const;
448 template<
bool Enable> EIGEN_DEVICE_FUNC
449 inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
451 EIGEN_DEVICE_FUNC Scalar
sum()
const;
452 EIGEN_DEVICE_FUNC Scalar
mean()
const;
453 EIGEN_DEVICE_FUNC Scalar trace()
const;
455 EIGEN_DEVICE_FUNC Scalar
prod()
const;
457 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar
minCoeff()
const;
458 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar
maxCoeff()
const;
460 template<
typename IndexType> EIGEN_DEVICE_FUNC
461 typename internal::traits<Derived>::Scalar
minCoeff(IndexType*
row, IndexType*
col)
const;
462 template<
typename IndexType> EIGEN_DEVICE_FUNC
463 typename internal::traits<Derived>::Scalar
maxCoeff(IndexType*
row, IndexType*
col)
const;
464 template<
typename IndexType> EIGEN_DEVICE_FUNC
465 typename internal::traits<Derived>::Scalar
minCoeff(IndexType* index)
const;
466 template<
typename IndexType> EIGEN_DEVICE_FUNC
467 typename internal::traits<Derived>::Scalar
maxCoeff(IndexType* index)
const;
469 template<
typename BinaryOp>
471 Scalar redux(
const BinaryOp& func)
const;
473 template<
typename Visitor>
475 void visit(Visitor& func)
const;
483 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
484 eigen_assert(this->rows() == 1 && this->cols() == 1);
485 return derived().coeff(0,0);
505 EIGEN_DEVICE_FUNC
inline ConstRowwiseReturnType
rowwise()
const {
506 return ConstRowwiseReturnType(derived());
508 EIGEN_DEVICE_FUNC RowwiseReturnType
rowwise();
517 EIGEN_DEVICE_FUNC
inline ConstColwiseReturnType
colwise()
const {
518 return ConstColwiseReturnType(derived());
520 EIGEN_DEVICE_FUNC ColwiseReturnType
colwise();
523 static const RandomReturnType
Random(Index rows, Index cols);
524 static const RandomReturnType
Random(Index size);
525 static const RandomReturnType
Random();
527 template<
typename ThenDerived,
typename ElseDerived>
532 template<
typename ThenDerived>
536 template<
typename ElseDerived>
540 template<
int p> RealScalar lpNorm()
const;
542 template<
int RowFactor,
int ColFactor>
562 EIGEN_DEVICE_FUNC ReverseReturnType
reverse();
565 EIGEN_DEVICE_FUNC ConstReverseReturnType
reverse()
const
567 return ConstReverseReturnType(derived());
571 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
572 # include "../plugins/BlockMethods.h"
573 # ifdef EIGEN_DENSEBASE_PLUGIN
574 # include EIGEN_DENSEBASE_PLUGIN
576 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
580 template<
typename Dest>
582 inline void evalTo(Dest& )
const
584 EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
594 #ifdef EIGEN_INTERNAL_DEBUGGING
597 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
602 EIGEN_DEVICE_FUNC
explicit DenseBase(
int);
609 #endif // EIGEN_DENSEBASE_H
ConstReverseReturnType reverse() const
Definition: DenseBase.h:565
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:44
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103
const Replicate< Derived, Dynamic, Dynamic > replicate(Index rowFactor, Index colFactor) const
Definition: DenseBase.h:555
ColXpr col(Index i)
Definition: DenseBase.h:778
Enforce aligned packet loads and stores regardless of what is requested.
Definition: ForceAlignedAccess.h:34
Definition: Constants.h:314
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:72
bool any() const
Definition: BooleanRedux.h:107
const Replicate< Derived, RowFactor, ColFactor > replicate() const
Definition: Replicate.h:118
Scalar prod() const
Definition: Redux.h:487
bool allFinite() const
Definition: BooleanRedux.h:153
Expression of the transpose of a matrix.
Definition: Transpose.h:53
Derived & setRandom()
Definition: Random.h:132
static const SequentialLinSpacedReturnType LinSpaced(Sequential_t, Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition: CwiseNullaryOp.h:245
Scalar value_type
Definition: DenseBase.h:77
Derived & operator=(const DenseBase< OtherDerived > &other)
Definition: Assign.h:39
void visit(Visitor &func) const
Definition: Visitor.h:107
internal::traits< Derived >::Scalar maxCoeff() const
Definition: Redux.h:449
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:107
RowXpr row(Index i)
Definition: DenseBase.h:797
Definition: DenseBase.h:120
Definition: DenseBase.h:107
Pseudo expression providing partial reduction operations.
Definition: ForwardDeclarations.h:242
ConstColwiseReturnType colwise() const
Definition: DenseBase.h:517
const unsigned int RowMajorBit
Definition: Constants.h:53
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
CommaInitializer< Derived > operator<<(const Scalar &s)
Definition: CommaInitializer.h:147
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:193
static const RandomReturnType Random()
Definition: Random.h:114
Scalar mean() const
Definition: Redux.h:473
TransposeReturnType transpose()
Definition: Transpose.h:166
Definition: DenseBase.h:148
static const ConstantReturnType Constant(Index rows, Index cols, const Scalar &value)
Definition: CwiseNullaryOp.h:182
void resize(Index newSize)
Definition: DenseBase.h:252
Helper class used by the comma initializer operator.
Definition: CommaInitializer.h:28
internal::traits< Derived >::StorageIndex StorageIndex
The type used to store indices.
Definition: DenseBase.h:69
Definition: EigenBase.h:28
Definition: Constants.h:494
Index innerSize() const
Definition: DenseBase.h:241
bool isZero(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:486
Definition: DenseBase.h:160
Index outerSize() const
Definition: DenseBase.h:229
Definition: DenseBase.h:137
static const ConstantReturnType Zero()
Definition: CwiseNullaryOp.h:472
void fill(const Scalar &value)
Definition: CwiseNullaryOp.h:326
CoeffReturnType value() const
Definition: DenseBase.h:481
Dense storage base class for matrices and arrays.
Definition: PlainObjectBase.h:88
Expression of the multiple replication of a matrix or vector.
Definition: Replicate.h:60
EIGEN_DEPRECATED const Derived & flagged() const
Definition: DenseBase.h:323
bool isOnes(const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:617
bool all() const
Definition: BooleanRedux.h:81
EvalReturnType eval() const
Definition: DenseBase.h:412
Scalar sum() const
Definition: Redux.h:460
Expression which must be nested by value.
Definition: NestByValue.h:35
void swap(const DenseBase< OtherDerived > &other)
Definition: DenseBase.h:425
ReverseReturnType reverse()
Definition: Reverse.h:118
static const ConstantReturnType Ones()
Definition: CwiseNullaryOp.h:602
Derived & setLinSpaced(Index size, const Scalar &low, const Scalar &high)
Sets a linearly space vector.
Definition: CwiseNullaryOp.h:391
DenseBase()
Definition: DenseBase.h:589
Derived & lazyAssign(const DenseBase< OtherDerived > &other)
Definition: Assign.h:20
bool hasNaN() const
Definition: BooleanRedux.h:143
internal::traits< Derived >::Scalar minCoeff() const
Definition: Redux.h:439
const Select< Derived, ThenDerived, ElseDerived > select(const DenseBase< ThenDerived > &thenMatrix, const DenseBase< ElseDerived > &elseMatrix) const
Definition: Select.h:124
Definition: DenseBase.h:113
Definition: Eigen_Colamd.h:54
Definition: DenseBase.h:172
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.
Definition: DenseBase.h:212
Index nonZeros() const
Definition: DenseBase.h:217
bool isConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:316
Derived & setZero()
Definition: CwiseNullaryOp.h:504
Index count() const
Definition: BooleanRedux.h:133
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45
Definition: Constants.h:316
Derived & setOnes()
Definition: CwiseNullaryOp.h:630
ConstRowwiseReturnType rowwise() const
Definition: DenseBase.h:505
const NestByValue< Derived > nestByValue() const
Definition: NestByValue.h:104
void reverseInPlace()
Definition: Reverse.h:139
bool isApproxToConstant(const Scalar &value, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: CwiseNullaryOp.h:301
Derived & setConstant(const Scalar &value)
Definition: CwiseNullaryOp.h:336
Definition: Constants.h:312
Definition: DenseBase.h:167
const WithFormat< Derived > format(const IOFormat &fmt) const
Definition: IO.h:121
void transposeInPlace()
Definition: Transpose.h:278
Definition: DenseBase.h:126
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:178
Expression of the reverse of a vector or matrix.
Definition: Reverse.h:63
void resize(Index rows, Index cols)
Definition: DenseBase.h:263
void swap(PlainObjectBase< OtherDerived > &other)
Definition: DenseBase.h:437
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition: Select.h:52