Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:56:12

0001 // This file is part of Eigen, a lightweight C++ template library
0002 // for linear algebra.
0003 //
0004 // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
0005 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
0006 //
0007 // This Source Code Form is subject to the terms of the Mozilla
0008 // Public License v. 2.0. If a copy of the MPL was not distributed
0009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
0010 
0011 #ifndef EIGEN_DENSEBASE_H
0012 #define EIGEN_DENSEBASE_H
0013 
0014 namespace Eigen {
0015 
0016 namespace internal {
0017 
0018 // The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type.
0019 // This dummy function simply aims at checking that at compile time.
0020 static inline void check_DenseIndex_is_signed() {
0021   EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE)
0022 }
0023 
0024 } // end namespace internal
0025 
0026 /** \class DenseBase
0027   * \ingroup Core_Module
0028   *
0029   * \brief Base class for all dense matrices, vectors, and arrays
0030   *
0031   * This class is the base that is inherited by all dense objects (matrix, vector, arrays,
0032   * and related expression types). The common Eigen API for dense objects is contained in this class.
0033   *
0034   * \tparam Derived is the derived type, e.g., a matrix type or an expression.
0035   *
0036   * This class can be extended with the help of the plugin mechanism described on the page
0037   * \ref TopicCustomizing_Plugins by defining the preprocessor symbol \c EIGEN_DENSEBASE_PLUGIN.
0038   *
0039   * \sa \blank \ref TopicClassHierarchy
0040   */
0041 template<typename Derived> class DenseBase
0042 #ifndef EIGEN_PARSED_BY_DOXYGEN
0043   : public DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value>
0044 #else
0045   : public DenseCoeffsBase<Derived,DirectWriteAccessors>
0046 #endif // not EIGEN_PARSED_BY_DOXYGEN
0047 {
0048   public:
0049 
0050     /** Inner iterator type to iterate over the coefficients of a row or column.
0051       * \sa class InnerIterator
0052       */
0053     typedef Eigen::InnerIterator<Derived> InnerIterator;
0054 
0055     typedef typename internal::traits<Derived>::StorageKind StorageKind;
0056 
0057     /**
0058       * \brief The type used to store indices
0059       * \details This typedef is relevant for types that store multiple indices such as
0060       *          PermutationMatrix or Transpositions, otherwise it defaults to Eigen::Index
0061       * \sa \blank \ref TopicPreprocessorDirectives, Eigen::Index, SparseMatrixBase.
0062      */
0063     typedef typename internal::traits<Derived>::StorageIndex StorageIndex;
0064 
0065     /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc. */
0066     typedef typename internal::traits<Derived>::Scalar Scalar;
0067 
0068     /** The numeric type of the expression' coefficients, e.g. float, double, int or std::complex<float>, etc.
0069       *
0070       * It is an alias for the Scalar type */
0071     typedef Scalar value_type;
0072 
0073     typedef typename NumTraits<Scalar>::Real RealScalar;
0074     typedef DenseCoeffsBase<Derived, internal::accessors_level<Derived>::value> Base;
0075 
0076     using Base::derived;
0077     using Base::const_cast_derived;
0078     using Base::rows;
0079     using Base::cols;
0080     using Base::size;
0081     using Base::rowIndexByOuterInner;
0082     using Base::colIndexByOuterInner;
0083     using Base::coeff;
0084     using Base::coeffByOuterInner;
0085     using Base::operator();
0086     using Base::operator[];
0087     using Base::x;
0088     using Base::y;
0089     using Base::z;
0090     using Base::w;
0091     using Base::stride;
0092     using Base::innerStride;
0093     using Base::outerStride;
0094     using Base::rowStride;
0095     using Base::colStride;
0096     typedef typename Base::CoeffReturnType CoeffReturnType;
0097 
0098     enum {
0099 
0100       RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
0101         /**< The number of rows at compile-time. This is just a copy of the value provided
0102           * by the \a Derived type. If a value is not known at compile-time,
0103           * it is set to the \a Dynamic constant.
0104           * \sa MatrixBase::rows(), MatrixBase::cols(), ColsAtCompileTime, SizeAtCompileTime */
0105 
0106       ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
0107         /**< The number of columns at compile-time. This is just a copy of the value provided
0108           * by the \a Derived type. If a value is not known at compile-time,
0109           * it is set to the \a Dynamic constant.
0110           * \sa MatrixBase::rows(), MatrixBase::cols(), RowsAtCompileTime, SizeAtCompileTime */
0111 
0112 
0113       SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
0114                                                    internal::traits<Derived>::ColsAtCompileTime>::ret),
0115         /**< This is equal to the number of coefficients, i.e. the number of
0116           * rows times the number of columns, or to \a Dynamic if this is not
0117           * known at compile-time. \sa RowsAtCompileTime, ColsAtCompileTime */
0118 
0119       MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
0120         /**< This value is equal to the maximum possible number of rows that this expression
0121           * might have. If this expression might have an arbitrarily high number of rows,
0122           * this value is set to \a Dynamic.
0123           *
0124           * This value is useful to know when evaluating an expression, in order to determine
0125           * whether it is possible to avoid doing a dynamic memory allocation.
0126           *
0127           * \sa RowsAtCompileTime, MaxColsAtCompileTime, MaxSizeAtCompileTime
0128           */
0129 
0130       MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
0131         /**< This value is equal to the maximum possible number of columns that this expression
0132           * might have. If this expression might have an arbitrarily high number of columns,
0133           * this value is set to \a Dynamic.
0134           *
0135           * This value is useful to know when evaluating an expression, in order to determine
0136           * whether it is possible to avoid doing a dynamic memory allocation.
0137           *
0138           * \sa ColsAtCompileTime, MaxRowsAtCompileTime, MaxSizeAtCompileTime
0139           */
0140 
0141       MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
0142                                                       internal::traits<Derived>::MaxColsAtCompileTime>::ret),
0143         /**< This value is equal to the maximum possible number of coefficients that this expression
0144           * might have. If this expression might have an arbitrarily high number of coefficients,
0145           * this value is set to \a Dynamic.
0146           *
0147           * This value is useful to know when evaluating an expression, in order to determine
0148           * whether it is possible to avoid doing a dynamic memory allocation.
0149           *
0150           * \sa SizeAtCompileTime, MaxRowsAtCompileTime, MaxColsAtCompileTime
0151           */
0152 
0153       IsVectorAtCompileTime = internal::traits<Derived>::RowsAtCompileTime == 1
0154                            || internal::traits<Derived>::ColsAtCompileTime == 1,
0155         /**< This is set to true if either the number of rows or the number of
0156           * columns is known at compile-time to be equal to 1. Indeed, in that case,
0157           * we are dealing with a column-vector (if there is only one column) or with
0158           * a row-vector (if there is only one row). */
0159 
0160       NumDimensions = int(MaxSizeAtCompileTime) == 1 ? 0 : bool(IsVectorAtCompileTime) ? 1 : 2,
0161         /**< This value is equal to Tensor::NumDimensions, i.e. 0 for scalars, 1 for vectors,
0162          * and 2 for matrices.
0163          */
0164 
0165       Flags = internal::traits<Derived>::Flags,
0166         /**< This stores expression \ref flags flags which may or may not be inherited by new expressions
0167           * constructed from this one. See the \ref flags "list of flags".
0168           */
0169 
0170       IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */
0171 
0172       InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
0173                              : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
0174 
0175       InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
0176       OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
0177     };
0178 
0179     typedef typename internal::find_best_packet<Scalar,SizeAtCompileTime>::type PacketScalar;
0180 
0181     enum { IsPlainObjectBase = 0 };
0182 
0183     /** The plain matrix type corresponding to this expression.
0184       * \sa PlainObject */
0185     typedef Matrix<typename internal::traits<Derived>::Scalar,
0186                 internal::traits<Derived>::RowsAtCompileTime,
0187                 internal::traits<Derived>::ColsAtCompileTime,
0188                 AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
0189                 internal::traits<Derived>::MaxRowsAtCompileTime,
0190                 internal::traits<Derived>::MaxColsAtCompileTime
0191           > PlainMatrix;
0192 
0193     /** The plain array type corresponding to this expression.
0194       * \sa PlainObject */
0195     typedef Array<typename internal::traits<Derived>::Scalar,
0196                 internal::traits<Derived>::RowsAtCompileTime,
0197                 internal::traits<Derived>::ColsAtCompileTime,
0198                 AutoAlign | (internal::traits<Derived>::Flags&RowMajorBit ? RowMajor : ColMajor),
0199                 internal::traits<Derived>::MaxRowsAtCompileTime,
0200                 internal::traits<Derived>::MaxColsAtCompileTime
0201           > PlainArray;
0202 
0203     /** \brief The plain matrix or array type corresponding to this expression.
0204       *
0205       * This is not necessarily exactly the return type of eval(). In the case of plain matrices,
0206       * the return type of eval() is a const reference to a matrix, not a matrix! It is however guaranteed
0207       * that the return type of eval() is either PlainObject or const PlainObject&.
0208       */
0209     typedef typename internal::conditional<internal::is_same<typename internal::traits<Derived>::XprKind,MatrixXpr >::value,
0210                                  PlainMatrix, PlainArray>::type PlainObject;
0211 
0212     /** \returns the number of nonzero coefficients which is in practice the number
0213       * of stored coefficients. */
0214     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0215     inline Index nonZeros() const { return size(); }
0216 
0217     /** \returns the outer size.
0218       *
0219       * \note For a vector, this returns just 1. For a matrix (non-vector), this is the major dimension
0220       * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of columns for a
0221       * column-major matrix, and the number of rows for a row-major matrix. */
0222     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0223     Index outerSize() const
0224     {
0225       return IsVectorAtCompileTime ? 1
0226            : int(IsRowMajor) ? this->rows() : this->cols();
0227     }
0228 
0229     /** \returns the inner size.
0230       *
0231       * \note For a vector, this is just the size. For a matrix (non-vector), this is the minor dimension
0232       * with respect to the \ref TopicStorageOrders "storage order", i.e., the number of rows for a
0233       * column-major matrix, and the number of columns for a row-major matrix. */
0234     EIGEN_DEVICE_FUNC EIGEN_CONSTEXPR
0235     Index innerSize() const
0236     {
0237       return IsVectorAtCompileTime ? this->size()
0238            : int(IsRowMajor) ? this->cols() : this->rows();
0239     }
0240 
0241     /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are
0242       * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does
0243       * nothing else.
0244       */
0245     EIGEN_DEVICE_FUNC
0246     void resize(Index newSize)
0247     {
0248       EIGEN_ONLY_USED_FOR_DEBUG(newSize);
0249       eigen_assert(newSize == this->size()
0250                 && "DenseBase::resize() does not actually allow to resize.");
0251     }
0252     /** Only plain matrices/arrays, not expressions, may be resized; therefore the only useful resize methods are
0253       * Matrix::resize() and Array::resize(). The present method only asserts that the new size equals the old size, and does
0254       * nothing else.
0255       */
0256     EIGEN_DEVICE_FUNC
0257     void resize(Index rows, Index cols)
0258     {
0259       EIGEN_ONLY_USED_FOR_DEBUG(rows);
0260       EIGEN_ONLY_USED_FOR_DEBUG(cols);
0261       eigen_assert(rows == this->rows() && cols == this->cols()
0262                 && "DenseBase::resize() does not actually allow to resize.");
0263     }
0264 
0265 #ifndef EIGEN_PARSED_BY_DOXYGEN
0266     /** \internal Represents a matrix with all coefficients equal to one another*/
0267     typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,PlainObject> ConstantReturnType;
0268     /** \internal \deprecated Represents a vector with linearly spaced coefficients that allows sequential access only. */
0269     EIGEN_DEPRECATED typedef CwiseNullaryOp<internal::linspaced_op<Scalar>,PlainObject> SequentialLinSpacedReturnType;
0270     /** \internal Represents a vector with linearly spaced coefficients that allows random access. */
0271     typedef CwiseNullaryOp<internal::linspaced_op<Scalar>,PlainObject> RandomAccessLinSpacedReturnType;
0272     /** \internal the return type of MatrixBase::eigenvalues() */
0273     typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
0274 
0275 #endif // not EIGEN_PARSED_BY_DOXYGEN
0276 
0277     /** Copies \a other into *this. \returns a reference to *this. */
0278     template<typename OtherDerived>
0279     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0280     Derived& operator=(const DenseBase<OtherDerived>& other);
0281 
0282     /** Special case of the template operator=, in order to prevent the compiler
0283       * from generating a default operator= (issue hit with g++ 4.1)
0284       */
0285     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0286     Derived& operator=(const DenseBase& other);
0287 
0288     template<typename OtherDerived>
0289     EIGEN_DEVICE_FUNC
0290     Derived& operator=(const EigenBase<OtherDerived> &other);
0291 
0292     template<typename OtherDerived>
0293     EIGEN_DEVICE_FUNC
0294     Derived& operator+=(const EigenBase<OtherDerived> &other);
0295 
0296     template<typename OtherDerived>
0297     EIGEN_DEVICE_FUNC
0298     Derived& operator-=(const EigenBase<OtherDerived> &other);
0299 
0300     template<typename OtherDerived>
0301     EIGEN_DEVICE_FUNC
0302     Derived& operator=(const ReturnByValue<OtherDerived>& func);
0303 
0304     /** \internal
0305       * Copies \a other into *this without evaluating other. \returns a reference to *this. */
0306     template<typename OtherDerived>
0307     /** \deprecated */
0308     EIGEN_DEPRECATED EIGEN_DEVICE_FUNC
0309     Derived& lazyAssign(const DenseBase<OtherDerived>& other);
0310 
0311     EIGEN_DEVICE_FUNC
0312     CommaInitializer<Derived> operator<< (const Scalar& s);
0313 
0314     template<unsigned int Added,unsigned int Removed>
0315     /** \deprecated it now returns \c *this */
0316     EIGEN_DEPRECATED
0317     const Derived& flagged() const
0318     { return derived(); }
0319 
0320     template<typename OtherDerived>
0321     EIGEN_DEVICE_FUNC
0322     CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);
0323 
0324     typedef Transpose<Derived> TransposeReturnType;
0325     EIGEN_DEVICE_FUNC
0326     TransposeReturnType transpose();
0327     typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;
0328     EIGEN_DEVICE_FUNC
0329     ConstTransposeReturnType transpose() const;
0330     EIGEN_DEVICE_FUNC
0331     void transposeInPlace();
0332 
0333     EIGEN_DEVICE_FUNC static const ConstantReturnType
0334     Constant(Index rows, Index cols, const Scalar& value);
0335     EIGEN_DEVICE_FUNC static const ConstantReturnType
0336     Constant(Index size, const Scalar& value);
0337     EIGEN_DEVICE_FUNC static const ConstantReturnType
0338     Constant(const Scalar& value);
0339 
0340     EIGEN_DEPRECATED EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType
0341     LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high);
0342     EIGEN_DEPRECATED EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType
0343     LinSpaced(Sequential_t, const Scalar& low, const Scalar& high);
0344 
0345     EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType
0346     LinSpaced(Index size, const Scalar& low, const Scalar& high);
0347     EIGEN_DEVICE_FUNC static const RandomAccessLinSpacedReturnType
0348     LinSpaced(const Scalar& low, const Scalar& high);
0349 
0350     template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
0351     static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
0352     NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);
0353     template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
0354     static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
0355     NullaryExpr(Index size, const CustomNullaryOp& func);
0356     template<typename CustomNullaryOp> EIGEN_DEVICE_FUNC
0357     static const CwiseNullaryOp<CustomNullaryOp, PlainObject>
0358     NullaryExpr(const CustomNullaryOp& func);
0359 
0360     EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index rows, Index cols);
0361     EIGEN_DEVICE_FUNC static const ConstantReturnType Zero(Index size);
0362     EIGEN_DEVICE_FUNC static const ConstantReturnType Zero();
0363     EIGEN_DEVICE_FUNC static const ConstantReturnType Ones(Index rows, Index cols);
0364     EIGEN_DEVICE_FUNC static const ConstantReturnType Ones(Index size);
0365     EIGEN_DEVICE_FUNC static const ConstantReturnType Ones();
0366 
0367     EIGEN_DEVICE_FUNC void fill(const Scalar& value);
0368     EIGEN_DEVICE_FUNC Derived& setConstant(const Scalar& value);
0369     EIGEN_DEVICE_FUNC Derived& setLinSpaced(Index size, const Scalar& low, const Scalar& high);
0370     EIGEN_DEVICE_FUNC Derived& setLinSpaced(const Scalar& low, const Scalar& high);
0371     EIGEN_DEVICE_FUNC Derived& setZero();
0372     EIGEN_DEVICE_FUNC Derived& setOnes();
0373     EIGEN_DEVICE_FUNC Derived& setRandom();
0374 
0375     template<typename OtherDerived> EIGEN_DEVICE_FUNC
0376     bool isApprox(const DenseBase<OtherDerived>& other,
0377                   const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0378     EIGEN_DEVICE_FUNC
0379     bool isMuchSmallerThan(const RealScalar& other,
0380                            const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0381     template<typename OtherDerived> EIGEN_DEVICE_FUNC
0382     bool isMuchSmallerThan(const DenseBase<OtherDerived>& other,
0383                            const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0384 
0385     EIGEN_DEVICE_FUNC bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0386     EIGEN_DEVICE_FUNC bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0387     EIGEN_DEVICE_FUNC bool isZero(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0388     EIGEN_DEVICE_FUNC bool isOnes(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
0389 
0390     inline bool hasNaN() const;
0391     inline bool allFinite() const;
0392 
0393     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0394     Derived& operator*=(const Scalar& other);
0395     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0396     Derived& operator/=(const Scalar& other);
0397 
0398     typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;
0399     /** \returns the matrix or vector obtained by evaluating this expression.
0400       *
0401       * Notice that in the case of a plain matrix or vector (not an expression) this function just returns
0402       * a const reference, in order to avoid a useless copy.
0403       *
0404       * \warning Be careful with eval() and the auto C++ keyword, as detailed in this \link TopicPitfalls_auto_keyword page \endlink.
0405       */
0406     EIGEN_DEVICE_FUNC
0407     EIGEN_STRONG_INLINE EvalReturnType eval() const
0408     {
0409       // Even though MSVC does not honor strong inlining when the return type
0410       // is a dynamic matrix, we desperately need strong inlining for fixed
0411       // size types on MSVC.
0412       return typename internal::eval<Derived>::type(derived());
0413     }
0414 
0415     /** swaps *this with the expression \a other.
0416       *
0417       */
0418     template<typename OtherDerived>
0419     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0420     void swap(const DenseBase<OtherDerived>& other)
0421     {
0422       EIGEN_STATIC_ASSERT(!OtherDerived::IsPlainObjectBase,THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
0423       eigen_assert(rows()==other.rows() && cols()==other.cols());
0424       call_assignment(derived(), other.const_cast_derived(), internal::swap_assign_op<Scalar>());
0425     }
0426 
0427     /** swaps *this with the matrix or array \a other.
0428       *
0429       */
0430     template<typename OtherDerived>
0431     EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
0432     void swap(PlainObjectBase<OtherDerived>& other)
0433     {
0434       eigen_assert(rows()==other.rows() && cols()==other.cols());
0435       call_assignment(derived(), other.derived(), internal::swap_assign_op<Scalar>());
0436     }
0437 
0438     EIGEN_DEVICE_FUNC inline const NestByValue<Derived> nestByValue() const;
0439     EIGEN_DEVICE_FUNC inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
0440     EIGEN_DEVICE_FUNC inline ForceAlignedAccess<Derived> forceAlignedAccess();
0441     template<bool Enable> EIGEN_DEVICE_FUNC
0442     inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf() const;
0443     template<bool Enable> EIGEN_DEVICE_FUNC
0444     inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
0445 
0446     EIGEN_DEVICE_FUNC Scalar sum() const;
0447     EIGEN_DEVICE_FUNC Scalar mean() const;
0448     EIGEN_DEVICE_FUNC Scalar trace() const;
0449 
0450     EIGEN_DEVICE_FUNC Scalar prod() const;
0451 
0452     template<int NaNPropagation>
0453     EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar minCoeff() const;
0454     template<int NaNPropagation>
0455     EIGEN_DEVICE_FUNC typename internal::traits<Derived>::Scalar maxCoeff() const;
0456 
0457 
0458     // By default, the fastest version with undefined NaN propagation semantics is
0459     // used.
0460     // TODO(rmlarsen): Replace with default template argument when we move to
0461     // c++11 or beyond.
0462     EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar minCoeff() const {
0463       return minCoeff<PropagateFast>();
0464     }
0465     EIGEN_DEVICE_FUNC inline typename internal::traits<Derived>::Scalar maxCoeff() const {
0466       return maxCoeff<PropagateFast>();
0467     }
0468 
0469     template<int NaNPropagation, typename IndexType>
0470     EIGEN_DEVICE_FUNC
0471     typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const;
0472     template<int NaNPropagation, typename IndexType>
0473     EIGEN_DEVICE_FUNC
0474     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const;
0475     template<int NaNPropagation, typename IndexType>
0476     EIGEN_DEVICE_FUNC
0477     typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const;
0478     template<int NaNPropagation, typename IndexType>
0479     EIGEN_DEVICE_FUNC
0480     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const;
0481 
0482     // TODO(rmlarsen): Replace these methods with a default template argument.
0483     template<typename IndexType>
0484     EIGEN_DEVICE_FUNC inline
0485     typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const {
0486       return minCoeff<PropagateFast>(row, col);
0487     }
0488     template<typename IndexType>
0489     EIGEN_DEVICE_FUNC inline
0490     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const {
0491       return maxCoeff<PropagateFast>(row, col);
0492     }
0493     template<typename IndexType>
0494      EIGEN_DEVICE_FUNC inline
0495     typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const {
0496       return minCoeff<PropagateFast>(index);
0497     }
0498     template<typename IndexType>
0499     EIGEN_DEVICE_FUNC inline
0500     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const {
0501       return maxCoeff<PropagateFast>(index);
0502     }
0503   
0504     template<typename BinaryOp>
0505     EIGEN_DEVICE_FUNC
0506     Scalar redux(const BinaryOp& func) const;
0507 
0508     template<typename Visitor>
0509     EIGEN_DEVICE_FUNC
0510     void visit(Visitor& func) const;
0511 
0512     /** \returns a WithFormat proxy object allowing to print a matrix the with given
0513       * format \a fmt.
0514       *
0515       * See class IOFormat for some examples.
0516       *
0517       * \sa class IOFormat, class WithFormat
0518       */
0519     inline const WithFormat<Derived> format(const IOFormat& fmt) const
0520     {
0521       return WithFormat<Derived>(derived(), fmt);
0522     }
0523 
0524     /** \returns the unique coefficient of a 1x1 expression */
0525     EIGEN_DEVICE_FUNC
0526     CoeffReturnType value() const
0527     {
0528       EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
0529       eigen_assert(this->rows() == 1 && this->cols() == 1);
0530       return derived().coeff(0,0);
0531     }
0532 
0533     EIGEN_DEVICE_FUNC bool all() const;
0534     EIGEN_DEVICE_FUNC bool any() const;
0535     EIGEN_DEVICE_FUNC Index count() const;
0536 
0537     typedef VectorwiseOp<Derived, Horizontal> RowwiseReturnType;
0538     typedef const VectorwiseOp<const Derived, Horizontal> ConstRowwiseReturnType;
0539     typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType;
0540     typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType;
0541 
0542     /** \returns a VectorwiseOp wrapper of *this for broadcasting and partial reductions
0543     *
0544     * Example: \include MatrixBase_rowwise.cpp
0545     * Output: \verbinclude MatrixBase_rowwise.out
0546     *
0547     * \sa colwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting
0548     */
0549     //Code moved here due to a CUDA compiler bug
0550     EIGEN_DEVICE_FUNC inline ConstRowwiseReturnType rowwise() const {
0551       return ConstRowwiseReturnType(derived());
0552     }
0553     EIGEN_DEVICE_FUNC RowwiseReturnType rowwise();
0554 
0555     /** \returns a VectorwiseOp wrapper of *this broadcasting and partial reductions
0556     *
0557     * Example: \include MatrixBase_colwise.cpp
0558     * Output: \verbinclude MatrixBase_colwise.out
0559     *
0560     * \sa rowwise(), class VectorwiseOp, \ref TutorialReductionsVisitorsBroadcasting
0561     */
0562     EIGEN_DEVICE_FUNC inline ConstColwiseReturnType colwise() const {
0563       return ConstColwiseReturnType(derived());
0564     }
0565     EIGEN_DEVICE_FUNC ColwiseReturnType colwise();
0566 
0567     typedef CwiseNullaryOp<internal::scalar_random_op<Scalar>,PlainObject> RandomReturnType;
0568     static const RandomReturnType Random(Index rows, Index cols);
0569     static const RandomReturnType Random(Index size);
0570     static const RandomReturnType Random();
0571 
0572     template<typename ThenDerived,typename ElseDerived>
0573     inline EIGEN_DEVICE_FUNC const Select<Derived,ThenDerived,ElseDerived>
0574     select(const DenseBase<ThenDerived>& thenMatrix,
0575            const DenseBase<ElseDerived>& elseMatrix) const;
0576 
0577     template<typename ThenDerived>
0578     inline EIGEN_DEVICE_FUNC const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
0579     select(const DenseBase<ThenDerived>& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const;
0580 
0581     template<typename ElseDerived>
0582     inline EIGEN_DEVICE_FUNC const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
0583     select(const typename ElseDerived::Scalar& thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;
0584 
0585     template<int p> RealScalar lpNorm() const;
0586 
0587     template<int RowFactor, int ColFactor>
0588     EIGEN_DEVICE_FUNC
0589     const Replicate<Derived,RowFactor,ColFactor> replicate() const;
0590     /**
0591     * \return an expression of the replication of \c *this
0592     *
0593     * Example: \include MatrixBase_replicate_int_int.cpp
0594     * Output: \verbinclude MatrixBase_replicate_int_int.out
0595     *
0596     * \sa VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate
0597     */
0598     //Code moved here due to a CUDA compiler bug
0599     EIGEN_DEVICE_FUNC
0600     const Replicate<Derived, Dynamic, Dynamic> replicate(Index rowFactor, Index colFactor) const
0601     {
0602       return Replicate<Derived, Dynamic, Dynamic>(derived(), rowFactor, colFactor);
0603     }
0604 
0605     typedef Reverse<Derived, BothDirections> ReverseReturnType;
0606     typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;
0607     EIGEN_DEVICE_FUNC ReverseReturnType reverse();
0608     /** This is the const version of reverse(). */
0609     //Code moved here due to a CUDA compiler bug
0610     EIGEN_DEVICE_FUNC ConstReverseReturnType reverse() const
0611     {
0612       return ConstReverseReturnType(derived());
0613     }
0614     EIGEN_DEVICE_FUNC void reverseInPlace();
0615 
0616     #ifdef EIGEN_PARSED_BY_DOXYGEN
0617     /** STL-like <a href="https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator">RandomAccessIterator</a>
0618       * iterator type as returned by the begin() and end() methods.
0619       */
0620     typedef random_access_iterator_type iterator;
0621     /** This is the const version of iterator (aka read-only) */
0622     typedef random_access_iterator_type const_iterator;
0623     #else
0624     typedef typename internal::conditional< (Flags&DirectAccessBit)==DirectAccessBit,
0625                                             internal::pointer_based_stl_iterator<Derived>,
0626                                             internal::generic_randaccess_stl_iterator<Derived>
0627                                           >::type iterator_type;
0628 
0629     typedef typename internal::conditional< (Flags&DirectAccessBit)==DirectAccessBit,
0630                                             internal::pointer_based_stl_iterator<const Derived>,
0631                                             internal::generic_randaccess_stl_iterator<const Derived>
0632                                           >::type const_iterator_type;
0633 
0634     // Stl-style iterators are supported only for vectors.
0635 
0636     typedef typename internal::conditional< IsVectorAtCompileTime,
0637                                             iterator_type,
0638                                             void
0639                                           >::type iterator;
0640 
0641     typedef typename internal::conditional< IsVectorAtCompileTime,
0642                                             const_iterator_type,
0643                                             void
0644                                           >::type const_iterator;
0645     #endif
0646 
0647     inline iterator begin();
0648     inline const_iterator begin() const;
0649     inline const_iterator cbegin() const;
0650     inline iterator end();
0651     inline const_iterator end() const;
0652     inline const_iterator cend() const;
0653 
0654 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
0655 #define EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
0656 #define EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF(COND)
0657 #define EIGEN_DOC_UNARY_ADDONS(X,Y)
0658 #   include "../plugins/CommonCwiseUnaryOps.h"
0659 #   include "../plugins/BlockMethods.h"
0660 #   include "../plugins/IndexedViewMethods.h"
0661 #   include "../plugins/ReshapedMethods.h"
0662 #   ifdef EIGEN_DENSEBASE_PLUGIN
0663 #     include EIGEN_DENSEBASE_PLUGIN
0664 #   endif
0665 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
0666 #undef EIGEN_DOC_BLOCK_ADDONS_NOT_INNER_PANEL
0667 #undef EIGEN_DOC_BLOCK_ADDONS_INNER_PANEL_IF
0668 #undef EIGEN_DOC_UNARY_ADDONS
0669 
0670     // disable the use of evalTo for dense objects with a nice compilation error
0671     template<typename Dest>
0672     EIGEN_DEVICE_FUNC
0673     inline void evalTo(Dest& ) const
0674     {
0675       EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
0676     }
0677 
0678   protected:
0679     EIGEN_DEFAULT_COPY_CONSTRUCTOR(DenseBase)
0680     /** Default constructor. Do nothing. */
0681     EIGEN_DEVICE_FUNC DenseBase()
0682     {
0683       /* Just checks for self-consistency of the flags.
0684        * Only do it when debugging Eigen, as this borders on paranoia and could slow compilation down
0685        */
0686 #ifdef EIGEN_INTERNAL_DEBUGGING
0687       EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor))
0688                         && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))),
0689                           INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
0690 #endif
0691     }
0692 
0693   private:
0694     EIGEN_DEVICE_FUNC explicit DenseBase(int);
0695     EIGEN_DEVICE_FUNC DenseBase(int,int);
0696     template<typename OtherDerived> EIGEN_DEVICE_FUNC explicit DenseBase(const DenseBase<OtherDerived>&);
0697 };
0698 
0699 } // end namespace Eigen
0700 
0701 #endif // EIGEN_DENSEBASE_H