Main MRPT website > C++ reference for MRPT 1.9.9
CArrayNumeric.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10
11 #include <mrpt/math/types_math.h> // Eigen
14 #include <mrpt/math/point_poses2vectors.h> // MRPT_MATRIX_CONSTRUCTORS_FROM_POSES()
15
16 namespace mrpt
17 {
18 namespace math
19 {
20 /** CArrayNumeric is an array for numeric types supporting several mathematical
21  * operations (actually, just a wrapper on Eigen::Matrix<T,N,1>)
22  * \sa CArrayFloat, CArrayDouble, CArray
23  */
24 template <typename T, std::size_t N>
25 class CArrayNumeric : public Eigen::Matrix<T, N, 1>
26 {
27  public:
28  using value_type = T;
29  using Base = Eigen::Matrix<T, N, 1>;
30
31  /** Default constructor */
33  /** Constructor from initial values ptr[0]-ptr[N-1] */
34  CArrayNumeric(const T* ptr) : Eigen::Matrix<T, N, 1>(ptr) {}
35  /** Initialization from a vector-like source, that is, anything implementing
36  * operator[]. */
37  template <class Derived>
39  : Eigen::Matrix<T, N, 1>(obj)
40  {
41  }
42
44
45  template <typename OtherDerived>
48  {
49  Base::operator=(other);
50  return *this;
51  }
52 };
53
54 // -------------- Partial specializations of CArrayNumeric -----------
55
56 /** A partial specialization of CArrayNumeric for float numbers.
57 * \sa CArrayNumeric, CArray */
58 template <std::size_t N>
60
61 /** A partial specialization of CArrayNumeric for double numbers.
62  * \sa CArrayNumeric, CArray */
63 template <std::size_t N>
65
66 /** A partial specialization of CArrayNumeric for int numbers.
67  * \sa CArrayNumeric, CArray */
68 template <std::size_t N>
70
71 /** A partial specialization of CArrayNumeric for unsigned int numbers.
72  * \sa CArrayNumeric, CArray */
73 template <std::size_t N>
75 }
76
77 namespace typemeta
78 {
79 // Extensions to mrpt::typemeta::TTypeName for matrices:
80 template <typename T, size_t N>
82 {
83  constexpr static auto get()
84  {
85  return literal("CArrayNumeric<") + TTypeName<T>::get() + literal(",") +
87  }
88 };
89 template <size_t N>
91 {
92  constexpr static auto get()
93  {
94  return literal("CArrayDouble<") + literal(num_to_string<N>::value) +
95  literal(">");
96  }
97 };
98 template <size_t N>
100 {
101  constexpr static auto get()
102  {
103  return literal("CArrayFloat<") + literal(num_to_string<N>::value) +
104  literal(">");
105  }
106 };
107 }
108 } // End of namespace
CArrayNumeric()
Default constructor.
Definition: CArrayNumeric.h:32
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually...
Definition: CArrayNumeric.h:25
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
A template to obtain the type of its argument as a string at compile time.
Definition: TTypeName.h:65
constexpr auto literal(const char(&lit)[N_PLUS_1]) -> string_literal< N_PLUS_1 - 1 >
Definition: static_string.h:43
#define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_)
Definition: math_frwds.h:95
CArrayNumeric< T, N > & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: CArrayNumeric.h:46
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
CArrayNumeric(const T *ptr)
Constructor from initial values ptr[0]-ptr[N-1].
Definition: CArrayNumeric.h:34
CArrayNumeric(const Eigen::MatrixBase< Derived > &obj)
Initialization from a vector-like source, that is, anything implementing operator[].
Definition: CArrayNumeric.h:38
Eigen::Matrix< T, N, 1 > Base
Definition: CArrayNumeric.h:29
constexpr string representation of a number.
Definition: num_to_string.h:44
static constexpr auto get()
Definition: TTypeName.h:67

 Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019