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 |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
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
Eigen
Definition: eigen_frwds.h:15
mrpt::math::CArrayNumeric< T, 4 >::Base
Eigen::Matrix< T, N, 1 > Base
Definition: CArrayNumeric.h:29
mrpt::math::CArrayNumeric< T, 4 >::value_type
T value_type
Definition: CArrayNumeric.h:28
point_poses2vectors.h
mrpt::math::CArrayNumeric::operator=
CArrayNumeric< T, N > & operator=(const Eigen::MatrixBase< OtherDerived > &other)
Definition: CArrayNumeric.h:46
num_to_string.h
mrpt::math::CArrayNumeric::CArrayNumeric
CArrayNumeric(const T *ptr)
Constructor from initial values ptr[0]-ptr[N-1].
Definition: CArrayNumeric.h:34
obj
GLsizei GLsizei GLuint * obj
Definition: glext.h:4070
mrpt::typemeta::TTypeName
A template to obtain the type of its argument as a string at compile time.
Definition: TTypeName.h:65
mrpt::typemeta::TTypeName< mrpt::math::CArrayNumeric< T, N > >::get
constexpr static auto get()
Definition: CArrayNumeric.h:83
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::typemeta::num_to_string
constexpr string representation of a number.
Definition: num_to_string.h:44
TTypeName.h
mrpt::math::CArrayNumeric::CArrayNumeric
CArrayNumeric(const Eigen::MatrixBase< Derived > &obj)
Initialization from a vector-like source, that is, anything implementing operator[].
Definition: CArrayNumeric.h:38
mrpt::math::CArrayNumeric
CArrayNumeric is an array for numeric types supporting several mathematical operations (actually,...
Definition: CArrayNumeric.h:25
mrpt::typemeta::TTypeName::get
constexpr static auto get()
Definition: TTypeName.h:67
mrpt::typemeta::TTypeName< mrpt::math::CArrayFloat< N > >::get
constexpr static auto get()
Definition: CArrayNumeric.h:101
mrpt::math::CArrayNumeric::CArrayNumeric
CArrayNumeric()
Default constructor.
Definition: CArrayNumeric.h:32
MRPT_MATRIX_CONSTRUCTORS_FROM_POSES
#define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_)
Definition: math_frwds.h:95
Eigen::MatrixBase
Definition: eigen_frwds.h:20
mrpt::typemeta::literal
constexpr auto literal(const char(&lit)[N_PLUS_1]) -> string_literal< N_PLUS_1 - 1 >
Definition: static_string.h:43
types_math.h
mrpt::typemeta::TTypeName< mrpt::math::CArrayDouble< N > >::get
constexpr static auto get()
Definition: CArrayNumeric.h:92



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST