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::math
63 {
64 /** Column vector, like Eigen::MatrixX*, but automatically initialized to zeros
65  * since construction */
66 template <typename T>
67 class dynamic_vector : public Eigen::Matrix<T, Eigen::Dynamic, 1>
68 {
69  public:
70  using Base = Eigen::Matrix<T, Eigen::Dynamic, 1>;
72  using value_type = T;
74 
75  /** Default constructor (vector of given size set to zero) */
76  inline dynamic_vector(size_t length = 0) { Base::setZero(length); }
77  /** Constructor to given size and all entries to some value */
78  inline dynamic_vector(size_t length, float value)
79  {
80  Base::resize(length);
81  Base::setConstant(value);
82  }
83 };
84 
85 /** Column vector, like Eigen::MatrixXf, but automatically initialized to zeros
86  * since construction */
87 using CVectorFloat = dynamic_vector<float>;
88 /** Column vector, like Eigen::MatrixXd, but automatically initialized to zeros
89  * since construction */
90 using CVectorDouble = dynamic_vector<double>;
91 
100 }
101 
#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:44
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:45
This base provides a set of functions for maths stuff.
dynamic_vector(size_t length, float value)
Constructor to given size and all entries to some value.
Definition: types_math.h:78
std::ostream & operator<<(std::ostream &o, const TPoint2D &p)
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
Eigen::Matrix< T, Eigen::Dynamic, 1 > Base
Definition: types_math.h:70
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:46
GLsizei const GLfloat * value
Definition: glext.h:4117
GLubyte GLubyte GLubyte a
Definition: glext.h:6279
mrpt::serialization::CArchive & operator>>(mrpt::serialization::CArchive &in, CMatrix::Ptr &pObj)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020