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 #ifndef CMatrixFixedNumeric_H
00029 #define CMatrixFixedNumeric_H
00030
00031 #include <mrpt/math/CArray.h>
00032 #include <mrpt/math/math_frwds.h>
00033 #include <mrpt/utils/CSerializable.h>
00034
00035 namespace mrpt
00036 {
00037 namespace math
00038 {
00039 using namespace mrpt::system;
00040 using namespace mrpt::poses;
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 template <typename T,size_t NROWS,size_t NCOLS>
00054 class CMatrixFixedNumeric :
00055 public Eigen::Matrix<
00056 T,
00057 NROWS,
00058 NCOLS,
00059
00060 Eigen::AutoAlign |
00061 ( (NCOLS==1 && NROWS!=1) ? Eigen::ColMajor : Eigen::RowMajor )
00062 >
00063 {
00064 public:
00065 typedef Eigen::Matrix<T,NROWS,NCOLS, Eigen::AutoAlign | ( (NCOLS==1 && NROWS!=1) ? Eigen::ColMajor : Eigen::RowMajor ) > Base;
00066 typedef CMatrixFixedNumeric<T,NROWS,NCOLS> mrpt_autotype;
00067
00068 MRPT_EIGEN_DERIVED_CLASS_CTOR_OPERATOR_EQUAL(CMatrixFixedNumeric)
00069 MRPT_MATRIX_CONSTRUCTORS_FROM_POSES(CMatrixFixedNumeric)
00070
00071
00072 inline CMatrixFixedNumeric() : Base() { Base::setZero(); }
00073
00074
00075 inline CMatrixFixedNumeric(const T * vals) : Base(vals) { }
00076
00077
00078
00079
00080 inline CMatrixFixedNumeric(TConstructorFlags_Matrices constructor_flag) : Base() { }
00081
00082 template<size_t N,typename ReturnType> inline ReturnType getVicinity(size_t c,size_t r) const {
00083 return detail::getVicinity<CMatrixFixedNumeric<T,NROWS,NCOLS>,T,ReturnType,N>::get(c,r,*this);
00084 }
00085
00086 inline void loadFromArray(const T* vals)
00087 {
00088 Base b(vals);
00089 *this = b;
00090 }
00091
00092
00093 template <typename Derived>
00094 inline bool operator ==(const Eigen::MatrixBase<Derived>& m2) const
00095 {
00096 return Base::cols()==m2.cols() &&
00097 Base::rows()==m2.rows() &&
00098 Base::cwiseEqual(m2).all();
00099 }
00100
00101 template <typename Derived>
00102 inline bool operator !=(const Eigen::MatrixBase<Derived>& m2) const { return !((*this)==m2); }
00103
00104
00105 };
00106
00107
00108
00109 typedef CMatrixFixedNumeric<double,2,2> CMatrixDouble22;
00110 typedef CMatrixFixedNumeric<double,2,3> CMatrixDouble23;
00111 typedef CMatrixFixedNumeric<double,3,2> CMatrixDouble32;
00112 typedef CMatrixFixedNumeric<double,3,3> CMatrixDouble33;
00113 typedef CMatrixFixedNumeric<double,4,4> CMatrixDouble44;
00114 typedef CMatrixFixedNumeric<double,6,6> CMatrixDouble66;
00115 typedef CMatrixFixedNumeric<double,7,7> CMatrixDouble77;
00116 typedef CMatrixFixedNumeric<double,1,3> CMatrixDouble13;
00117 typedef CMatrixFixedNumeric<double,3,1> CMatrixDouble31;
00118 typedef CMatrixFixedNumeric<double,1,2> CMatrixDouble12;
00119 typedef CMatrixFixedNumeric<double,2,1> CMatrixDouble21;
00120 typedef CMatrixFixedNumeric<double,6,1> CMatrixDouble61;
00121 typedef CMatrixFixedNumeric<double,1,6> CMatrixDouble16;
00122 typedef CMatrixFixedNumeric<double,7,1> CMatrixDouble71;
00123 typedef CMatrixFixedNumeric<double,1,7> CMatrixDouble17;
00124 typedef CMatrixFixedNumeric<double,5,1> CMatrixDouble51;
00125 typedef CMatrixFixedNumeric<double,1,5> CMatrixDouble15;
00126
00127 typedef CMatrixFixedNumeric<float,2,2> CMatrixFloat22;
00128 typedef CMatrixFixedNumeric<float,2,3> CMatrixFloat23;
00129 typedef CMatrixFixedNumeric<float,3,2> CMatrixFloat32;
00130 typedef CMatrixFixedNumeric<float,3,3> CMatrixFloat33;
00131 typedef CMatrixFixedNumeric<float,4,4> CMatrixFloat44;
00132 typedef CMatrixFixedNumeric<float,6,6> CMatrixFloat66;
00133 typedef CMatrixFixedNumeric<float,7,7> CMatrixFloat77;
00134 typedef CMatrixFixedNumeric<float,1,3> CMatrixFloat13;
00135 typedef CMatrixFixedNumeric<float,3,1> CMatrixFloat31;
00136 typedef CMatrixFixedNumeric<float,1,2> CMatrixFloat12;
00137 typedef CMatrixFixedNumeric<float,2,1> CMatrixFloat21;
00138 typedef CMatrixFixedNumeric<float,6,1> CMatrixFloat61;
00139 typedef CMatrixFixedNumeric<float,1,6> CMatrixFloat16;
00140 typedef CMatrixFixedNumeric<float,7,1> CMatrixFloat71;
00141 typedef CMatrixFixedNumeric<float,1,7> CMatrixFloat17;
00142 typedef CMatrixFixedNumeric<float,5,1> CMatrixFloat51;
00143 typedef CMatrixFixedNumeric<float,1,5> CMatrixFloat15;
00144
00145
00146
00147 namespace detail
00148 {
00149
00150
00151
00152 template<typename T,size_t D> class VicinityTraits<CMatrixFixedNumeric<T,D,D> > {
00153 public:
00154 inline static void initialize(CMatrixFixedNumeric<T,D,D> &mat,size_t N) {
00155 ASSERT_(N==D);
00156 }
00157 inline static void insertInContainer(CMatrixFixedNumeric<T,D,D> &mat,size_t r,size_t c,const T &t) {
00158 mat.get_unsafe(r,c)=t;
00159 }
00160 };
00161 }
00162
00163
00164 }
00165
00166 namespace utils
00167 {
00168
00169 template<typename T,size_t N,size_t M> struct TTypeName <mrpt::math::CMatrixFixedNumeric<T,N,M> > {
00170 static std::string get() { return mrpt::format("CMatrixFixedNumeric<%s,%u,%u>",TTypeName<T>::get().c_str(),(unsigned int)N,(unsigned int)M); }
00171 };
00172 }
00173
00174 }
00175
00176 #endif