Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef mrpt_utils_types_H
00030 #define mrpt_utils_types_H
00031
00032 #include <vector>
00033 #include <map>
00034 #include <string>
00035 #include <stdexcept>
00036 #include <cstdarg>
00037 #include <ctime>
00038
00039 #include <mrpt/utils/mrpt_stdint.h>
00040 #include <mrpt/utils/mrpt_inttypes.h>
00041
00042
00043 #include <mrpt/math/math_frwds.h>
00044
00045
00046
00047
00048
00049 #include <iostream>
00050 #include <fstream>
00051 #include <sstream>
00052 #ifdef EIGEN_MAJOR_VERSION
00053 # error **FATAL ERROR**: MRPT headers must be included before Eigen headers.
00054 #endif
00055 #ifndef EIGEN_USE_NEW_STDVECTOR
00056 # define EIGEN_USE_NEW_STDVECTOR
00057 #endif
00058 #include <Eigen/Dense>
00059 #include <Eigen/StdVector>
00060 #include <Eigen/StdDeque>
00061
00062 #if !EIGEN_VERSION_AT_LEAST(2,90,0)
00063 #error MRPT needs version 3.0.0-beta of Eigen or newer
00064 #endif
00065
00066
00067 #include EIGEN_MATRIXBASE_PLUGIN_POST_IMPL
00068
00069
00070
00071
00072
00073
00074 #define MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(_CLASS_) \
00075 \
00076 template<typename OtherDerived> \
00077 inline mrpt_autotype & operator= (const Eigen::MatrixBase <OtherDerived>& other) { \
00078 \
00079 Base::operator=(other); \
00080 return *this; \
00081 } \
00082 \
00083 template<typename OtherDerived> \
00084 inline _CLASS_(const Eigen::MatrixBase <OtherDerived>& other) : Base(other.template cast<typename Base::Scalar>()) { } \
00085
00086 namespace mrpt
00087 {
00088
00089
00090
00091
00092 template <typename T>
00093 struct dynamicsize_vector : public Eigen::Matrix<T,Eigen::Dynamic,1>
00094 {
00095 typedef Eigen::Matrix<T,Eigen::Dynamic,1> Base;
00096 typedef dynamicsize_vector<T> mrpt_autotype;
00097 MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(dynamicsize_vector)
00098
00099
00100 inline dynamicsize_vector() : Base() {}
00101
00102 inline dynamicsize_vector(size_t N) : Base(N,1) { Base::derived().setZero(); }
00103
00104 inline dynamicsize_vector(size_t N, T init_val) : Base(N,1) { Base::derived().assign(init_val); }
00105
00106 template <typename R>
00107 inline dynamicsize_vector(const std::vector<R>& v) : Base(v.size(),1) { for (size_t i=0;i<v.size();i++) (*this)[i]=v[i]; }
00108
00109 inline void resize(const size_t N, const T default_val) { Base::derived().resize(N,1); Base::derived().setConstant(default_val); }
00110
00111 inline void resize(const size_t N) { Base::derived().conservativeResize(N); }
00112
00113 inline void clear() { *this = dynamicsize_vector<T>(); }
00114
00115 inline void reserve(size_t dummy_size) { }
00116 };
00117
00118 typedef dynamicsize_vector<float> vector_float;
00119 typedef dynamicsize_vector<double> vector_double;
00120
00121 typedef std::vector<int8_t> vector_signed_byte;
00122 typedef std::vector<int16_t> vector_signed_word;
00123 typedef std::vector<int32_t> vector_int;
00124 typedef std::vector<int64_t> vector_long;
00125 typedef std::vector<size_t> vector_size_t;
00126 typedef std::vector<uint8_t> vector_byte;
00127 typedef std::vector<uint16_t> vector_word;
00128 typedef std::vector<uint32_t> vector_uint;
00129 typedef std::vector<bool> vector_bool;
00130 typedef std::vector<std::string> vector_string;
00131
00132
00133 template <class TYPE1,class TYPE2=TYPE1>
00134 struct aligned_containers
00135 {
00136 typedef std::pair<TYPE1,TYPE2> pair_t;
00137 typedef std::vector<TYPE1, Eigen::aligned_allocator<TYPE1> > vector_t;
00138 typedef std::deque<TYPE1, Eigen::aligned_allocator<TYPE1> > deque_t;
00139 typedef std::map<TYPE1,TYPE2,std::less<TYPE1>,Eigen::aligned_allocator<std::pair<const TYPE1,TYPE2> > > map_t;
00140 typedef std::multimap<TYPE1,TYPE2,std::less<TYPE1>,Eigen::aligned_allocator<std::pair<const TYPE1,TYPE2> > > multimap_t;
00141 };
00142
00143 namespace utils
00144 {
00145
00146
00147 #if defined(_MSC_VER) && (_MSC_VER>=1300)
00148 typedef unsigned long long POINTER_TYPE;
00149 #else
00150 typedef unsigned long POINTER_TYPE;
00151 #endif
00152
00153 typedef uint64_t TNodeID;
00154 typedef std::pair<TNodeID,TNodeID> TPairNodeIDs;
00155 #define INVALID_NODEID static_cast<TNodeID>(-1)
00156
00157 }
00158 }
00159
00160 #endif
00161