MRPT  2.0.1
eigen_extensions.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-2020, 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 
10 #pragma once
11 
12 #include <mrpt/math/math_frwds.h>
13 #include <algorithm>
14 
15 /* Utility functions to ease the use of Eigen matrices */
16 
17 namespace mrpt::math
18 {
19 namespace detail
20 {
21 /** Internal resize which compiles to nothing on fixed-size matrices. */
22 template <typename MAT, int TypeSizeAtCompileTime>
24 {
25  static inline void internal_resize(MAT&, size_t, size_t) {}
26  static inline void internal_resize(MAT&, size_t) {}
27 };
28 template <typename MAT>
29 struct TAuxResizer<MAT, -1>
30 {
31  static inline void internal_resize(MAT& obj, size_t row, size_t col)
32  {
33  obj.derived().conservativeResize(row, col);
34  }
35  static inline void internal_resize(MAT& obj, size_t nsize)
36  {
37  obj.derived().conservativeResize(nsize);
38  }
39 };
40 
41 // Generic version for all kind of matrices:
42 template <int R, int C>
44 {
45  template <typename MAT>
46  static inline void doit(MAT& mat, size_t new_rows, size_t new_cols)
47  {
49  internal_resize(mat, new_rows, new_cols);
50  }
51 };
52 // Specialization for column matrices:
53 template <int R>
54 struct MatOrVecResizer<R, 1>
55 {
56  template <typename MAT>
57  static inline void doit(MAT& mat, size_t new_rows, size_t)
58  {
60  MAT, MAT::SizeAtCompileTime>::internal_resize(mat, new_rows);
61  }
62 };
63 // Specialization for row matrices:
64 template <int C>
65 struct MatOrVecResizer<1, C>
66 {
67  template <typename MAT>
68  static inline void doit(MAT& mat, size_t, size_t new_cols)
69  {
71  MAT, MAT::SizeAtCompileTime>::internal_resize(mat, new_cols);
72  }
73 };
74 template <>
75 struct MatOrVecResizer<1, 1>
76 {
77  template <typename MAT>
78  static inline void doit(MAT& mat, size_t, size_t new_cols)
79  {
81  MAT, MAT::SizeAtCompileTime>::internal_resize(mat, new_cols);
82  }
83 };
84 } // namespace detail
85 
86 } // namespace mrpt::math
static void internal_resize(MAT &, size_t)
static void doit(MAT &mat, size_t, size_t new_cols)
This base provides a set of functions for maths stuff.
static void doit(MAT &mat, size_t new_rows, size_t)
static void internal_resize(MAT &obj, size_t row, size_t col)
static void internal_resize(MAT &obj, size_t nsize)
static void internal_resize(MAT &, size_t, size_t)
static void doit(MAT &mat, size_t new_rows, size_t new_cols)
Internal resize which compiles to nothing on fixed-size matrices.
static void doit(MAT &mat, size_t, size_t new_cols)
const float R



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020