traits.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 template<typename T1>
00022 struct get_pod_type
00023 { typedef T1 result; };
00024
00025 template<typename T2>
00026 struct get_pod_type< std::complex<T2> >
00027 { typedef T2 result; };
00028
00029
00030
00031 template<typename T>
00032 struct is_Mat_only
00033 { static const bool value = false; };
00034
00035 template<typename eT>
00036 struct is_Mat_only< Mat<eT> >
00037 { static const bool value = true; };
00038
00039
00040
00041 template<typename T>
00042 struct is_Mat
00043 { static const bool value = false; };
00044
00045 template<typename eT>
00046 struct is_Mat< Mat<eT> >
00047 { static const bool value = true; };
00048
00049 template<typename eT>
00050 struct is_Mat< Row<eT> >
00051 { static const bool value = true; };
00052
00053 template<typename eT>
00054 struct is_Mat< Col<eT> >
00055 { static const bool value = true; };
00056
00057
00058
00059 template<typename T>
00060 struct is_Row
00061 { static const bool value = false; };
00062
00063 template<typename eT>
00064 struct is_Row< Row<eT> >
00065 { static const bool value = true; };
00066
00067
00068
00069 template<typename T>
00070 struct is_Col
00071 { static const bool value = false; };
00072
00073 template<typename eT>
00074 struct is_Col< Col<eT> >
00075 { static const bool value = true; };
00076
00077
00078
00079
00080
00081
00082 template<typename T>
00083 struct is_subview
00084 { static const bool value = false; };
00085
00086 template<typename eT>
00087 struct is_subview< subview<eT> >
00088 { static const bool value = true; };
00089
00090
00091 template<typename T>
00092 struct is_diagview
00093 { static const bool value = false; };
00094
00095 template<typename eT>
00096 struct is_diagview< diagview<eT> >
00097 { static const bool value = true; };
00098
00099
00100
00101
00102
00103
00104
00105
00106 template<typename T>
00107 struct is_Cube
00108 { static const bool value = false; };
00109
00110 template<typename eT>
00111 struct is_Cube< Cube<eT> >
00112 { static const bool value = true; };
00113
00114 template<typename T>
00115 struct is_subview_cube
00116 { static const bool value = false; };
00117
00118 template<typename eT>
00119 struct is_subview_cube< subview_cube<eT> >
00120 { static const bool value = true; };
00121
00122
00123
00124
00125
00126
00127
00128
00129 template<typename T>
00130 struct is_Op
00131 { static const bool value = false; };
00132
00133 template<typename T1, typename op_type>
00134 struct is_Op< Op<T1,op_type> >
00135 { static const bool value = true; };
00136
00137
00138 template<typename T>
00139 struct is_OpCube
00140 { static const bool value = false; };
00141
00142 template<typename T1, typename op_type>
00143 struct is_OpCube< OpCube<T1,op_type> >
00144 { static const bool value = true; };
00145
00146
00147 template<typename T>
00148 struct is_Glue
00149 { static const bool value = false; };
00150
00151 template<typename T1, typename T2, typename glue_type>
00152 struct is_Glue< Glue<T1,T2,glue_type> >
00153 { static const bool value = true; };
00154
00155
00156 template<typename T>
00157 struct is_GlueCube
00158 { static const bool value = false; };
00159
00160 template<typename T1, typename T2, typename glue_type>
00161 struct is_GlueCube< GlueCube<T1,T2,glue_type> >
00162 { static const bool value = true; };
00163
00164
00165 template<typename T>
00166 struct is_glue_times
00167 { static const bool value = false; };
00168
00169 template<typename T1, typename T2>
00170 struct is_glue_times< Glue<T1,T2,glue_times> >
00171 { static const bool value = true; };
00172
00173
00174 template<typename T>
00175 struct is_glue_times_diag
00176 { static const bool value = false; };
00177
00178 template<typename T1, typename T2>
00179 struct is_glue_times_diag< Glue<T1,T2,glue_times_diag> >
00180 { static const bool value = true; };
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 template<typename T>
00192 struct is_eOp
00193 { static const bool value = false; };
00194
00195 template<typename T1, typename eop_type>
00196 struct is_eOp< eOp<T1,eop_type> >
00197 { static const bool value = true; };
00198
00199
00200 template<typename T>
00201 struct is_eGlue
00202 { static const bool value = false; };
00203
00204 template<typename T1, typename T2, typename eglue_type>
00205 struct is_eGlue< eGlue<T1,T2,eglue_type> >
00206 { static const bool value = true; };
00207
00208
00209 template<typename T>
00210 struct is_op_diagmat
00211 { static const bool value = false; };
00212
00213 template<typename T1>
00214 struct is_op_diagmat< Op<T1,op_diagmat> >
00215 { static const bool value = true; };
00216
00217
00218
00219
00220
00221
00222 template<typename T1>
00223 struct is_arma_type
00224 {
00225 static const bool value
00226 = is_Mat<T1>::value
00227 || is_Op<T1>::value
00228 || is_Glue<T1>::value
00229 || is_subview<T1>::value
00230 || is_diagview<T1>::value
00231 || is_eOp<T1>::value
00232 || is_eGlue<T1>::value
00233 ;
00234 };
00235
00236
00237
00238 template<typename T1>
00239 struct is_arma_cube_type
00240 {
00241 static const bool value
00242 = is_Cube<T1>::value
00243 || is_OpCube<T1>::value
00244 || is_GlueCube<T1>::value
00245 || is_subview_cube<T1>::value
00246 ;
00247 };
00248
00249
00250
00251
00252
00253
00254
00255
00256 template<typename T1, typename T2>
00257 struct is_same_type
00258 { static const bool value = false; };
00259
00260
00261 template<typename T1>
00262 struct is_same_type<T1,T1>
00263 { static const bool value = true; };
00264
00265
00266
00267 template<typename T1, typename T2>
00268 struct isnt_same_type
00269 {
00270 static const bool value = true;
00271
00272 inline static void check()
00273 {
00274 arma_static_assert<false> ERROR___TYPE_MISMATCH;
00275 ERROR___TYPE_MISMATCH = ERROR___TYPE_MISMATCH;
00276 }
00277 };
00278
00279
00280 template<typename T1>
00281 struct isnt_same_type<T1,T1>
00282 {
00283 static const bool value = false;
00284
00285 arma_inline static void check() {}
00286 };
00287
00288
00289
00290
00291
00292
00293
00294 template<typename T1>
00295 struct isnt_fltpt
00296 {
00297 static const bool value = true;
00298
00299 inline static void check()
00300 {
00301 arma_static_assert<false> ERROR___TYPE_MISMATCH;
00302 ERROR___TYPE_MISMATCH = ERROR___TYPE_MISMATCH;
00303 }
00304 };
00305
00306
00307
00308 struct isnt_fltpt_false
00309 {
00310 static const bool value = false;
00311
00312 arma_inline static void check() {}
00313 };
00314
00315
00316
00317 template<> struct isnt_fltpt< float > : public isnt_fltpt_false {};
00318 template<> struct isnt_fltpt< double > : public isnt_fltpt_false {};
00319 template<> struct isnt_fltpt< long double > : public isnt_fltpt_false {};
00320 template<> struct isnt_fltpt< std::complex<float> > : public isnt_fltpt_false {};
00321 template<> struct isnt_fltpt< std::complex<double> > : public isnt_fltpt_false {};
00322
00323
00324
00325 template<typename T1>
00326 struct is_u8
00327 { static const bool value = false; };
00328
00329 template<>
00330 struct is_u8<u8>
00331 { static const bool value = true; };
00332
00333
00334
00335 template<typename T1>
00336 struct is_s8
00337 { static const bool value = false; };
00338
00339 template<>
00340 struct is_s8<s8>
00341 { static const bool value = true; };
00342
00343
00344
00345 template<typename T1>
00346 struct is_u16
00347 { static const bool value = false; };
00348
00349 template<>
00350 struct is_u16<u16>
00351 { static const bool value = true; };
00352
00353
00354
00355 template<typename T1>
00356 struct is_s16
00357 { static const bool value = false; };
00358
00359 template<>
00360 struct is_s16<s16>
00361 { static const bool value = true; };
00362
00363
00364
00365 template<typename T1>
00366 struct is_u32
00367 { static const bool value = false; };
00368
00369 template<>
00370 struct is_u32<u32>
00371 { static const bool value = true; };
00372
00373
00374
00375 template<typename T1>
00376 struct is_s32
00377 { static const bool value = false; };
00378
00379 template<>
00380 struct is_s32<s32>
00381 { static const bool value = true; };
00382
00383
00384
00385
00386 template<typename T1>
00387 struct is_float
00388 { static const bool value = false; };
00389
00390 template<>
00391 struct is_float<float>
00392 { static const bool value = true; };
00393
00394
00395
00396 template<typename T1>
00397 struct is_double
00398 { static const bool value = false; };
00399
00400 template<>
00401 struct is_double<double>
00402 { static const bool value = true; };
00403
00404
00405
00406 template<typename T1>
00407 struct is_complex
00408 { static const bool value = false; };
00409
00410
00411 template<typename eT>
00412 struct is_complex< std::complex<eT> >
00413 { static const bool value = true; };
00414
00415
00416
00417 template<typename T1>
00418 struct is_complex_float
00419 { static const bool value = false; };
00420
00421 template<>
00422 struct is_complex< std::complex<float> >
00423 { static const bool value = true; };
00424
00425
00426
00427 template<typename T1>
00428 struct is_complex_double
00429 { static const bool value = false; };
00430
00431 template<>
00432 struct is_complex_double< std::complex<double> >
00433 { static const bool value = true; };
00434
00435
00436
00437
00438
00439 template<typename T1>
00440 struct is_supported_complex
00441 { static const bool value = false; };
00442
00443
00444 template<typename eT>
00445 struct is_supported_complex< std::complex<eT> >
00446 { static const bool value = ( sizeof(std::complex<eT>) == 2*sizeof(eT) ); };
00447
00448
00449
00450 template<typename T1>
00451 struct is_supported_complex_float
00452 { static const bool value = false; };
00453
00454 template<>
00455 struct is_supported_complex_float< std::complex<float> >
00456 { static const bool value = ( sizeof(std::complex<float>) == 2*sizeof(float) ); };
00457
00458
00459
00460 template<typename T1>
00461 struct is_supported_complex_double
00462 { static const bool value = false; };
00463
00464 template<>
00465 struct is_supported_complex_double< std::complex<double> >
00466 { static const bool value = ( sizeof(std::complex<double>) == 2*sizeof(double) ); };
00467
00468
00469
00470 template<typename T1>
00471 struct is_supported_elem_type
00472 {
00473 static const bool value = \
00474 is_u8<T1>::value ||
00475 is_s8<T1>::value ||
00476 is_u16<T1>::value ||
00477 is_s16<T1>::value ||
00478 is_u32<T1>::value ||
00479 is_s32<T1>::value ||
00480 is_float<T1>::value ||
00481 is_double<T1>::value ||
00482 is_supported_complex_float<T1>::value ||
00483 is_supported_complex_double<T1>::value;
00484 };
00485
00486
00487
00488 template<typename T1>
00489 struct isnt_supported_elem_type
00490 {
00491 static const bool value = true;
00492
00493 inline static void check()
00494 {
00495 arma_static_assert<false> ERROR___UNSUPPORTED_ELEMENT_TYPE;
00496 ERROR___UNSUPPORTED_ELEMENT_TYPE = ERROR___UNSUPPORTED_ELEMENT_TYPE;
00497 }
00498 };
00499
00500
00501
00502 struct isnt_supported_elem_type_false
00503 {
00504 static const bool value = false;
00505
00506 arma_inline static void check() {}
00507 };
00508
00509
00510
00511 template<> struct isnt_supported_elem_type< u8 > : public isnt_supported_elem_type_false {};
00512 template<> struct isnt_supported_elem_type< s8 > : public isnt_supported_elem_type_false {};
00513 template<> struct isnt_supported_elem_type< u16 > : public isnt_supported_elem_type_false {};
00514 template<> struct isnt_supported_elem_type< s16 > : public isnt_supported_elem_type_false {};
00515 template<> struct isnt_supported_elem_type< u32 > : public isnt_supported_elem_type_false {};
00516 template<> struct isnt_supported_elem_type< s32 > : public isnt_supported_elem_type_false {};
00517 template<> struct isnt_supported_elem_type< float > : public isnt_supported_elem_type_false {};
00518 template<> struct isnt_supported_elem_type< double > : public isnt_supported_elem_type_false {};
00519 template<> struct isnt_supported_elem_type< std::complex<float> > : public isnt_supported_elem_type_false {};
00520 template<> struct isnt_supported_elem_type< std::complex<double> > : public isnt_supported_elem_type_false {};
00521
00522
00523
00524 template<typename T1>
00525 struct is_supported_blas_type
00526 {
00527 static const bool value = \
00528 is_float<T1>::value ||
00529 is_double<T1>::value ||
00530 is_supported_complex_float<T1>::value ||
00531 is_supported_complex_double<T1>::value;
00532 };
00533
00534
00535
00536 template<typename T>
00537 struct is_signed
00538 {
00539 static const bool value = (T(-1) < T(0));
00540 };
00541
00542
00543
00544 template<typename T>
00545 struct is_non_integral
00546 {
00547 static const bool value = (T(1.0) != T(1.1));
00548 };
00549
00550
00551
00552
00553
00554 class arma_junk_class;
00555
00556 template<typename T1, typename T2>
00557 struct force_different_type
00558 {
00559 typedef T1 T1_result;
00560 typedef T2 T2_result;
00561 };
00562
00563
00564 template<typename T1>
00565 struct force_different_type<T1,T1>
00566 {
00567 typedef T1 T1_result;
00568 typedef arma_junk_class T2_result;
00569 };
00570
00571
00572
00573