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-2017, 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>
17 
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  typedef Eigen::Matrix<T, Eigen::Dynamic, 1> Base;
74  typedef T value_type;
77 
78  /** Default constructor (vector of given size set to zero) */
79  inline dynamic_vector(size_t length = 0) { Base::setZero(length); }
80  /** Constructor to given size and all entries to some value */
81  inline dynamic_vector(size_t length, float value)
82  {
83  Base::resize(length);
84  Base::setConstant(value);
85  }
86 };
87 
88 /** Column vector, like Eigen::MatrixXf, but automatically initialized to zeros
89  * since construction */
90 typedef dynamic_vector<float> CVectorFloat;
91 /** Column vector, like Eigen::MatrixXd, but automatically initialized to zeros
92  * since construction */
93 typedef dynamic_vector<double> CVectorDouble;
94 }
95 
96 namespace utils
97 {
98 class CStream;
99 
101 CStream& operator<<(
105 }
106 }
#define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_)
Definition: types_math.h:46
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
GLdouble s
Definition: glext.h:3676
dynamic_vector< float > CVectorFloat
Column vector, like Eigen::MatrixXf, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:42
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
dynamic_vector(size_t length, float value)
Constructor to given size and all entries to some value.
Definition: types_math.h:81
#define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_)
Definition: math_frwds.h:106
CStream & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:123
dynamic_vector< T > mrpt_autotype
Definition: types_math.h:73
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Eigen::Matrix< T, Eigen::Dynamic, 1 > Base
Definition: types_math.h:72
GLuint GLsizei GLsizei * length
Definition: glext.h:4064
GLuint in
Definition: glext.h:7274
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:44
GLsizei const GLfloat * value
Definition: glext.h:4117
CStream & operator>>(mrpt::utils::CStream &in, char *a)
Definition: CStream.cpp:407
GLubyte GLubyte GLubyte a
Definition: glext.h:6279



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019