Main MRPT website > C++ reference for MRPT 1.5.6
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 
46 // This must be put inside any MRPT class that inherits from an Eigen class:
47 #define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_) \
48  /*! Assignment operator from any other Eigen class */ \
49  template<typename OtherDerived> \
50  inline mrpt_autotype & operator= (const Eigen::MatrixBase <OtherDerived>& other) { \
51  Base::operator=(other); \
52  return *this; \
53  } \
54  /*! Constructor from any other Eigen class */ \
55  template<typename OtherDerived> \
56  inline _CLASS_(const Eigen::MatrixBase <OtherDerived>& other) : Base(other.template cast<typename Base::Scalar>()) { } \
57 
58 namespace mrpt
59 {
60  namespace math
61  {
62  /** Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction */
63  template <typename T>
64  class dynamic_vector : public Eigen::Matrix<T,Eigen::Dynamic,1>
65  {
66  public:
67  typedef Eigen::Matrix<T,Eigen::Dynamic,1> Base;
69  typedef T value_type;
72 
73  /** Default constructor (vector of given size set to zero) */
74  inline dynamic_vector(size_t length=0) { Base::setZero(length); }
75  /** Constructor to given size and all entries to some value */
76  inline dynamic_vector(size_t length, float value) { Base::resize(length); Base::setConstant(value); }
77 
78  };
79 
80  typedef dynamic_vector<float> CVectorFloat; //!< Column vector, like Eigen::MatrixXf, but automatically initialized to zeros since construction
81  typedef dynamic_vector<double> CVectorDouble; //!< Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction
82  }
83 
84  namespace utils
85  {
86  class CStream;
87 
92  }
93 }
Eigen::Matrix< T, Eigen::Dynamic, 1 > Base
Definition: types_math.h:67
#define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_)
Definition: types_math.h:47
Column vector, like Eigen::MatrixX*, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:35
GLdouble s
Definition: glext.h:3602
dynamic_vector< float > CVectorFloat
Column vector, like Eigen::MatrixXf, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:35
::mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, CImagePtr &pObj)
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
dynamic_vector(size_t length, float value)
Constructor to given size and all entries to some value.
Definition: types_math.h:76
#define MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(_CLASS_)
Definition: math_frwds.h:88
CStream BASE_IMPEXP & operator<<(mrpt::utils::CStream &s, const char *a)
Definition: CStream.cpp:130
dynamic_vector< T > mrpt_autotype
Definition: types_math.h:68
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLuint GLsizei GLsizei * length
Definition: glext.h:3900
GLuint in
Definition: glext.h:6301
dynamic_vector< double > CVectorDouble
Column vector, like Eigen::MatrixXd, but automatically initialized to zeros since construction...
Definition: eigen_frwds.h:37
GLsizei const GLfloat * value
Definition: glext.h:3929
GLubyte GLubyte GLubyte a
Definition: glext.h:5575



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019