Main MRPT website > C++ reference for MRPT 1.9.9
types_math.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 
10 #pragma once
11 
12 #include <vector> // For <Eigen/StdVector>
13 #include <deque> // For <Eigen/StdDeque>
14 
15 // needed here for a few basic types used in Eigen MRPT's plugin:
16 #include <mrpt/math/math_frwds.h>
18 // --------------------------------------------------
19 // Include the Eigen3 library headers, including
20 // MRPT's extensions:
21 // --------------------------------------------------
22 #include <fstream> // These headers are assumed by <mrpt/math/eigen_plugins.h>:
23 #include <ctime>
24 #include <stdexcept>
25 #ifdef EIGEN_MATRIXBASE_H
26 # error **FATAL ERROR**: MRPT headers must be included before <Eigen/Dense> headers.
27 #endif
28 #ifndef EIGEN_USE_NEW_STDVECTOR
29 #define EIGEN_USE_NEW_STDVECTOR
30 #endif
31 #include <Eigen/Dense>
32 #include <Eigen/StdVector>
33 #include <Eigen/StdDeque>
34 
35 #if !EIGEN_VERSION_AT_LEAST(2, 90, 0)
36 #error MRPT needs version 3.0.0-beta of Eigen or newer
37 #endif
38 
39 // Template implementations that need to be after all Eigen includes:
40 #include EIGEN_MATRIXBASE_PLUGIN_POST_IMPL
41 // --------------------------------------------------
42 // End of Eigen includes
43 // --------------------------------------------------
44 
45 // This must be put inside any MRPT class that inherits from an Eigen class:
46 #define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_) \
47  /*! Assignment operator from any other Eigen class */ \
48  template <typename OtherDerived> \
49  inline mrpt_autotype& operator=( \
50  const Eigen::MatrixBase<OtherDerived>& other) \
51  { \
52  Base::operator=(other); \
53  return *this; \
54  } \
55  /*! Constructor from any other Eigen class */ \
56  template <typename OtherDerived> \
57  inline _CLASS_(const Eigen::MatrixBase<OtherDerived>& other) \
58  : Base(other.template cast<typename Base::Scalar>()) \
59  { \
60  }
61 
62 namespace mrpt
63 {
64 namespace math
65 {
66 /** Column vector, like Eigen::MatrixX*, but automatically initialized to zeros
67  * since construction */
68 template <typename T>
69 class dynamic_vector : public Eigen::Matrix<T, Eigen::Dynamic, 1>
70 {
71  public:
72  using Base = Eigen::Matrix<T, Eigen::Dynamic, 1>;
74  using value_type = T;
76 
77  /** Default constructor (vector of given size set to zero) */
78  inline dynamic_vector(size_t length = 0) { Base::setZero(length); }
79  /** Constructor to given size and all entries to some value */
80  inline dynamic_vector(size_t length, float value)
81  {
82  Base::resize(length);
83  Base::setConstant(value);
84  }
85 };
86 
87 /** Column vector, like Eigen::MatrixXf, but automatically initialized to zeros
88  * since construction */
89 using CVectorFloat = dynamic_vector<float>;
90 /** Column vector, like Eigen::MatrixXd, but automatically initialized to zeros
91  * since construction */
92 using CVectorDouble = dynamic_vector<double>;
93 
102 }
103 }
mrpt::math::operator<<
std::ostream & operator<<(std::ostream &o, const TPoint2D &p)
Definition: lightweight_geom_data.cpp:439
s
GLdouble s
Definition: glext.h:3676
mrpt::math::dynamic_vector
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:44
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::math::CVectorDouble
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:46
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
length
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
mrpt::math::operator>>
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)
mrpt::math::dynamic_vector::dynamic_vector
dynamic_vector(size_t length, float value)
Constructor to given size and all entries to some value.
Definition: types_math.h:80
mrpt::math::dynamic_vector::value_type
T value_type
Definition: types_math.h:74
math_frwds.h
MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL
#define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_)
Definition: types_math.h:46
serialization_frwds.h
value
GLsizei const GLfloat * value
Definition: glext.h:4117
in
GLuint in
Definition: glext.h:7274
mrpt::math::CVectorFloat
dynamic_vector< float > CVectorFloat
Column vector, like Eigen::MatrixXf, but automatically initialized to zeros since construction.
Definition: eigen_frwds.h:45
mrpt::math::dynamic_vector::Base
Eigen::Matrix< T, Eigen::Dynamic, 1 > Base
Definition: types_math.h:72
a
GLubyte GLubyte GLubyte a
Definition: glext.h:6279



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