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