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,
45 DenseCoeffsBase<Derived> >
47 :
public DenseCoeffsBase<Derived>
48 #endif // not EIGEN_PARSED_BY_DOXYGEN 55 typedef Eigen::InnerIterator<Derived> InnerIterator;
57 typedef typename internal::traits<Derived>::StorageKind StorageKind;
65 typedef typename internal::traits<Derived>::StorageIndex
StorageIndex;
68 typedef typename internal::traits<Derived>::Scalar
Scalar;
76 typedef internal::special_scalar_op_base<Derived,Scalar,RealScalar, DenseCoeffsBase<Derived> > Base;
78 using Base::operator*;
79 using Base::operator/;
81 using Base::const_cast_derived;
85 using Base::rowIndexByOuterInner;
86 using Base::colIndexByOuterInner;
88 using Base::coeffByOuterInner;
89 using Base::operator();
90 using Base::operator[];
96 using Base::innerStride;
97 using Base::outerStride;
98 using Base::rowStride;
99 using Base::colStride;
100 typedef typename Base::CoeffReturnType CoeffReturnType;
104 RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
110 ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
117 SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
118 internal::traits<Derived>::ColsAtCompileTime>::ret),
123 MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
134 MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
145 MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
146 internal::traits<Derived>::MaxColsAtCompileTime>::ret),
157 IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1
158 || internal::traits<Derived>::MaxColsAtCompileTime == 1,
164 Flags = internal::traits<Derived>::Flags,
171 InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
172 : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
174 InnerStrideAtCompileTime =
internal::inner_stride_at_compile_time<Derived>::ret,
175 OuterStrideAtCompileTime =
internal::outer_stride_at_compile_time<Derived>::ret
178 typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar;
180 enum { IsPlainObjectBase = 0 };
185 internal::traits<Derived>::RowsAtCompileTime,
186 internal::traits<Derived>::ColsAtCompileTime,
188 internal::traits<Derived>::MaxRowsAtCompileTime,
189 internal::traits<Derived>::MaxColsAtCompileTime
195 internal::traits<Derived>::RowsAtCompileTime,
196 internal::traits<Derived>::ColsAtCompileTime,
198 internal::traits<Derived>::MaxRowsAtCompileTime,
199 internal::traits<Derived>::MaxColsAtCompileTime
208 typedef typename internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,
MatrixXpr >::value,
224 return IsVectorAtCompileTime ? 1
225 : int(IsRowMajor) ? this->rows() : this->cols();
236 return IsVectorAtCompileTime ? this->size()
237 : int(IsRowMajor) ? this->cols() : this->rows();
247 EIGEN_ONLY_USED_FOR_DEBUG(newSize);
248 eigen_assert(newSize == this->size()
249 &&
"DenseBase::resize() does not actually allow to resize.");
258 EIGEN_ONLY_USED_FOR_DEBUG(rows);
259 EIGEN_ONLY_USED_FOR_DEBUG(cols);
260 eigen_assert(rows == this->rows() && cols == this->cols()
261 &&
"DenseBase::resize() does not actually allow to resize.");
264 #ifndef EIGEN_PARSED_BY_DOXYGEN 274 #endif // not EIGEN_PARSED_BY_DOXYGEN 277 template<
typename OtherDerived>
285 Derived& operator=(
const DenseBase& other);
287 template<
typename OtherDerived>
291 template<
typename OtherDerived>
295 template<
typename OtherDerived>
299 template<
typename OtherDerived>
301 Derived& operator=(
const ReturnByValue<OtherDerived>& func);
306 template<
typename OtherDerived>
314 template<
unsigned int Added,
unsigned int Removed>
317 {
return derived(); }
319 template<
typename OtherDerived>
325 TransposeReturnType transpose();
328 ConstTransposeReturnType transpose()
const;
330 void transposeInPlace();
332 EIGEN_DEVICE_FUNC
static const ConstantReturnType
333 Constant(Index rows, Index cols,
const Scalar& value);
334 EIGEN_DEVICE_FUNC
static const ConstantReturnType
335 Constant(Index size,
const Scalar& value);
336 EIGEN_DEVICE_FUNC
static const ConstantReturnType
337 Constant(
const Scalar& value);
339 EIGEN_DEVICE_FUNC
static const SequentialLinSpacedReturnType
340 LinSpaced(Sequential_t, Index size,
const Scalar& low,
const Scalar& high);
341 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
342 LinSpaced(Index size,
const Scalar& low,
const Scalar& high);
343 EIGEN_DEVICE_FUNC
static const SequentialLinSpacedReturnType
344 LinSpaced(Sequential_t,
const Scalar& low,
const Scalar& high);
345 EIGEN_DEVICE_FUNC
static const RandomAccessLinSpacedReturnType
346 LinSpaced(
const Scalar& low,
const Scalar& high);
348 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
350 NullaryExpr(Index rows, Index cols,
const CustomNullaryOp& func);
351 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
353 NullaryExpr(Index size,
const CustomNullaryOp& func);
354 template<
typename CustomNullaryOp> EIGEN_DEVICE_FUNC
356 NullaryExpr(
const CustomNullaryOp& func);
358 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero(Index rows, Index cols);
359 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero(Index size);
360 EIGEN_DEVICE_FUNC
static const ConstantReturnType Zero();
361 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones(Index rows, Index cols);
362 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones(Index size);
363 EIGEN_DEVICE_FUNC
static const ConstantReturnType Ones();
365 EIGEN_DEVICE_FUNC
void fill(
const Scalar& value);
366 EIGEN_DEVICE_FUNC Derived& setConstant(
const Scalar& value);
367 EIGEN_DEVICE_FUNC Derived& setLinSpaced(Index size,
const Scalar& low,
const Scalar& high);
368 EIGEN_DEVICE_FUNC Derived& setLinSpaced(
const Scalar& low,
const Scalar& high);
369 EIGEN_DEVICE_FUNC Derived& setZero();
370 EIGEN_DEVICE_FUNC Derived& setOnes();
371 EIGEN_DEVICE_FUNC Derived& setRandom();
373 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
377 bool isMuchSmallerThan(
const RealScalar& other,
379 template<
typename OtherDerived> EIGEN_DEVICE_FUNC
388 inline bool hasNaN()
const;
389 inline bool allFinite()
const;
392 inline Derived& operator*=(
const Scalar& other);
394 inline Derived& operator/=(
const Scalar& other);
396 typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;
405 EIGEN_STRONG_INLINE EvalReturnType
eval()
const 410 return typename internal::eval<Derived>::type(derived());
416 template<
typename OtherDerived>
420 EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
421 eigen_assert(rows()==other.rows() && cols()==other.cols());
422 call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
428 template<
typename OtherDerived>
432 eigen_assert(rows()==other.rows() && cols()==other.cols());
433 call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
439 template<
bool Enable> EIGEN_DEVICE_FUNC
440 inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf()
const;
441 template<
bool Enable> EIGEN_DEVICE_FUNC
442 inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
444 EIGEN_DEVICE_FUNC Scalar sum()
const;
445 EIGEN_DEVICE_FUNC Scalar mean()
const;
446 EIGEN_DEVICE_FUNC Scalar trace()
const;
448 EIGEN_DEVICE_FUNC Scalar prod()
const;
450 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar minCoeff()
const;
451 EIGEN_DEVICE_FUNC
typename internal::traits<Derived>::Scalar maxCoeff()
const;
453 template<
typename IndexType> EIGEN_DEVICE_FUNC
454 typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col)
const;
455 template<
typename IndexType> EIGEN_DEVICE_FUNC
456 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col)
const;
457 template<
typename IndexType> EIGEN_DEVICE_FUNC
458 typename internal::traits<Derived>::Scalar minCoeff(IndexType* index)
const;
459 template<
typename IndexType> EIGEN_DEVICE_FUNC
460 typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index)
const;
462 template<
typename BinaryOp>
464 Scalar redux(
const BinaryOp& func)
const;
466 template<
typename Visitor>
468 void visit(Visitor& func)
const;
476 EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
477 eigen_assert(this->rows() == 1 && this->cols() == 1);
478 return derived().coeff(0,0);
498 EIGEN_DEVICE_FUNC
inline ConstRowwiseReturnType
rowwise()
const {
499 return ConstRowwiseReturnType(derived());
501 EIGEN_DEVICE_FUNC RowwiseReturnType rowwise();
510 EIGEN_DEVICE_FUNC
inline ConstColwiseReturnType
colwise()
const {
511 return ConstColwiseReturnType(derived());
513 EIGEN_DEVICE_FUNC ColwiseReturnType colwise();
516 static const RandomReturnType Random(Index rows, Index cols);
517 static const RandomReturnType Random(Index size);
518 static const RandomReturnType Random();
520 template<
typename ThenDerived,
typename ElseDerived>
525 template<
typename ThenDerived>
529 template<
typename ElseDerived>
533 template<
int p> RealScalar lpNorm()
const;
535 template<
int RowFactor,
int ColFactor>
555 EIGEN_DEVICE_FUNC ReverseReturnType reverse();
558 EIGEN_DEVICE_FUNC ConstReverseReturnType
reverse()
const 560 return ConstReverseReturnType(derived());
562 EIGEN_DEVICE_FUNC
void reverseInPlace();
564 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase 565 # include "../plugins/BlockMethods.h" 566 # ifdef EIGEN_DENSEBASE_PLUGIN 567 # include EIGEN_DENSEBASE_PLUGIN 569 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS 573 template<
typename Dest>
575 inline void evalTo(Dest& )
const 577 EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
587 #ifdef EIGEN_INTERNAL_DEBUGGING 588 EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1,
int(IsRowMajor))
589 && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1,
int(!IsRowMajor))),
590 INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
595 EIGEN_DEVICE_FUNC
explicit DenseBase(
int);
602 #endif // EIGEN_DENSEBASE_H ConstReverseReturnType reverse() const
Definition: DenseBase.h:558
Generic expression of a matrix where all coefficients are defined by a functor.
Definition: CwiseNullaryOp.h:44
const Replicate< Derived, Dynamic, Dynamic > replicate(Index rowFactor, Index colFactor) const
Definition: DenseBase.h:548
Enforce aligned packet loads and stores regardless of what is requested.
Definition: ForceAlignedAccess.h:34
internal::traits< Derived >::Scalar Scalar
Definition: DenseBase.h:68
Expression of the transpose of a matrix.
Definition: Transpose.h:53
Scalar value_type
Definition: DenseBase.h:73
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:107
Pseudo expression providing partial reduction operations.
Definition: ForwardDeclarations.h:243
ConstColwiseReturnType colwise() const
Definition: DenseBase.h:510
const unsigned int RowMajorBit
Definition: Constants.h:61
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
void resize(Index newSize)
Definition: DenseBase.h:245
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:65
Definition: EigenBase.h:28
Definition: Constants.h:505
Definition: Constants.h:320
Index innerSize() const
Definition: DenseBase.h:234
Index outerSize() const
Definition: DenseBase.h:222
Definition: Constants.h:322
CoeffReturnType value() const
Definition: DenseBase.h:474
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:316
EvalReturnType eval() const
Definition: DenseBase.h:405
Expression which must be nested by value.
Definition: NestByValue.h:35
void swap(const DenseBase< OtherDerived > &other)
Definition: DenseBase.h:418
DenseBase()
Definition: DenseBase.h:582
Definition: Eigen_Colamd.h:54
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:209
Index nonZeros() const
Definition: DenseBase.h:214
Definition: Constants.h:324
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:45
ConstRowwiseReturnType rowwise() const
Definition: DenseBase.h:498
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:256
void swap(PlainObjectBase< OtherDerived > &other)
Definition: DenseBase.h:430
Expression of a coefficient wise version of the C++ ternary operator ?:
Definition: Select.h:52