MRPT  1.9.9
math_frwds.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/config.h>
12 #include <string>
13 #include <type_traits>
14 
15 /*! \file math_frwds.h
16  * Forward declarations of all mrpt::math classes related to vectors, arrays
17  * and matrices.
18  * Many of the function implementations are in ops_matrices.h, others in
19  * ops_containers.h
20  */
21 
22 namespace mrpt
23 {
24 namespace system
25 {
27 }
28 namespace math
29 {
30 struct TPoseOrPoint;
31 class CMatrix; // mrpt-binary-serializable matrix
32 class CMatrixD; // mrpt-binary-serializable matrix
33 
34 namespace detail
35 {
36 /** Internal resize which compiles to nothing on fixed-size matrices. */
37 template <typename MAT, int TypeSizeAtCompileTime>
39 {
40  static inline void internal_resize(MAT&, size_t, size_t) {}
41  static inline void internal_resize(MAT&, size_t) {}
42 };
43 template <typename MAT>
44 struct TAuxResizer<MAT, -1>
45 {
46  static inline void internal_resize(MAT& obj, size_t row, size_t col)
47  {
48  obj.derived().conservativeResize(row, col);
49  }
50  static inline void internal_resize(MAT& obj, size_t nsize)
51  {
52  obj.derived().conservativeResize(nsize);
53  }
54 };
55 } // namespace detail
56 
57 /*! Selection of the number format in CMatrixTemplate::saveToTextFile
58  */
60 {
61  /** engineering format '%e' */
63  /** fixed floating point '%f' */
65  /** intergers '%i' */
67 };
68 
69 /** For usage in one of the constructors of CMatrixFixedNumeric or
70  CMatrixTemplate (and derived classes), if it's not required
71  to fill it with zeros at the constructor to save time. */
73 {
75 };
76 
77 // ---------------- Forward declarations: Classes ----------------
78 template <class T>
79 class CMatrixTemplate;
80 template <class T>
81 class CMatrixTemplateObjects;
82 template <class T>
83 class CQuaternion;
84 
85 /** ContainerType<T>::element_t exposes the value of any STL or Eigen container.
86  * Default specialization works for STL and MRPT containers, there is another
87  * one for Eigen in <mrpt/math/eigen_frwds.h> */
88 template <typename CONTAINER>
89 struct ContainerType
90 {
91  using element_t = typename CONTAINER::value_type;
92 };
93 
94 #define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_) \
95  template < \
96  class TPOSE, typename = std::enable_if_t< \
97  std::is_base_of_v<mrpt::math::TPoseOrPoint, TPOSE>>> \
98  explicit inline _CLASS_(const TPOSE& p) \
99  { \
100  mrpt::math::containerFromPoseOrPoint(*this, p); \
101  } \
102  template <class CPOSE, int = CPOSE::is_3D_val> \
103  explicit inline _CLASS_(const CPOSE& p) \
104  { \
105  mrpt::math::containerFromPoseOrPoint(*this, p); \
106  }
107 
108 template <class CONTAINER1, class CONTAINER2>
109 void cumsum(const CONTAINER1& in_data, CONTAINER2& out_cumsum);
110 
111 template <class CONTAINER>
112 inline typename CONTAINER::Scalar norm(const CONTAINER& v);
113 template <class CONTAINER>
114 inline typename CONTAINER::Scalar norm_inf(const CONTAINER& v);
115 
116 template <class MAT_A, class SKEW_3VECTOR, class MAT_OUT>
117 void multiply_A_skew3(const MAT_A& A, const SKEW_3VECTOR& v, MAT_OUT& out);
118 template <class SKEW_3VECTOR, class MAT_A, class MAT_OUT>
119 void multiply_skew3_A(const SKEW_3VECTOR& v, const MAT_A& A, MAT_OUT& out);
120 
121 namespace detail
122 {
123 template <class MATORG, class MATDEST>
124 void extractMatrix(
125  const MATORG& M, const size_t first_row, const size_t first_col,
126  MATDEST& outMat);
127 }
128 
129 /** Conversion of poses (TPose2D,TPoint2D,...,
130  * mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vector/matrix) */
131 template <class CONTAINER, class POINT_OR_POSE>
132 CONTAINER& containerFromPoseOrPoint(CONTAINER& C, const POINT_OR_POSE& p);
133 
134 // Vicinity classes ----------------------------------------------------
135 namespace detail
136 {
137 /**
138  * The purpose of this class is to model traits for containers, so that they
139  * can be used as return values for the function CMatrixTemplate::getVicinity.
140  * This class is NOT defined for any base container, because correctness would
141  * not be guaranteed. Instead, each class must define its own specialization
142  * of the template, containing two functions:
143  * - static void initialize(container<T>,size_t N): must reserve space to allow
144  * at least the insertion of N*N elements, in a square fashion when appliable.
145  * - static void insertInContainer(container<T>,size_t r,size_t c,const T &):
146  * must insert the given element in the container. Whenever it's possible, it
147  * must insert it in the (r,c) coordinates.
148  * For linear containers, the vicinity functions are guaranteed to insert
149  * elements in order, i.e., starting from the top and reading from left to
150  * right.
151  */
152 template <typename T>
154 
155 /**
156  * This huge template encapsulates a function to get the vicinity of an
157  * element, with maximum genericity. Although it's not meant to be called
158  * directly,
159  * every type defining the get_unsafe method
160  * will work. The assert checks if the boundaries (r-N,r+N,c-N,c+N) fit in
161  * the matrix.
162  * The template parameters are the following:
163  * - MatrixType: the matrix or container base type, from which the vicinity is
164  * required.
165  * - T: the base type of the matrix or container.
166  * - ReturnType: the returning container type. The class
167  * VicinityTraits<ReturnType> must be completely defined.
168  * - D: the dimension of the vicinity. Current implementations are 4, 5, 8, 9,
169  * 12, 13, 20, 21, 24 and 25, although it's easy to implement new variants.
170  */
171 template <typename MatrixType, typename T, typename ReturnType, size_t D>
172 struct getVicinity;
173 } // namespace detail
174 
175 // Other forward decls:
176 template <class T>
177 T wrapTo2Pi(T a);
178 
179 } // namespace math
180 } // namespace mrpt
double Scalar
Definition: KmUtils.h:43
TConstructorFlags_Matrices
For usage in one of the constructors of CMatrixFixedNumeric or CMatrixTemplate (and derived classes)...
Definition: math_frwds.h:72
engineering format &#39;e&#39;
Definition: math_frwds.h:62
static void internal_resize(MAT &, size_t)
Definition: math_frwds.h:41
void multiply_A_skew3(const MAT_A &A, const SKEW_3VECTOR &v, MAT_OUT &out)
Only for vectors/arrays "v" of length3, compute out = A * Skew(v), where Skew(v) is the skew symmetri...
Definition: ops_matrices.h:167
GLsizei GLsizei GLuint * obj
Definition: glext.h:4085
CONTAINER & containerFromPoseOrPoint(CONTAINER &C, const POINT_OR_POSE &p)
Conversion of poses (TPose2D,TPoint2D,..., mrpt::poses::CPoint2D,CPose3D,...) to MRPT containers (vec...
void extractMatrix(const MATORG &M, const size_t first_row, const size_t first_col, MATDEST &outMat)
Extract a submatrix - The output matrix must be set to the required size before call.
Definition: ops_matrices.h:216
The purpose of this class is to model traits for containers, so that they can be used as return value...
Definition: math_frwds.h:153
T wrapTo2Pi(T a)
Modifies the given angle to translate it into the [0,2pi[ range.
Definition: wrap2pi.h:38
static void internal_resize(MAT &obj, size_t row, size_t col)
Definition: math_frwds.h:46
TMatrixTextFileFormat
Definition: math_frwds.h:59
GLsizei const GLchar ** string
Definition: glext.h:4116
static void internal_resize(MAT &obj, size_t nsize)
Definition: math_frwds.h:50
static void internal_resize(MAT &, size_t, size_t)
Definition: math_frwds.h:40
void cumsum(const CONTAINER1 &in_data, CONTAINER2 &out_cumsum)
intergers &#39;i&#39;
Definition: math_frwds.h:66
CONTAINER::Scalar norm_inf(const CONTAINER &v)
Internal resize which compiles to nothing on fixed-size matrices.
Definition: math_frwds.h:38
const GLdouble * v
Definition: glext.h:3684
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
typename CONTAINER::value_type element_t
Definition: math_frwds.h:91
GLenum GLenum GLvoid * row
Definition: glext.h:3580
This huge template encapsulates a function to get the vicinity of an element, with maximum genericity...
Definition: math_frwds.h:172
void multiply_skew3_A(const SKEW_3VECTOR &v, const MAT_A &A, MAT_OUT &out)
Only for vectors/arrays "v" of length3, compute out = Skew(v) * A, where Skew(v) is the skew symmetri...
Definition: ops_matrices.h:191
std::string MRPT_getVersion()
Returns a string describing the MRPT version.
Definition: os.cpp:187
GLubyte GLubyte GLubyte a
Definition: glext.h:6372
GLfloat GLfloat p
Definition: glext.h:6398
fixed floating point &#39;f&#39;
Definition: math_frwds.h:64
CONTAINER::Scalar norm(const CONTAINER &v)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: bef67d9c5 Mon Apr 15 00:03:11 2019 +0200 at lun abr 15 00:10:13 CEST 2019