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://www.mrpt.org/                                |
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 #include <string>
00037 
00038 /*! \file math_frwds.h
00039   * Forward declarations of all mrpt::math classes related to vectors, arrays and matrices.
00040   * Many of the function implementations are in ops_matrices.h, others in ops_containers.h
00041   */
00042 
00043 namespace mrpt
00044 {
00045         namespace utils
00046         {
00047                 class BASE_IMPEXP CStream;
00048                 template<class T> inline T square(const T x);
00049         }
00050 
00051         namespace system
00052         {
00053                 std::string BASE_IMPEXP MRPT_getVersion();
00054         }
00055 
00056         namespace poses
00057         {
00058                 class CPoint2D;
00059                 class CPoint3D;
00060                 class CPose2D;
00061                 class CPose3D;
00062                 class CPose3DQuat;
00063         }
00064 
00065         namespace math
00066         {
00067                 struct TPoint2D;
00068                 struct TPoint3D;
00069                 struct TPose2D;
00070                 struct TPose3D;
00071                 struct TPose3DQuat;
00072 
00073                 namespace detail
00074                 {
00075                         /** Internal resize which compiles to nothing on fixed-size matrices. */
00076                         template <typename MAT,int TypeSizeAtCompileTime>
00077                         struct TAuxResizer {
00078                                 static inline void internal_resize(MAT &obj, size_t row, size_t col) { }
00079                                 static inline void internal_resize(MAT &obj, size_t nsize) { }
00080                         };
00081                         template <typename MAT>
00082                         struct TAuxResizer<MAT,-1> {
00083                                 static inline void internal_resize(MAT &obj, size_t row, size_t col) { obj.derived().conservativeResize(row,col); }
00084                                 static inline void internal_resize(MAT &obj, size_t nsize) { obj.derived().conservativeResize(nsize); }
00085                         };
00086                 }
00087 
00088 
00089                 /*! Selection of the number format in CMatrixTemplate::saveToTextFile
00090                   */
00091                 enum TMatrixTextFileFormat
00092                 {
00093                         MATRIX_FORMAT_ENG = 0,   //!< engineering format '%e'
00094                         MATRIX_FORMAT_FIXED = 1, //!< fixed floating point '%f'
00095                         MATRIX_FORMAT_INT = 2    //!< intergers '%i'
00096                 };
00097 
00098                 /** For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes), if it's not required
00099                      to fill it with zeros at the constructor to save time. */
00100                 enum TConstructorFlags_Matrices
00101                 {
00102                         UNINITIALIZED_MATRIX = 0
00103                 };
00104 
00105                 // ---------------- Forward declarations: Classes ----------------
00106                 template <class T> class CMatrixTemplate;
00107                 template <class T> class CMatrixTemplateObjects;
00108 
00109 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
00110                 explicit inline _CLASS_( const mrpt::math::TPose2D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00111                 explicit inline _CLASS_( const mrpt::math::TPose3D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00112                 explicit inline _CLASS_( const mrpt::math::TPose3DQuat &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00113                 explicit inline _CLASS_( const mrpt::math::TPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00114                 explicit inline _CLASS_( const mrpt::math::TPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00115                 explicit inline _CLASS_( const mrpt::poses::CPose2D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00116                 explicit inline _CLASS_( const mrpt::poses::CPose3D &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00117                 explicit inline _CLASS_( const mrpt::poses::CPose3DQuat &p)  { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00118                 explicit inline _CLASS_( const mrpt::poses::CPoint2D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); } \
00119                 explicit inline _CLASS_( const mrpt::poses::CPoint3D &p) { mrpt::math::containerFromPoseOrPoint(*this,p); }
00120 
00121 
00122                 template <class CONTAINER1,class CONTAINER2> void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum);
00123 
00124                 template <class CONTAINER> inline typename CONTAINER::value_type norm(const CONTAINER &v);
00125                 template <class CONTAINER> inline typename CONTAINER::value_type norm_inf(const CONTAINER &v);
00126 
00127                 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);
00128                 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);
00129 
00130                 namespace detail
00131                 {
00132                         // Implemented in "lightweight_geom_data.cpp"
00133                         TPoint2D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint2D &p);     //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00134                         TPoint3D BASE_IMPEXP lightFromPose(const mrpt::poses::CPoint3D &p);     //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00135                         TPose2D  BASE_IMPEXP lightFromPose(const mrpt::poses::CPose2D &p);      //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00136                         TPose3D  BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3D &p);      //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00137                         TPose3DQuat BASE_IMPEXP lightFromPose(const mrpt::poses::CPose3DQuat &p);       //!< Convert a pose into a light-weight structure (functional form, needed for forward declarations)
00138 
00139                         template <class MATORG, class MATDEST>
00140                         void extractMatrix(
00141                                 const MATORG &M,
00142                                 const size_t first_row,
00143                                 const size_t first_col,
00144                                 MATDEST &outMat);
00145                 }
00146 
00147                 /** Conversion of poses to MRPT containers (vector/matrix) */
00148                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint2D &p);
00149                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPoint3D &p);
00150                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose2D &p);
00151                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3D &p);
00152                 template <class CONTAINER> CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const TPose3DQuat &p);
00153 
00154                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint2D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00155                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPoint3D &p) { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00156                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose2D &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00157                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3D &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00158                 template <class CONTAINER> inline CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const mrpt::poses::CPose3DQuat &p)  { return containerFromPoseOrPoint(C, mrpt::math::detail::lightFromPose(p)); }
00159 
00160 
00161                 // Vicinity classes ----------------------------------------------------
00162                 namespace detail        {
00163                         /**
00164                           * 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.
00165                           * This class is NOT defined for any base container, because correctness would not be guaranteed. Instead, each class must define its own specialization
00166                           * of the template, containing two functions:
00167                           * - 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.
00168                           * - 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
00169                           * must insert it in the (r,c) coordinates.
00170                           * 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.
00171                           */
00172                         template<typename T> class VicinityTraits;
00173 
00174                         /**
00175                           * 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,
00176                           * 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
00177                           * the matrix.
00178                           * The template parameters are the following:
00179                           * - MatrixType: the matrix or container base type, from which the vicinity is required.
00180                           * - T: the base type of the matrix or container.
00181                           * - ReturnType: the returning container type. The class VicinityTraits<ReturnType> must be completely defined.
00182                           * - 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.
00183                           */
00184                         template<typename MatrixType,typename T,typename ReturnType,size_t D> struct getVicinity;
00185 
00186                 }
00187 
00188                 // Other forward decls:
00189                 template <class T> T wrapTo2Pi(T a);
00190 
00191 
00192         } // End of namespace
00193 } // End of namespace
00194 
00195 #endif



Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011