Main MRPT website > C++ reference
MRPT logo

math_frwds.h

Go to the documentation of this file.
00001 /* +---------------------------------------------------------------------------+
00002    |          The Mobile Robot Programming Toolkit (MRPT) C++ library          |
00003    |                                                                           |
00004    |                   http://mrpt.sourceforge.net/                            |
00005    |                                                                           |
00006    |   Copyright (C) 2005-2011  University of Malaga                           |
00007    |                                                                           |
00008    |    This software was written by the Machine Perception and Intelligent    |
00009    |      Robotics Lab, University of Malaga (Spain).                          |
00010    |    Contact: Jose-Luis Blanco  <jlblanco@ctima.uma.es>                     |
00011    |                                                                           |
00012    |  This file is part of the MRPT project.                                   |
00013    |                                                                           |
00014    |     MRPT is free software: you can redistribute it and/or modify          |
00015    |     it under the terms of the GNU General Public License as published by  |
00016    |     the Free Software Foundation, either version 3 of the License, or     |
00017    |     (at your option) any later version.                                   |
00018    |                                                                           |
00019    |   MRPT is distributed in the hope that it will be useful,                 |
00020    |     but WITHOUT ANY WARRANTY; without even the implied warranty of        |
00021    |     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         |
00022    |     GNU General Public License for more details.                          |
00023    |                                                                           |
00024    |     You should have received a copy of the GNU General Public License     |
00025    |     along with MRPT.  If not, see <http://www.gnu.org/licenses/>.         |
00026    |                                                                           |
00027    +---------------------------------------------------------------------------+ */
00028 #ifndef mrpt_math_forwddecls_H
00029 #define mrpt_math_forwddecls_H
00030 
00031 #include <mrpt/config.h>
00032 #include <mrpt/base/link_pragmas.h>
00033 #include <cmath>
00034 #include <cstdlib>
00035 #include <algorithm>
00036 
00037 /*! \file math_frwds.h
00038   * Forward declarations of all mrpt::math classes related to vectors, arrays and matrices.
00039   * Many of the function implementations are in ops_matrices.h, others in ops_containers.h
00040   */
00041 
00042 namespace mrpt
00043 {
00044         namespace utils
00045         {
00046                 class BASE_IMPEXP CStream;
00047                 template<class T> inline T square(const T x);
00048         }
00049 
00050         namespace system
00051         {
00052                 std::string BASE_IMPEXP MRPT_getVersion();
00053         }
00054 
00055         namespace poses
00056         {
00057                 class CPoint2D;
00058                 class CPoint3D;
00059                 class CPose2D;
00060                 class CPose3D;
00061                 class CPose3DQuat;
00062         }
00063 
00064         namespace math
00065         {
00066                 struct TPoint2D;
00067                 struct TPoint3D;
00068                 struct TPose2D;
00069                 struct TPose3D;
00070                 struct TPose3DQuat;
00071 
00072                 namespace detail
00073                 {
00074                         /** Internal resize which compiles to nothing on fixed-size matrices. */
00075                         template <typename MAT,int TypeSizeAtCompileTime>
00076                         struct TAuxResizer {
00077                                 static inline void internal_resize(MAT &obj, size_t row, size_t col) { }
00078                                 static inline void internal_resize(MAT &obj, size_t nsize) { }
00079                         };
00080                         template <typename MAT>
00081                         struct TAuxResizer<MAT,-1> {
00082                                 static inline void internal_resize(MAT &obj, size_t row, size_t col) { obj.derived().conservativeResize(row,col); }
00083                                 static inline void internal_resize(MAT &obj, size_t nsize) { obj.derived().conservativeResize(nsize); }
00084                         };
00085                 }
00086 
00087 
00088                 /*! Selection of the number format in CMatrixTemplate::saveToTextFile
00089                   */
00090                 enum TMatrixTextFileFormat
00091                 {
00092                         MATRIX_FORMAT_ENG = 0,   //!< engineering format '%e'
00093                         MATRIX_FORMAT_FIXED = 1, //!< fixed floating point '%f'
00094                         MATRIX_FORMAT_INT = 2    //!< intergers '%i'
00095                 };
00096 
00097                 /** For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required
00098                      to fill it with zeros at the constructor to save time. */
00099                 enum TConstructorFlags_Matrices
00100                 {
00101                         UNINITIALIZED_MATRIX = 0
00102                 };
00103 
00104                 // ---------------- Forward declarations: Classes ----------------
00105                 template <class T> class CMatrixTemplate;
00106                 template <class T> class CMatrixTemplateObjects;
00107 
00108 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
00109                 explicit inline _CLASS_( const mrpt::math::TPose2D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00110                 explicit inline _CLASS_( const mrpt::math::TPose3D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00111                 explicit inline _CLASS_( const mrpt::math::TPose3DQuat &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00112                 explicit inline _CLASS_( const mrpt::math::TPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00113                 explicit inline _CLASS_( const mrpt::math::TPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00114                 explicit inline _CLASS_( const mrpt::poses::CPose2D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00115                 explicit inline _CLASS_( const mrpt::poses::CPose3D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00116                 explicit inline _CLASS_( const mrpt::poses::CPose3DQuat &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00117                 explicit inline _CLASS_( const mrpt::poses::CPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00118                 explicit inline _CLASS_( const mrpt::poses::CPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); }
00119 
00120 
00121                 template <class CONTAINER1,class CONTAINER2> void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum);
00122 
00123                 template <class CONTAINER> inline typename CONTAINER::value_type norm(const CONTAINER &v);
00124                 template <class CONTAINER> inline typename CONTAINER::value_type norm_inf(const CONTAINER &v);
00125 
00126                 template <class MAT_A,class SKEW_3VECTOR,class MAT_OUT> void multiply_A_skew3(const MAT_A &A,const SKEW_3VECTOR &v, MAT_OUT &out);
00127                 template <class SKEW_3VECTOR,class MAT_A,class MAT_OUT> void multiply_skew3_A(const SKEW_3VECTOR &v,const MAT_A &A, MAT_OUT &out);
00128 
00129                 namespace detail
00130                 {
00131                         // Implemented in "lightweight_geom_data.cpp"
00132                         TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p);     //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00133                         TPoint3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint3D &p);     //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00134                         TPose2D  BASE_IMPEXP lightFromPose(const mrpt::poses::CPose2D &p);      //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00135                         TPose3D  BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3D &p);      //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00136                         TPose3DQuat BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3DQuat &p);       //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00137 
00138                         template <class MATORG, class MATDEST>
00139                         void extractMatrix(
00140                                 const MATORG &M,
00141                                 const size_t first_row,
00142                                 const size_t first_col,
00143                                 MATDEST &outMat);
00144                 }
00145 
00146                 /** Conversion of poses to MRPT containers (vector/matrix) */
00147                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint2D &p);
00148                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint3D &p);
00149                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose2D &p);
00150                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3D &p);
00151                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3DQuat &p);
00152 
00153                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint2D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00154                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint3D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00155                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose2D &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00156                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3D &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00157                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3DQuat &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00158 
00159 
00160                 // Vicinity classes ----------------------------------------------------
00161                 namespace detail        {
00162                         /**
00163                           * The purpose of this class is to model traits for containers, so that they can be used as return values for the function CMatrixTemplate::getVicinity.
00164                           * This class is NOT defined for any base container, because correctness would not be guaranteed. Instead, each class must define its own specialization
00165                           * of the template, containing two functions:
00166                           * - static void initialize(container<T>,size_t N): must reserve space to allow at least the insertion of N*N elements, in a square fashion when appliable.
00167                           * - static void insertInContainer(container<T>,size_t r,size_t c,const T &): must insert the given element in the container. Whenever it's possible, it
00168                           * must insert it in the (r,c) coordinates.
00169                           * For linear containers, the vicinity functions are guaranteed to insert elements in order, i.e., starting from the top and reading from left to right.
00170                           */
00171                         template<typename T> class VicinityTraits;
00172 
00173                         /**
00174                           * This huge template encapsulates a function to get the vicinity of an element, with maximum genericity. Although it's not meant to be called directly,
00175                           * every type defining the ASSERT_ENOUGHROOM assert and the get_unsafe method will work. The assert checks if the boundaries (r-N,r+N,c-N,c+N) fit in
00176                           * the matrix.
00177                           * The template parameters are the following:
00178                           * - MatrixType: the matrix or container base type, from which the vicinity is required.
00179                           * - T: the base type of the matrix or container.
00180                           * - ReturnType: the returning container type. The class VicinityTraits<ReturnType> must be completely defined.
00181                           * - D: the dimension of the vicinity. Current implementations are 4, 5, 8, 9, 12, 13, 20, 21, 24 and 25, although it's easy to implement new variants.
00182                           */
00183                         template<typename MatrixType,typename T,typename ReturnType,size_t D> struct getVicinity;
00184 
00185                 }
00186 
00187                 // Other forward decls:
00188                 template <class T> T wrapTo2Pi(T a);
00189 
00190 
00191         } // End of namespace
00192 } // End of namespace
00193 
00194 #endif



Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:40:17 UTC 2011