DenseBase.h
Go to the documentation of this file.
00001 // This file is part of Eigen, a lightweight C++ template library
00002 // for linear algebra.
00003 //
00004 // Copyright (C) 2007-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
00005 // Copyright (C) 2008-2010 Gael Guennebaud <gael.guennebaud@inria.fr>
00006 //
00007 // This Source Code Form is subject to the terms of the Mozilla
00008 // Public License v. 2.0. If a copy of the MPL was not distributed
00009 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
00010 
00011 #ifndef EIGEN_DENSEBASE_H
00012 #define EIGEN_DENSEBASE_H
00013 
00014 namespace Eigen {
00015 
00016 namespace internal {
00017   
00018 // The index type defined by EIGEN_DEFAULT_DENSE_INDEX_TYPE must be a signed type.
00019 // This dummy function simply aims at checking that at compile time.
00020 static inline void check_DenseIndex_is_signed() {
00021   EIGEN_STATIC_ASSERT(NumTraits<DenseIndex>::IsSigned,THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE); 
00022 }
00023 
00024 } // end namespace internal
00025   
00041 template<typename Derived> class DenseBase
00042 #ifndef EIGEN_PARSED_BY_DOXYGEN
00043   : public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
00044                                      typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>
00045 #else
00046   : public DenseCoeffsBase<Derived>
00047 #endif // not EIGEN_PARSED_BY_DOXYGEN
00048 {
00049   public:
00050     using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
00051                 typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*;
00052 
00053     class InnerIterator;
00054 
00055     typedef typename internal::traits<Derived>::StorageKind StorageKind;
00056 
00061     typedef typename internal::traits<Derived>::Index Index; 
00062 
00063     typedef typename internal::traits<Derived>::Scalar Scalar;
00064     typedef typename internal::packet_traits<Scalar>::type PacketScalar;
00065     typedef typename NumTraits<Scalar>::Real RealScalar;
00066 
00067     typedef DenseCoeffsBase<Derived> Base;
00068     using Base::derived;
00069     using Base::const_cast_derived;
00070     using Base::rows;
00071     using Base::cols;
00072     using Base::size;
00073     using Base::rowIndexByOuterInner;
00074     using Base::colIndexByOuterInner;
00075     using Base::coeff;
00076     using Base::coeffByOuterInner;
00077     using Base::packet;
00078     using Base::packetByOuterInner;
00079     using Base::writePacket;
00080     using Base::writePacketByOuterInner;
00081     using Base::coeffRef;
00082     using Base::coeffRefByOuterInner;
00083     using Base::copyCoeff;
00084     using Base::copyCoeffByOuterInner;
00085     using Base::copyPacket;
00086     using Base::copyPacketByOuterInner;
00087     using Base::operator();
00088     using Base::operator[];
00089     using Base::x;
00090     using Base::y;
00091     using Base::z;
00092     using Base::w;
00093     using Base::stride;
00094     using Base::innerStride;
00095     using Base::outerStride;
00096     using Base::rowStride;
00097     using Base::colStride;
00098     typedef typename Base::CoeffReturnType CoeffReturnType;
00099 
00100     enum {
00101 
00102       RowsAtCompileTime = internal::traits<Derived>::RowsAtCompileTime,
00108       ColsAtCompileTime = internal::traits<Derived>::ColsAtCompileTime,
00115       SizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::RowsAtCompileTime,
00116                                                    internal::traits<Derived>::ColsAtCompileTime>::ret),
00121       MaxRowsAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime,
00132       MaxColsAtCompileTime = internal::traits<Derived>::MaxColsAtCompileTime,
00143       MaxSizeAtCompileTime = (internal::size_at_compile_time<internal::traits<Derived>::MaxRowsAtCompileTime,
00144                                                       internal::traits<Derived>::MaxColsAtCompileTime>::ret),
00155       IsVectorAtCompileTime = internal::traits<Derived>::MaxRowsAtCompileTime == 1
00156                            || internal::traits<Derived>::MaxColsAtCompileTime == 1,
00162       Flags = internal::traits<Derived>::Flags,
00167       IsRowMajor = int(Flags) & RowMajorBit, 
00169       InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime)
00170                              : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
00171 
00172       CoeffReadCost = internal::traits<Derived>::CoeffReadCost,
00177       InnerStrideAtCompileTime = internal::inner_stride_at_compile_time<Derived>::ret,
00178       OuterStrideAtCompileTime = internal::outer_stride_at_compile_time<Derived>::ret
00179     };
00180 
00181     enum { ThisConstantIsPrivateInPlainObjectBase };
00182 
00185     inline Index nonZeros() const { return size(); }
00196     Index outerSize() const
00197     {
00198       return IsVectorAtCompileTime ? 1
00199            : int(IsRowMajor) ? this->rows() : this->cols();
00200     }
00201 
00207     Index innerSize() const
00208     {
00209       return IsVectorAtCompileTime ? this->size()
00210            : int(IsRowMajor) ? this->cols() : this->rows();
00211     }
00212 
00217     void resize(Index newSize)
00218     {
00219       EIGEN_ONLY_USED_FOR_DEBUG(newSize);
00220       eigen_assert(newSize == this->size()
00221                 && "DenseBase::resize() does not actually allow to resize.");
00222     }
00227     void resize(Index nbRows, Index nbCols)
00228     {
00229       EIGEN_ONLY_USED_FOR_DEBUG(nbRows);
00230       EIGEN_ONLY_USED_FOR_DEBUG(nbCols);
00231       eigen_assert(nbRows == this->rows() && nbCols == this->cols()
00232                 && "DenseBase::resize() does not actually allow to resize.");
00233     }
00234 
00235 #ifndef EIGEN_PARSED_BY_DOXYGEN
00236 
00238     typedef CwiseNullaryOp<internal::scalar_constant_op<Scalar>,Derived> ConstantReturnType;
00240     typedef CwiseNullaryOp<internal::linspaced_op<Scalar,false>,Derived> SequentialLinSpacedReturnType;
00242     typedef CwiseNullaryOp<internal::linspaced_op<Scalar,true>,Derived> RandomAccessLinSpacedReturnType;
00244     typedef Matrix<typename NumTraits<typename internal::traits<Derived>::Scalar>::Real, internal::traits<Derived>::ColsAtCompileTime, 1> EigenvaluesReturnType;
00245 
00246 #endif // not EIGEN_PARSED_BY_DOXYGEN
00247 
00249     template<typename OtherDerived>
00250     Derived& operator=(const DenseBase<OtherDerived>& other);
00251 
00255     Derived& operator=(const DenseBase& other);
00256 
00257     template<typename OtherDerived>
00258     Derived& operator=(const EigenBase<OtherDerived> &other);
00259 
00260     template<typename OtherDerived>
00261     Derived& operator+=(const EigenBase<OtherDerived> &other);
00262 
00263     template<typename OtherDerived>
00264     Derived& operator-=(const EigenBase<OtherDerived> &other);
00265 
00266     template<typename OtherDerived>
00267     Derived& operator=(const ReturnByValue<OtherDerived>& func);
00268 
00270     template<typename OtherDerived>
00271     Derived& lazyAssign(const DenseBase<OtherDerived>& other);
00272 
00274     template<typename OtherDerived>
00275     Derived& lazyAssign(const ReturnByValue<OtherDerived>& other);
00276 
00277     CommaInitializer<Derived> operator<< (const Scalar& s);
00278 
00279     template<unsigned int Added,unsigned int Removed>
00280     const Flagged<Derived, Added, Removed> flagged() const;
00281 
00282     template<typename OtherDerived>
00283     CommaInitializer<Derived> operator<< (const DenseBase<OtherDerived>& other);
00284 
00285     Eigen::Transpose<Derived> transpose();
00286         typedef typename internal::add_const<Transpose<const Derived> >::type ConstTransposeReturnType;
00287     ConstTransposeReturnType transpose() const;
00288     void transposeInPlace();
00289 #ifndef EIGEN_NO_DEBUG
00290   protected:
00291     template<typename OtherDerived>
00292     void checkTransposeAliasing(const OtherDerived& other) const;
00293   public:
00294 #endif
00295 
00296 
00297     static const ConstantReturnType
00298     Constant(Index rows, Index cols, const Scalar& value);
00299     static const ConstantReturnType
00300     Constant(Index size, const Scalar& value);
00301     static const ConstantReturnType
00302     Constant(const Scalar& value);
00303 
00304     static const SequentialLinSpacedReturnType
00305     LinSpaced(Sequential_t, Index size, const Scalar& low, const Scalar& high);
00306     static const RandomAccessLinSpacedReturnType
00307     LinSpaced(Index size, const Scalar& low, const Scalar& high);
00308     static const SequentialLinSpacedReturnType
00309     LinSpaced(Sequential_t, const Scalar& low, const Scalar& high);
00310     static const RandomAccessLinSpacedReturnType
00311     LinSpaced(const Scalar& low, const Scalar& high);
00312 
00313     template<typename CustomNullaryOp>
00314     static const CwiseNullaryOp<CustomNullaryOp, Derived>
00315     NullaryExpr(Index rows, Index cols, const CustomNullaryOp& func);
00316     template<typename CustomNullaryOp>
00317     static const CwiseNullaryOp<CustomNullaryOp, Derived>
00318     NullaryExpr(Index size, const CustomNullaryOp& func);
00319     template<typename CustomNullaryOp>
00320     static const CwiseNullaryOp<CustomNullaryOp, Derived>
00321     NullaryExpr(const CustomNullaryOp& func);
00322 
00323     static const ConstantReturnType Zero(Index rows, Index cols);
00324     static const ConstantReturnType Zero(Index size);
00325     static const ConstantReturnType Zero();
00326     static const ConstantReturnType Ones(Index rows, Index cols);
00327     static const ConstantReturnType Ones(Index size);
00328     static const ConstantReturnType Ones();
00329 
00330     void fill(const Scalar& value);
00331     Derived& setConstant(const Scalar& value);
00332     Derived& setLinSpaced(Index size, const Scalar& low, const Scalar& high);
00333     Derived& setLinSpaced(const Scalar& low, const Scalar& high);
00334     Derived& setZero();
00335     Derived& setOnes();
00336     Derived& setRandom();
00337 
00338     template<typename OtherDerived>
00339     bool isApprox(const DenseBase<OtherDerived>& other,
00340                   const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00341     bool isMuchSmallerThan(const RealScalar& other,
00342                            const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00343     template<typename OtherDerived>
00344     bool isMuchSmallerThan(const DenseBase<OtherDerived>& other,
00345                            const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00346 
00347     bool isApproxToConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00348     bool isConstant(const Scalar& value, const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00349     bool isZero(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00350     bool isOnes(const RealScalar& prec = NumTraits<Scalar>::dummy_precision()) const;
00351     
00352     inline bool hasNaN() const;
00353     inline bool allFinite() const;
00354 
00355     inline Derived& operator*=(const Scalar& other);
00356     inline Derived& operator/=(const Scalar& other);
00357 
00358     typedef typename internal::add_const_on_value_type<typename internal::eval<Derived>::type>::type EvalReturnType;
00364     EIGEN_STRONG_INLINE EvalReturnType eval() const
00365     {
00366       // Even though MSVC does not honor strong inlining when the return type
00367       // is a dynamic matrix, we desperately need strong inlining for fixed
00368       // size types on MSVC.
00369       return typename internal::eval<Derived>::type(derived());
00370     }
00371 
00375     template<typename OtherDerived>
00376     void swap(const DenseBase<OtherDerived>& other,
00377               int = OtherDerived::ThisConstantIsPrivateInPlainObjectBase)
00378     {
00379       SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
00380     }
00381 
00385     template<typename OtherDerived>
00386     void swap(PlainObjectBase<OtherDerived>& other)
00387     {
00388       SwapWrapper<Derived>(derived()).lazyAssign(other.derived());
00389     }
00390 
00391 
00392     inline const NestByValue<Derived> nestByValue() const;
00393     inline const ForceAlignedAccess<Derived> forceAlignedAccess() const;
00394     inline ForceAlignedAccess<Derived> forceAlignedAccess();
00395     template<bool Enable> inline const typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf() const;
00396     template<bool Enable> inline typename internal::conditional<Enable,ForceAlignedAccess<Derived>,Derived&>::type forceAlignedAccessIf();
00397 
00398     Scalar sum() const;
00399     Scalar mean() const;
00400     Scalar trace() const;
00401 
00402     Scalar prod() const;
00403 
00404     typename internal::traits<Derived>::Scalar minCoeff() const;
00405     typename internal::traits<Derived>::Scalar maxCoeff() const;
00406 
00407     template<typename IndexType>
00408     typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const;
00409     template<typename IndexType>
00410     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const;
00411     template<typename IndexType>
00412     typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const;
00413     template<typename IndexType>
00414     typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const;
00415 
00416     template<typename BinaryOp>
00417     typename internal::result_of<BinaryOp(typename internal::traits<Derived>::Scalar)>::type
00418     redux(const BinaryOp& func) const;
00419 
00420     template<typename Visitor>
00421     void visit(Visitor& func) const;
00422 
00423     inline const WithFormat<Derived> format(const IOFormat& fmt) const;
00424 
00426     CoeffReturnType value() const
00427     {
00428       EIGEN_STATIC_ASSERT_SIZE_1x1(Derived)
00429       eigen_assert(this->rows() == 1 && this->cols() == 1);
00430       return derived().coeff(0,0);
00431     }
00432 
00433     bool all(void) const;
00434     bool any(void) const;
00435     Index count() const;
00436 
00437     typedef VectorwiseOp<Derived, Horizontal> RowwiseReturnType;
00438     typedef const VectorwiseOp<const Derived, Horizontal> ConstRowwiseReturnType;
00439     typedef VectorwiseOp<Derived, Vertical> ColwiseReturnType;
00440     typedef const VectorwiseOp<const Derived, Vertical> ConstColwiseReturnType;
00441 
00442     ConstRowwiseReturnType rowwise() const;
00443     RowwiseReturnType rowwise();
00444     ConstColwiseReturnType colwise() const;
00445     ColwiseReturnType colwise();
00446 
00447     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index rows, Index cols);
00448     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random(Index size);
00449     static const CwiseNullaryOp<internal::scalar_random_op<Scalar>,Derived> Random();
00450 
00451     template<typename ThenDerived,typename ElseDerived>
00452     const Select<Derived,ThenDerived,ElseDerived>
00453     select(const DenseBase<ThenDerived>& thenMatrix,
00454            const DenseBase<ElseDerived>& elseMatrix) const;
00455 
00456     template<typename ThenDerived>
00457     inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
00458     select(const DenseBase<ThenDerived>& thenMatrix, const typename ThenDerived::Scalar& elseScalar) const;
00459 
00460     template<typename ElseDerived>
00461     inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
00462     select(const typename ElseDerived::Scalar& thenScalar, const DenseBase<ElseDerived>& elseMatrix) const;
00463 
00464     template<int p> RealScalar lpNorm() const;
00465 
00466     template<int RowFactor, int ColFactor>
00467     inline const Replicate<Derived,RowFactor,ColFactor> replicate() const;
00468     
00469     typedef Replicate<Derived,Dynamic,Dynamic> ReplicateReturnType;
00470     inline const ReplicateReturnType replicate(Index rowFacor,Index colFactor) const;
00471 
00472     typedef Reverse<Derived, BothDirections> ReverseReturnType;
00473     typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;
00474     ReverseReturnType reverse();
00475     ConstReverseReturnType reverse() const;
00476     void reverseInPlace();
00477 
00478 #define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::DenseBase
00479 #   include "../plugins/BlockMethods.h"
00480 #   ifdef EIGEN_DENSEBASE_PLUGIN
00481 #     include EIGEN_DENSEBASE_PLUGIN
00482 #   endif
00483 #undef EIGEN_CURRENT_STORAGE_BASE_CLASS
00484 
00485 #ifdef EIGEN2_SUPPORT
00486 
00487     Block<Derived> corner(CornerType type, Index cRows, Index cCols);
00488     const Block<Derived> corner(CornerType type, Index cRows, Index cCols) const;
00489     template<int CRows, int CCols>
00490     Block<Derived, CRows, CCols> corner(CornerType type);
00491     template<int CRows, int CCols>
00492     const Block<Derived, CRows, CCols> corner(CornerType type) const;
00493 
00494 #endif // EIGEN2_SUPPORT
00495 
00496 
00497     // disable the use of evalTo for dense objects with a nice compilation error
00498     template<typename Dest> inline void evalTo(Dest& ) const
00499     {
00500       EIGEN_STATIC_ASSERT((internal::is_same<Dest,void>::value),THE_EVAL_EVALTO_FUNCTION_SHOULD_NEVER_BE_CALLED_FOR_DENSE_OBJECTS);
00501     }
00502 
00503   protected:
00505     DenseBase()
00506     {
00507       /* Just checks for self-consistency of the flags.
00508        * Only do it when debugging Eigen, as this borders on paranoiac and could slow compilation down
00509        */
00510 #ifdef EIGEN_INTERNAL_DEBUGGING
00511       EIGEN_STATIC_ASSERT((EIGEN_IMPLIES(MaxRowsAtCompileTime==1 && MaxColsAtCompileTime!=1, int(IsRowMajor))
00512                         && EIGEN_IMPLIES(MaxColsAtCompileTime==1 && MaxRowsAtCompileTime!=1, int(!IsRowMajor))),
00513                           INVALID_STORAGE_ORDER_FOR_THIS_VECTOR_EXPRESSION)
00514 #endif
00515     }
00516 
00517   private:
00518     explicit DenseBase(int);
00519     DenseBase(int,int);
00520     template<typename OtherDerived> explicit DenseBase(const DenseBase<OtherDerived>&);
00521 };
00522 
00523 } // end namespace Eigen
00524 
00525 #endif // EIGEN_DENSEBASE_H


turtlebot_exploration_3d
Author(s): Bona , Shawn
autogenerated on Thu Jun 6 2019 20:58:00