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
00075 #define MAT_TYPEDECL_PRODUCT_OF(MAT_1,MAT_2) \
00076 mrpt::math::detail::TMatrixProductType< \
00077 MAT_1::value_type, \
00078 MAT_1::mrpt_matrix_type_nrows, \
00079 MAT_1::mrpt_matrix_type_ncols, \
00080 MAT_2::mrpt_matrix_type_nrows, \
00081 MAT_2::mrpt_matrix_type_ncols>::mat_type
00082
00083
00084 #define MAT_TYPE_PRODUCT_OF(MAT_1,MAT_2) \
00085 typename mrpt::math::detail::TMatrixProductType< \
00086 typename MAT_1::value_type, \
00087 MAT_1::mrpt_matrix_type_nrows, \
00088 MAT_1::mrpt_matrix_type_ncols, \
00089 MAT_2::mrpt_matrix_type_nrows, \
00090 MAT_2::mrpt_matrix_type_ncols>::mat_type
00091
00092
00093
00094
00095 #define MAT_TYPEDECL_PRODUCT_AtB_OF(MAT_1,MAT_2) \
00096 mrpt::math::detail::TMatrixProductType< \
00097 MAT_1::value_type, \
00098 MAT_1::mrpt_matrix_type_ncols, \
00099 MAT_1::mrpt_matrix_type_nrows, \
00100 MAT_2::mrpt_matrix_type_nrows, \
00101 MAT_2::mrpt_matrix_type_ncols>::mat_type
00102
00103
00104 #define MAT_TYPE_PRODUCT_AtB_OF(MAT_1,MAT_2) \
00105 typename mrpt::math::detail::TMatrixProductType< \
00106 typename MAT_1::value_type, \
00107 MAT_1::mrpt_matrix_type_ncols, \
00108 MAT_1::mrpt_matrix_type_nrows, \
00109 MAT_2::mrpt_matrix_type_nrows, \
00110 MAT_2::mrpt_matrix_type_ncols>::mat_type
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 template <typename T,size_t NR1,size_t NC1>
00124 struct TMatrixTransposeType
00125 {
00126 typedef CMatrixFixedNumeric<T,NC1,NR1> mat_type;
00127 };
00128
00129 template <typename T>
00130 struct TMatrixTransposeType<T,size_t(-1),size_t(-1)>
00131 {
00132 typedef CMatrixTemplateNumeric<T> mat_type;
00133 };
00134
00135
00136
00137 #define MAT_TYPEDECL_TRANSPOSE_OF(MAT) \
00138 mrpt::math::detail::TMatrixTransposeType< \
00139 MAT::value_type, \
00140 MAT::mrpt_matrix_type_nrows, \
00141 MAT::mrpt_matrix_type_ncols>::mat_type
00142
00143
00144 #define MAT_TYPE_TRANSPOSE_OF(MAT) \
00145 typename mrpt::math::detail::TMatrixTransposeType< \
00146 typename MAT::value_type, \
00147 MAT::mrpt_matrix_type_nrows, \
00148 MAT::mrpt_matrix_type_ncols>::mat_type
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162 template <typename T,size_t NR1,size_t NC1>
00163 struct TMatrixCovarianceType
00164 {
00165 typedef CMatrixFixedNumeric<T,NC1,NC1> mat_type;
00166 };
00167
00168 template <typename T>
00169 struct TMatrixCovarianceType<T,size_t(-1),size_t(-1)>
00170 {
00171 typedef CMatrixTemplateNumeric<T> mat_type;
00172 };
00173
00174
00175
00176 #define MAT_TYPEDECL_COVARIANCE_OF(MAT) \
00177 mrpt::math::detail::TMatrixCovarianceType< \
00178 MAT::value_type, \
00179 MAT::mrpt_matrix_type_nrows, \
00180 MAT::mrpt_matrix_type_ncols>::mat_type
00181
00182
00183 #define MAT_TYPE_COVARIANCE_OF(MAT) \
00184 typename mrpt::math::detail::TMatrixCovarianceType< \
00185 typename MAT::value_type, \
00186 MAT::mrpt_matrix_type_nrows, \
00187 MAT::mrpt_matrix_type_ncols>::mat_type
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199 template <typename T,size_t N1,size_t N2>
00200 struct TMatrixJacobianType
00201 {
00202 typedef CMatrixFixedNumeric<T,N2,N1> mat_type;
00203 };
00204 template <typename T,size_t N1>
00205 struct TMatrixJacobianType<T,N1,size_t(-1)>
00206 {
00207 typedef CMatrixTemplateNumeric<T> mat_type;
00208 };
00209 template <typename T,size_t N2>
00210 struct TMatrixJacobianType<T,size_t(-1),N2>
00211 {
00212 typedef CMatrixTemplateNumeric<T> mat_type;
00213 };
00214 template <typename T>
00215 struct TMatrixJacobianType<T,size_t(-1),size_t(-1)>
00216 {
00217 typedef CMatrixTemplateNumeric<T> mat_type;
00218 };
00219
00220
00221 #define MAT_TYPEDECL_JACOBIAN_OF(VECX,VECY) \
00222 mrpt::math::detail::TMatrixJacobianType< \
00223 VECX::value_type, \
00224 VECX::mrpt_vector_type_len, \
00225 VECY::mrpt_vector_type_len>::mat_type
00226
00227
00228 #define MAT_TYPE_JACOBIAN_OF(VECX,VECY) \
00229 typename mrpt::math::detail::TMatrixJacobianType< \
00230 typename VECX::value_type, \
00231 VECX::mrpt_vector_type_len, \
00232 VECY::mrpt_vector_type_len>::mat_type
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 template <typename T,size_t NR1,size_t NC1>
00245 struct TMatrixSameSizeOfType
00246 {
00247 typedef CMatrixFixedNumeric<T,NR1,NC1> mat_type;
00248 };
00249
00250 template <typename T>
00251 struct TMatrixSameSizeOfType<T,size_t(-1),size_t(-1)>
00252 {
00253 typedef CMatrixTemplateNumeric<T> mat_type;
00254 };
00255
00256
00257
00258 #define MAT_TYPEDECL_SAMESIZE_OF(MAT) \
00259 mrpt::math::detail::TMatrixSameSizeOfType< \
00260 MAT::value_type, \
00261 MAT::mrpt_matrix_type_nrows, \
00262 MAT::mrpt_matrix_type_ncols>::mat_type
00263
00264
00265 #define MAT_TYPE_SAMESIZE_OF(MAT) \
00266 typename mrpt::math::detail::TMatrixSameSizeOfType< \
00267 typename MAT::value_type, \
00268 MAT::mrpt_matrix_type_nrows, \
00269 MAT::mrpt_matrix_type_ncols>::mat_type
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282 template <typename T,size_t NR1>
00283 struct TArrayOrVectorRowCountOfType
00284 {
00285 typedef CArrayNumeric<T,NR1> vec_type;
00286 };
00287
00288 template <typename T>
00289 struct TArrayOrVectorRowCountOfType<T,size_t(-1)>
00290 {
00291 typedef std::vector<T> vec_type;
00292 };
00293
00294
00295
00296 #define ARRAY_TYPEDECL_SAMESIZE_ROWS_OF(MAT) \
00297 mrpt::math::detail::TArrayOrVectorRowCountOfType< \
00298 MAT::value_type, \
00299 MAT::mrpt_matrix_type_nrows>::vec_type
00300
00301
00302 #define ARRAY_TYPE_SAMESIZE_ROWS_OF(MAT) \
00303 typename mrpt::math::detail::TArrayOrVectorRowCountOfType< \
00304 typename MAT::value_type, \
00305 MAT::mrpt_matrix_type_nrows>::vec_type
00306
00307
00308
00309 }}}
00310
00311 #endif