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 mrpt_matrices_metaprogramming_H
00029 #define mrpt_matrices_metaprogramming_H
00030
00031 #include <mrpt/math/math_frwds.h>
00032
00033 namespace mrpt { namespace math { namespace detail
00034 {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 template <typename T,size_t NR1,size_t NC1,size_t NR2,size_t NC2>
00049 struct TMatrixProductType
00050 {
00051 typedef CMatrixFixedNumeric<T,NR1,NC2> mat_type;
00052 };
00053
00054 template <typename T>
00055 struct TMatrixProductType<T,size_t(-1),size_t(-1),size_t(-1),size_t(-1)>
00056 {
00057 typedef CMatrixTemplateNumeric<T> mat_type;
00058 };
00059
00060 template <typename T,size_t NR1,size_t NC1>
00061 struct TMatrixProductType<T,NR1,NC1,size_t(-1),size_t(-1)>
00062 {
00063 typedef CMatrixTemplateNumeric<T> mat_type;
00064 };
00065
00066 template <typename T,size_t NR2,size_t NC2>
00067 struct TMatrixProductType<T,size_t(-1),size_t(-1),NR2,NC2>
00068 {
00069 typedef CMatrixTemplateNumeric<T> mat_type;
00070 };
00071
00072
00073
00074 #define MAT_TYPE_PRODUCT_OF(MAT_1,MAT_2) \
00075 typename mrpt::math::detail::TMatrixProductType< \
00076 typename MAT_1::value_type, \
00077 MAT_1::mrpt_matrix_type_nrows, \
00078 MAT_1::mrpt_matrix_type_ncols, \
00079 MAT_2::mrpt_matrix_type_nrows, \
00080 MAT_2::mrpt_matrix_type_ncols>::mat_type
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 template <typename T,size_t NR1,size_t NC1>
00094 struct TMatrixTransposeType
00095 {
00096 typedef CMatrixFixedNumeric<T,NC1,NR1> mat_type;
00097 };
00098
00099 template <typename T>
00100 struct TMatrixTransposeType<T,size_t(-1),size_t(-1)>
00101 {
00102 typedef CMatrixTemplateNumeric<T> mat_type;
00103 };
00104
00105
00106 #define MAT_TYPE_TRANSPOSE_OF(MAT) \
00107 typename mrpt::math::detail::TMatrixTransposeType< \
00108 typename MAT::value_type, \
00109 MAT::mrpt_matrix_type_nrows, \
00110 MAT::mrpt_matrix_type_ncols>::mat_type
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 template <typename T,size_t NR1,size_t NC1>
00125 struct TMatrixCovarianceType
00126 {
00127 typedef CMatrixFixedNumeric<T,NC1,NC1> mat_type;
00128 };
00129
00130 template <typename T>
00131 struct TMatrixCovarianceType<T,size_t(-1),size_t(-1)>
00132 {
00133 typedef CMatrixTemplateNumeric<T> mat_type;
00134 };
00135
00136
00137 #define MAT_TYPE_COVARIANCE_OF(MAT) \
00138 typename mrpt::math::detail::TMatrixCovarianceType< \
00139 typename MAT::value_type, \
00140 MAT::mrpt_matrix_type_nrows, \
00141 MAT::mrpt_matrix_type_ncols>::mat_type
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 template <typename T,size_t NR1,size_t NC1>
00154 struct TMatrixSameSizeOfType
00155 {
00156 typedef CMatrixFixedNumeric<T,NR1,NC1> mat_type;
00157 };
00158
00159 template <typename T>
00160 struct TMatrixSameSizeOfType<T,size_t(-1),size_t(-1)>
00161 {
00162 typedef CMatrixTemplateNumeric<T> mat_type;
00163 };
00164
00165
00166 #define MAT_TYPE_SAMESIZE_OF(MAT) \
00167 typename mrpt::math::detail::TMatrixSameSizeOfType< \
00168 typename MAT::value_type, \
00169 MAT::mrpt_matrix_type_nrows, \
00170 MAT::mrpt_matrix_type_ncols>::mat_type
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 template <typename T,size_t NR1>
00184 struct TArrayOrVectorRowCountOfType
00185 {
00186 typedef CArrayNumeric<T,NR1> vec_type;
00187 };
00188
00189 template <typename T>
00190 struct TArrayOrVectorRowCountOfType<T,size_t(-1)>
00191 {
00192 typedef std::vector<T> vec_type;
00193 };
00194
00195
00196 #define ARRAY_TYPE_SAMESIZE_ROWS_OF(MAT) \
00197 typename mrpt::math::detail::TArrayOrVectorRowCountOfType< \
00198 typename MAT::value_type, \
00199 MAT::mrpt_matrix_type_nrows>::vec_type
00200
00201
00202
00203 }}}
00204
00205 #endif