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