Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-3.900.4/include/armadillo_bits/traits.hpp @ 49:1ec0e2823891
Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author | Chris Cannam |
---|---|
date | Thu, 13 Jun 2013 10:25:24 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
48:69251e11a913 | 49:1ec0e2823891 |
---|---|
1 // Copyright (C) 2008-2013 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2008-2013 Conrad Sanderson | |
3 // | |
4 // This Source Code Form is subject to the terms of the Mozilla Public | |
5 // License, v. 2.0. If a copy of the MPL was not distributed with this | |
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
7 | |
8 | |
9 //! \addtogroup traits | |
10 //! @{ | |
11 | |
12 | |
13 template<typename T1> | |
14 struct get_pod_type | |
15 { typedef T1 result; }; | |
16 | |
17 template<typename T2> | |
18 struct get_pod_type< std::complex<T2> > | |
19 { typedef T2 result; }; | |
20 | |
21 | |
22 | |
23 template<typename T> | |
24 struct is_Mat_fixed_only | |
25 { | |
26 typedef char yes[1]; | |
27 typedef char no[2]; | |
28 | |
29 template<typename X> static yes& check(typename X::Mat_fixed_type*); | |
30 template<typename> static no& check(...); | |
31 | |
32 static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
33 }; | |
34 | |
35 | |
36 | |
37 template<typename T> | |
38 struct is_Row_fixed_only | |
39 { | |
40 typedef char yes[1]; | |
41 typedef char no[2]; | |
42 | |
43 template<typename X> static yes& check(typename X::Row_fixed_type*); | |
44 template<typename> static no& check(...); | |
45 | |
46 static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
47 }; | |
48 | |
49 | |
50 | |
51 template<typename T> | |
52 struct is_Col_fixed_only | |
53 { | |
54 typedef char yes[1]; | |
55 typedef char no[2]; | |
56 | |
57 template<typename X> static yes& check(typename X::Col_fixed_type*); | |
58 template<typename> static no& check(...); | |
59 | |
60 static const bool value = ( sizeof(check<T>(0)) == sizeof(yes) ); | |
61 }; | |
62 | |
63 | |
64 | |
65 template<typename T> | |
66 struct is_Mat_fixed | |
67 { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); }; | |
68 | |
69 | |
70 | |
71 template<typename T> | |
72 struct is_Mat_only | |
73 { static const bool value = is_Mat_fixed_only<T>::value; }; | |
74 | |
75 template<typename eT> | |
76 struct is_Mat_only< Mat<eT> > | |
77 { static const bool value = true; }; | |
78 | |
79 template<typename eT> | |
80 struct is_Mat_only< const Mat<eT> > | |
81 { static const bool value = true; }; | |
82 | |
83 | |
84 | |
85 template<typename T> | |
86 struct is_Mat | |
87 { static const bool value = ( is_Mat_fixed_only<T>::value || is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); }; | |
88 | |
89 template<typename eT> | |
90 struct is_Mat< Mat<eT> > | |
91 { static const bool value = true; }; | |
92 | |
93 template<typename eT> | |
94 struct is_Mat< const Mat<eT> > | |
95 { static const bool value = true; }; | |
96 | |
97 template<typename eT> | |
98 struct is_Mat< Row<eT> > | |
99 { static const bool value = true; }; | |
100 | |
101 template<typename eT> | |
102 struct is_Mat< const Row<eT> > | |
103 { static const bool value = true; }; | |
104 | |
105 template<typename eT> | |
106 struct is_Mat< Col<eT> > | |
107 { static const bool value = true; }; | |
108 | |
109 template<typename eT> | |
110 struct is_Mat< const Col<eT> > | |
111 { static const bool value = true; }; | |
112 | |
113 | |
114 | |
115 template<typename T> | |
116 struct is_Row | |
117 { static const bool value = is_Row_fixed_only<T>::value; }; | |
118 | |
119 template<typename eT> | |
120 struct is_Row< Row<eT> > | |
121 { static const bool value = true; }; | |
122 | |
123 template<typename eT> | |
124 struct is_Row< const Row<eT> > | |
125 { static const bool value = true; }; | |
126 | |
127 | |
128 | |
129 template<typename T> | |
130 struct is_Col | |
131 { static const bool value = is_Col_fixed_only<T>::value; }; | |
132 | |
133 template<typename eT> | |
134 struct is_Col< Col<eT> > | |
135 { static const bool value = true; }; | |
136 | |
137 template<typename eT> | |
138 struct is_Col< const Col<eT> > | |
139 { static const bool value = true; }; | |
140 | |
141 | |
142 | |
143 template<typename T> | |
144 struct is_diagview | |
145 { static const bool value = false; }; | |
146 | |
147 template<typename eT> | |
148 struct is_diagview< diagview<eT> > | |
149 { static const bool value = true; }; | |
150 | |
151 template<typename eT> | |
152 struct is_diagview< const diagview<eT> > | |
153 { static const bool value = true; }; | |
154 | |
155 | |
156 template<typename T> | |
157 struct is_subview | |
158 { static const bool value = false; }; | |
159 | |
160 template<typename eT> | |
161 struct is_subview< subview<eT> > | |
162 { static const bool value = true; }; | |
163 | |
164 template<typename eT> | |
165 struct is_subview< const subview<eT> > | |
166 { static const bool value = true; }; | |
167 | |
168 | |
169 template<typename T> | |
170 struct is_subview_row | |
171 { static const bool value = false; }; | |
172 | |
173 template<typename eT> | |
174 struct is_subview_row< subview_row<eT> > | |
175 { static const bool value = true; }; | |
176 | |
177 template<typename eT> | |
178 struct is_subview_row< const subview_row<eT> > | |
179 { static const bool value = true; }; | |
180 | |
181 | |
182 template<typename T> | |
183 struct is_subview_col | |
184 { static const bool value = false; }; | |
185 | |
186 template<typename eT> | |
187 struct is_subview_col< subview_col<eT> > | |
188 { static const bool value = true; }; | |
189 | |
190 template<typename eT> | |
191 struct is_subview_col< const subview_col<eT> > | |
192 { static const bool value = true; }; | |
193 | |
194 | |
195 template<typename T> | |
196 struct is_subview_elem1 | |
197 { static const bool value = false; }; | |
198 | |
199 template<typename eT, typename T1> | |
200 struct is_subview_elem1< subview_elem1<eT, T1> > | |
201 { static const bool value = true; }; | |
202 | |
203 template<typename eT, typename T1> | |
204 struct is_subview_elem1< const subview_elem1<eT, T1> > | |
205 { static const bool value = true; }; | |
206 | |
207 | |
208 template<typename T> | |
209 struct is_subview_elem2 | |
210 { static const bool value = false; }; | |
211 | |
212 template<typename eT, typename T1, typename T2> | |
213 struct is_subview_elem2< subview_elem2<eT, T1, T2> > | |
214 { static const bool value = true; }; | |
215 | |
216 template<typename eT, typename T1, typename T2> | |
217 struct is_subview_elem2< const subview_elem2<eT, T1, T2> > | |
218 { static const bool value = true; }; | |
219 | |
220 | |
221 | |
222 // | |
223 // | |
224 // | |
225 | |
226 | |
227 | |
228 template<typename T> | |
229 struct is_Cube | |
230 { static const bool value = false; }; | |
231 | |
232 template<typename eT> | |
233 struct is_Cube< Cube<eT> > | |
234 { static const bool value = true; }; | |
235 | |
236 template<typename T> | |
237 struct is_subview_cube | |
238 { static const bool value = false; }; | |
239 | |
240 template<typename eT> | |
241 struct is_subview_cube< subview_cube<eT> > | |
242 { static const bool value = true; }; | |
243 | |
244 | |
245 | |
246 // | |
247 // | |
248 // | |
249 | |
250 | |
251 template<typename T> | |
252 struct is_Gen | |
253 { static const bool value = false; }; | |
254 | |
255 template<typename T1, typename gen_type> | |
256 struct is_Gen< Gen<T1,gen_type> > | |
257 { static const bool value = true; }; | |
258 | |
259 template<typename T1, typename gen_type> | |
260 struct is_Gen< const Gen<T1,gen_type> > | |
261 { static const bool value = true; }; | |
262 | |
263 | |
264 template<typename T> | |
265 struct is_Op | |
266 { static const bool value = false; }; | |
267 | |
268 template<typename T1, typename op_type> | |
269 struct is_Op< Op<T1,op_type> > | |
270 { static const bool value = true; }; | |
271 | |
272 template<typename T1, typename op_type> | |
273 struct is_Op< const Op<T1,op_type> > | |
274 { static const bool value = true; }; | |
275 | |
276 template<typename T> | |
277 struct is_eOp | |
278 { static const bool value = false; }; | |
279 | |
280 template<typename T1, typename eop_type> | |
281 struct is_eOp< eOp<T1,eop_type> > | |
282 { static const bool value = true; }; | |
283 | |
284 template<typename T1, typename eop_type> | |
285 struct is_eOp< const eOp<T1,eop_type> > | |
286 { static const bool value = true; }; | |
287 | |
288 | |
289 template<typename T> | |
290 struct is_mtOp | |
291 { static const bool value = false; }; | |
292 | |
293 template<typename eT, typename T1, typename op_type> | |
294 struct is_mtOp< mtOp<eT, T1, op_type> > | |
295 { static const bool value = true; }; | |
296 | |
297 template<typename eT, typename T1, typename op_type> | |
298 struct is_mtOp< const mtOp<eT, T1, op_type> > | |
299 { static const bool value = true; }; | |
300 | |
301 | |
302 template<typename T> | |
303 struct is_Glue | |
304 { static const bool value = false; }; | |
305 | |
306 template<typename T1, typename T2, typename glue_type> | |
307 struct is_Glue< Glue<T1,T2,glue_type> > | |
308 { static const bool value = true; }; | |
309 | |
310 template<typename T1, typename T2, typename glue_type> | |
311 struct is_Glue< const Glue<T1,T2,glue_type> > | |
312 { static const bool value = true; }; | |
313 | |
314 | |
315 template<typename T> | |
316 struct is_eGlue | |
317 { static const bool value = false; }; | |
318 | |
319 template<typename T1, typename T2, typename eglue_type> | |
320 struct is_eGlue< eGlue<T1,T2,eglue_type> > | |
321 { static const bool value = true; }; | |
322 | |
323 template<typename T1, typename T2, typename eglue_type> | |
324 struct is_eGlue< const eGlue<T1,T2,eglue_type> > | |
325 { static const bool value = true; }; | |
326 | |
327 | |
328 template<typename T> | |
329 struct is_mtGlue | |
330 { static const bool value = false; }; | |
331 | |
332 template<typename eT, typename T1, typename T2, typename glue_type> | |
333 struct is_mtGlue< mtGlue<eT, T1, T2, glue_type> > | |
334 { static const bool value = true; }; | |
335 | |
336 template<typename eT, typename T1, typename T2, typename glue_type> | |
337 struct is_mtGlue< const mtGlue<eT, T1, T2, glue_type> > | |
338 { static const bool value = true; }; | |
339 | |
340 | |
341 // | |
342 // | |
343 | |
344 | |
345 template<typename T> | |
346 struct is_glue_times | |
347 { static const bool value = false; }; | |
348 | |
349 template<typename T1, typename T2> | |
350 struct is_glue_times< Glue<T1,T2,glue_times> > | |
351 { static const bool value = true; }; | |
352 | |
353 template<typename T1, typename T2> | |
354 struct is_glue_times< const Glue<T1,T2,glue_times> > | |
355 { static const bool value = true; }; | |
356 | |
357 | |
358 template<typename T> | |
359 struct is_glue_times_diag | |
360 { static const bool value = false; }; | |
361 | |
362 template<typename T1, typename T2> | |
363 struct is_glue_times_diag< Glue<T1,T2,glue_times_diag> > | |
364 { static const bool value = true; }; | |
365 | |
366 template<typename T1, typename T2> | |
367 struct is_glue_times_diag< const Glue<T1,T2,glue_times_diag> > | |
368 { static const bool value = true; }; | |
369 | |
370 | |
371 template<typename T> | |
372 struct is_op_diagmat | |
373 { static const bool value = false; }; | |
374 | |
375 template<typename T1> | |
376 struct is_op_diagmat< Op<T1,op_diagmat> > | |
377 { static const bool value = true; }; | |
378 | |
379 template<typename T1> | |
380 struct is_op_diagmat< const Op<T1,op_diagmat> > | |
381 { static const bool value = true; }; | |
382 | |
383 | |
384 template<typename T> | |
385 struct is_op_htrans2 | |
386 { static const bool value = false; }; | |
387 | |
388 template<typename T1> | |
389 struct is_op_htrans2< Op<T1,op_htrans2> > | |
390 { static const bool value = true; }; | |
391 | |
392 template<typename T1> | |
393 struct is_op_htrans2< const Op<T1,op_htrans2> > | |
394 { static const bool value = true; }; | |
395 | |
396 | |
397 // | |
398 // | |
399 | |
400 | |
401 template<typename T> | |
402 struct is_GenCube | |
403 { static const bool value = false; }; | |
404 | |
405 template<typename eT, typename gen_type> | |
406 struct is_GenCube< GenCube<eT,gen_type> > | |
407 { static const bool value = true; }; | |
408 | |
409 | |
410 template<typename T> | |
411 struct is_OpCube | |
412 { static const bool value = false; }; | |
413 | |
414 template<typename T1, typename op_type> | |
415 struct is_OpCube< OpCube<T1,op_type> > | |
416 { static const bool value = true; }; | |
417 | |
418 | |
419 template<typename T> | |
420 struct is_eOpCube | |
421 { static const bool value = false; }; | |
422 | |
423 template<typename T1, typename eop_type> | |
424 struct is_eOpCube< eOpCube<T1,eop_type> > | |
425 { static const bool value = true; }; | |
426 | |
427 | |
428 template<typename T> | |
429 struct is_mtOpCube | |
430 { static const bool value = false; }; | |
431 | |
432 template<typename eT, typename T1, typename op_type> | |
433 struct is_mtOpCube< mtOpCube<eT, T1, op_type> > | |
434 { static const bool value = true; }; | |
435 | |
436 | |
437 template<typename T> | |
438 struct is_GlueCube | |
439 { static const bool value = false; }; | |
440 | |
441 template<typename T1, typename T2, typename glue_type> | |
442 struct is_GlueCube< GlueCube<T1,T2,glue_type> > | |
443 { static const bool value = true; }; | |
444 | |
445 | |
446 template<typename T> | |
447 struct is_eGlueCube | |
448 { static const bool value = false; }; | |
449 | |
450 template<typename T1, typename T2, typename eglue_type> | |
451 struct is_eGlueCube< eGlueCube<T1,T2,eglue_type> > | |
452 { static const bool value = true; }; | |
453 | |
454 | |
455 template<typename T> | |
456 struct is_mtGlueCube | |
457 { static const bool value = false; }; | |
458 | |
459 template<typename eT, typename T1, typename T2, typename glue_type> | |
460 struct is_mtGlueCube< mtGlueCube<eT, T1, T2, glue_type> > | |
461 { static const bool value = true; }; | |
462 | |
463 | |
464 // | |
465 // | |
466 // | |
467 | |
468 | |
469 template<typename T> | |
470 struct is_op_rel | |
471 { static const bool value = false; }; | |
472 | |
473 template<typename out_eT, typename T1> | |
474 struct is_op_rel< mtOp<out_eT, T1, op_rel_lt_pre> > | |
475 { static const bool value = true; }; | |
476 | |
477 template<typename out_eT, typename T1> | |
478 struct is_op_rel< mtOp<out_eT, T1, op_rel_lt_post> > | |
479 { static const bool value = true; }; | |
480 | |
481 template<typename out_eT, typename T1> | |
482 struct is_op_rel< mtOp<out_eT, T1, op_rel_gt_pre> > | |
483 { static const bool value = true; }; | |
484 | |
485 template<typename out_eT, typename T1> | |
486 struct is_op_rel< mtOp<out_eT, T1, op_rel_gt_post> > | |
487 { static const bool value = true; }; | |
488 | |
489 template<typename out_eT, typename T1> | |
490 struct is_op_rel< mtOp<out_eT, T1, op_rel_lteq_pre> > | |
491 { static const bool value = true; }; | |
492 | |
493 template<typename out_eT, typename T1> | |
494 struct is_op_rel< mtOp<out_eT, T1, op_rel_lteq_post> > | |
495 { static const bool value = true; }; | |
496 | |
497 template<typename out_eT, typename T1> | |
498 struct is_op_rel< mtOp<out_eT, T1, op_rel_gteq_pre> > | |
499 { static const bool value = true; }; | |
500 | |
501 template<typename out_eT, typename T1> | |
502 struct is_op_rel< mtOp<out_eT, T1, op_rel_gteq_post> > | |
503 { static const bool value = true; }; | |
504 | |
505 template<typename out_eT, typename T1> | |
506 struct is_op_rel< mtOp<out_eT, T1, op_rel_eq> > | |
507 { static const bool value = true; }; | |
508 | |
509 template<typename out_eT, typename T1> | |
510 struct is_op_rel< mtOp<out_eT, T1, op_rel_noteq> > | |
511 { static const bool value = true; }; | |
512 | |
513 | |
514 | |
515 // | |
516 // | |
517 // | |
518 | |
519 | |
520 | |
521 template<typename T> | |
522 struct is_basevec | |
523 { static const bool value = ( is_Row_fixed_only<T>::value || is_Col_fixed_only<T>::value ); }; | |
524 | |
525 template<typename eT> | |
526 struct is_basevec< Row<eT> > | |
527 { static const bool value = true; }; | |
528 | |
529 template<typename eT> | |
530 struct is_basevec< const Row<eT> > | |
531 { static const bool value = true; }; | |
532 | |
533 template<typename eT> | |
534 struct is_basevec< Col<eT> > | |
535 { static const bool value = true; }; | |
536 | |
537 template<typename eT> | |
538 struct is_basevec< const Col<eT> > | |
539 { static const bool value = true; }; | |
540 | |
541 template<typename eT> | |
542 struct is_basevec< subview_row<eT> > | |
543 { static const bool value = true; }; | |
544 | |
545 template<typename eT> | |
546 struct is_basevec< const subview_row<eT> > | |
547 { static const bool value = true; }; | |
548 | |
549 template<typename eT> | |
550 struct is_basevec< subview_col<eT> > | |
551 { static const bool value = true; }; | |
552 | |
553 template<typename eT> | |
554 struct is_basevec< const subview_col<eT> > | |
555 { static const bool value = true; }; | |
556 | |
557 template<typename eT> | |
558 struct is_basevec< diagview<eT> > | |
559 { static const bool value = true; }; | |
560 | |
561 template<typename eT> | |
562 struct is_basevec< const diagview<eT> > | |
563 { static const bool value = true; }; | |
564 | |
565 template<typename eT, typename T1> | |
566 struct is_basevec< subview_elem1<eT,T1> > | |
567 { static const bool value = true; }; | |
568 | |
569 template<typename eT, typename T1> | |
570 struct is_basevec< const subview_elem1<eT,T1> > | |
571 { static const bool value = true; }; | |
572 | |
573 | |
574 // | |
575 // | |
576 // | |
577 | |
578 | |
579 | |
580 template<typename T1> | |
581 struct is_arma_type | |
582 { | |
583 static const bool value | |
584 = is_Mat<T1>::value | |
585 || is_Gen<T1>::value | |
586 || is_Op<T1>::value | |
587 || is_Glue<T1>::value | |
588 || is_eOp<T1>::value | |
589 || is_eGlue<T1>::value | |
590 || is_mtOp<T1>::value | |
591 || is_mtGlue<T1>::value | |
592 || is_diagview<T1>::value | |
593 || is_subview<T1>::value | |
594 || is_subview_row<T1>::value | |
595 || is_subview_col<T1>::value | |
596 || is_subview_elem1<T1>::value | |
597 || is_subview_elem2<T1>::value | |
598 ; | |
599 }; | |
600 | |
601 | |
602 | |
603 template<typename T1> | |
604 struct is_arma_cube_type | |
605 { | |
606 static const bool value | |
607 = is_Cube<T1>::value | |
608 || is_GenCube<T1>::value | |
609 || is_OpCube<T1>::value | |
610 || is_eOpCube<T1>::value | |
611 || is_mtOpCube<T1>::value | |
612 || is_GlueCube<T1>::value | |
613 || is_eGlueCube<T1>::value | |
614 || is_mtGlueCube<T1>::value | |
615 || is_subview_cube<T1>::value | |
616 ; | |
617 }; | |
618 | |
619 | |
620 | |
621 // | |
622 // | |
623 // | |
624 | |
625 | |
626 | |
627 template<typename T> | |
628 struct is_SpMat | |
629 { static const bool value = false; }; | |
630 | |
631 template<typename eT> | |
632 struct is_SpMat< SpMat<eT> > | |
633 { static const bool value = true; }; | |
634 | |
635 template<typename eT> | |
636 struct is_SpMat< SpCol<eT> > | |
637 { static const bool value = true; }; | |
638 | |
639 template<typename eT> | |
640 struct is_SpMat< SpRow<eT> > | |
641 { static const bool value = true; }; | |
642 | |
643 | |
644 | |
645 template<typename T> | |
646 struct is_SpRow | |
647 { static const bool value = false; }; | |
648 | |
649 template<typename eT> | |
650 struct is_SpRow< SpRow<eT> > | |
651 { static const bool value = true; }; | |
652 | |
653 | |
654 | |
655 template<typename T> | |
656 struct is_SpCol | |
657 { static const bool value = false; }; | |
658 | |
659 template<typename eT> | |
660 struct is_SpCol< SpCol<eT> > | |
661 { static const bool value = true; }; | |
662 | |
663 | |
664 | |
665 template<typename T> | |
666 struct is_SpSubview | |
667 { static const bool value = false; }; | |
668 | |
669 template<typename eT> | |
670 struct is_SpSubview< SpSubview<eT> > | |
671 { static const bool value = true; }; | |
672 | |
673 | |
674 template<typename T> | |
675 struct is_SpOp | |
676 { static const bool value = false; }; | |
677 | |
678 template<typename T1, typename op_type> | |
679 struct is_SpOp< SpOp<T1,op_type> > | |
680 { static const bool value = true; }; | |
681 | |
682 | |
683 template<typename T> | |
684 struct is_SpGlue | |
685 { static const bool value = false; }; | |
686 | |
687 template<typename T1, typename T2, typename glue_type> | |
688 struct is_SpGlue< SpGlue<T1,T2,glue_type> > | |
689 { static const bool value = true; }; | |
690 | |
691 | |
692 template<typename T> | |
693 struct is_mtSpOp | |
694 { static const bool value = false; }; | |
695 | |
696 template<typename eT, typename T1, typename spop_type> | |
697 struct is_mtSpOp< mtSpOp<eT, T1, spop_type> > | |
698 { static const bool value = true; }; | |
699 | |
700 | |
701 | |
702 template<typename T1> | |
703 struct is_arma_sparse_type | |
704 { | |
705 static const bool value | |
706 = is_SpMat<T1>::value | |
707 || is_SpSubview<T1>::value | |
708 || is_SpOp<T1>::value | |
709 || is_SpGlue<T1>::value | |
710 || is_mtSpOp<T1>::value | |
711 ; | |
712 }; | |
713 | |
714 | |
715 | |
716 // | |
717 // | |
718 // | |
719 | |
720 | |
721 template<typename T1, typename T2> | |
722 struct is_same_type | |
723 { static const bool value = false; }; | |
724 | |
725 | |
726 template<typename T1> | |
727 struct is_same_type<T1,T1> | |
728 { static const bool value = true; }; | |
729 | |
730 | |
731 | |
732 // | |
733 // | |
734 // | |
735 | |
736 | |
737 template<typename T1> | |
738 struct is_u8 | |
739 { static const bool value = false; }; | |
740 | |
741 template<> | |
742 struct is_u8<u8> | |
743 { static const bool value = true; }; | |
744 | |
745 | |
746 | |
747 template<typename T1> | |
748 struct is_s8 | |
749 { static const bool value = false; }; | |
750 | |
751 template<> | |
752 struct is_s8<s8> | |
753 { static const bool value = true; }; | |
754 | |
755 | |
756 | |
757 template<typename T1> | |
758 struct is_u16 | |
759 { static const bool value = false; }; | |
760 | |
761 template<> | |
762 struct is_u16<u16> | |
763 { static const bool value = true; }; | |
764 | |
765 | |
766 | |
767 template<typename T1> | |
768 struct is_s16 | |
769 { static const bool value = false; }; | |
770 | |
771 template<> | |
772 struct is_s16<s16> | |
773 { static const bool value = true; }; | |
774 | |
775 | |
776 | |
777 template<typename T1> | |
778 struct is_u32 | |
779 { static const bool value = false; }; | |
780 | |
781 template<> | |
782 struct is_u32<u32> | |
783 { static const bool value = true; }; | |
784 | |
785 | |
786 | |
787 template<typename T1> | |
788 struct is_s32 | |
789 { static const bool value = false; }; | |
790 | |
791 template<> | |
792 struct is_s32<s32> | |
793 { static const bool value = true; }; | |
794 | |
795 | |
796 | |
797 #if defined(ARMA_USE_U64S64) | |
798 template<typename T1> | |
799 struct is_u64 | |
800 { static const bool value = false; }; | |
801 | |
802 template<> | |
803 struct is_u64<u64> | |
804 { static const bool value = true; }; | |
805 | |
806 | |
807 template<typename T1> | |
808 struct is_s64 | |
809 { static const bool value = false; }; | |
810 | |
811 template<> | |
812 struct is_s64<s64> | |
813 { static const bool value = true; }; | |
814 #endif | |
815 | |
816 | |
817 | |
818 template<typename T1> | |
819 struct is_ulng_t | |
820 { static const bool value = false; }; | |
821 | |
822 template<> | |
823 struct is_ulng_t<ulng_t> | |
824 { static const bool value = true; }; | |
825 | |
826 | |
827 | |
828 template<typename T1> | |
829 struct is_slng_t | |
830 { static const bool value = false; }; | |
831 | |
832 template<> | |
833 struct is_slng_t<slng_t> | |
834 { static const bool value = true; }; | |
835 | |
836 | |
837 | |
838 template<typename T1> | |
839 struct is_ulng_t_32 | |
840 { static const bool value = false; }; | |
841 | |
842 template<> | |
843 struct is_ulng_t_32<ulng_t> | |
844 { static const bool value = (sizeof(ulng_t) == 4); }; | |
845 | |
846 | |
847 | |
848 template<typename T1> | |
849 struct is_slng_t_32 | |
850 { static const bool value = false; }; | |
851 | |
852 template<> | |
853 struct is_slng_t_32<slng_t> | |
854 { static const bool value = (sizeof(slng_t) == 4); }; | |
855 | |
856 | |
857 | |
858 template<typename T1> | |
859 struct is_ulng_t_64 | |
860 { static const bool value = false; }; | |
861 | |
862 template<> | |
863 struct is_ulng_t_64<ulng_t> | |
864 { static const bool value = (sizeof(ulng_t) == 8); }; | |
865 | |
866 | |
867 | |
868 template<typename T1> | |
869 struct is_slng_t_64 | |
870 { static const bool value = false; }; | |
871 | |
872 template<> | |
873 struct is_slng_t_64<slng_t> | |
874 { static const bool value = (sizeof(slng_t) == 8); }; | |
875 | |
876 | |
877 | |
878 template<typename T1> | |
879 struct is_uword | |
880 { static const bool value = false; }; | |
881 | |
882 template<> | |
883 struct is_uword<uword> | |
884 { static const bool value = true; }; | |
885 | |
886 | |
887 | |
888 template<typename T1> | |
889 struct is_sword | |
890 { static const bool value = false; }; | |
891 | |
892 template<> | |
893 struct is_sword<sword> | |
894 { static const bool value = true; }; | |
895 | |
896 | |
897 | |
898 template<typename T1> | |
899 struct is_float | |
900 { static const bool value = false; }; | |
901 | |
902 template<> | |
903 struct is_float<float> | |
904 { static const bool value = true; }; | |
905 | |
906 | |
907 | |
908 template<typename T1> | |
909 struct is_double | |
910 { static const bool value = false; }; | |
911 | |
912 template<> | |
913 struct is_double<double> | |
914 { static const bool value = true; }; | |
915 | |
916 | |
917 | |
918 template<typename T1> | |
919 struct is_real | |
920 { static const bool value = false; }; | |
921 | |
922 template<> | |
923 struct is_real<float> | |
924 { static const bool value = true; }; | |
925 | |
926 template<> | |
927 struct is_real<double> | |
928 { static const bool value = true; }; | |
929 | |
930 | |
931 | |
932 | |
933 template<typename T1> | |
934 struct is_not_complex | |
935 { static const bool value = true; }; | |
936 | |
937 template<typename eT> | |
938 struct is_not_complex< std::complex<eT> > | |
939 { static const bool value = false; }; | |
940 | |
941 | |
942 | |
943 template<typename T1> | |
944 struct is_complex | |
945 { static const bool value = false; }; | |
946 | |
947 // template<> | |
948 template<typename eT> | |
949 struct is_complex< std::complex<eT> > | |
950 { static const bool value = true; }; | |
951 | |
952 | |
953 | |
954 template<typename T1> | |
955 struct is_complex_float | |
956 { static const bool value = false; }; | |
957 | |
958 template<> | |
959 struct is_complex_float< std::complex<float> > | |
960 { static const bool value = true; }; | |
961 | |
962 | |
963 | |
964 template<typename T1> | |
965 struct is_complex_double | |
966 { static const bool value = false; }; | |
967 | |
968 template<> | |
969 struct is_complex_double< std::complex<double> > | |
970 { static const bool value = true; }; | |
971 | |
972 | |
973 | |
974 template<typename T1> | |
975 struct is_complex_strict | |
976 { static const bool value = false; }; | |
977 | |
978 template<> | |
979 struct is_complex_strict< std::complex<float> > | |
980 { static const bool value = true; }; | |
981 | |
982 template<> | |
983 struct is_complex_strict< std::complex<double> > | |
984 { static const bool value = true; }; | |
985 | |
986 | |
987 | |
988 //! check for a weird implementation of the std::complex class | |
989 template<typename T1> | |
990 struct is_supported_complex | |
991 { static const bool value = false; }; | |
992 | |
993 //template<> | |
994 template<typename eT> | |
995 struct is_supported_complex< std::complex<eT> > | |
996 { static const bool value = ( sizeof(std::complex<eT>) == 2*sizeof(eT) ); }; | |
997 | |
998 | |
999 | |
1000 template<typename T1> | |
1001 struct is_supported_complex_float | |
1002 { static const bool value = false; }; | |
1003 | |
1004 template<> | |
1005 struct is_supported_complex_float< std::complex<float> > | |
1006 { static const bool value = ( sizeof(std::complex<float>) == 2*sizeof(float) ); }; | |
1007 | |
1008 | |
1009 | |
1010 template<typename T1> | |
1011 struct is_supported_complex_double | |
1012 { static const bool value = false; }; | |
1013 | |
1014 template<> | |
1015 struct is_supported_complex_double< std::complex<double> > | |
1016 { static const bool value = ( sizeof(std::complex<double>) == 2*sizeof(double) ); }; | |
1017 | |
1018 | |
1019 | |
1020 template<typename T1> | |
1021 struct is_supported_elem_type | |
1022 { | |
1023 static const bool value = \ | |
1024 is_u8<T1>::value || | |
1025 is_s8<T1>::value || | |
1026 is_u16<T1>::value || | |
1027 is_s16<T1>::value || | |
1028 is_u32<T1>::value || | |
1029 is_s32<T1>::value || | |
1030 #if defined(ARMA_USE_U64S64) | |
1031 is_u64<T1>::value || | |
1032 is_s64<T1>::value || | |
1033 #endif | |
1034 #if defined(ARMA_ALLOW_LONG) | |
1035 is_ulng_t<T1>::value || | |
1036 is_slng_t<T1>::value || | |
1037 #endif | |
1038 is_float<T1>::value || | |
1039 is_double<T1>::value || | |
1040 is_supported_complex_float<T1>::value || | |
1041 is_supported_complex_double<T1>::value; | |
1042 }; | |
1043 | |
1044 | |
1045 | |
1046 template<typename T1> | |
1047 struct is_supported_blas_type | |
1048 { | |
1049 static const bool value = \ | |
1050 is_float<T1>::value || | |
1051 is_double<T1>::value || | |
1052 is_supported_complex_float<T1>::value || | |
1053 is_supported_complex_double<T1>::value; | |
1054 }; | |
1055 | |
1056 | |
1057 | |
1058 template<typename T> | |
1059 struct is_signed | |
1060 { | |
1061 static const bool value = true; | |
1062 }; | |
1063 | |
1064 | |
1065 template<> struct is_signed<u8> { static const bool value = false; }; | |
1066 template<> struct is_signed<u16> { static const bool value = false; }; | |
1067 template<> struct is_signed<u32> { static const bool value = false; }; | |
1068 #if defined(ARMA_USE_U64S64) | |
1069 template<> struct is_signed<u64> { static const bool value = false; }; | |
1070 #endif | |
1071 #if defined(ARMA_ALLOW_LONG) | |
1072 template<> struct is_signed<ulng_t> { static const bool value = false; }; | |
1073 #endif | |
1074 | |
1075 | |
1076 template<typename T> | |
1077 struct is_non_integral | |
1078 { | |
1079 static const bool value = false; | |
1080 }; | |
1081 | |
1082 | |
1083 template<> struct is_non_integral< float > { static const bool value = true; }; | |
1084 template<> struct is_non_integral< double > { static const bool value = true; }; | |
1085 template<> struct is_non_integral< std::complex<float> > { static const bool value = true; }; | |
1086 template<> struct is_non_integral< std::complex<double> > { static const bool value = true; }; | |
1087 | |
1088 | |
1089 | |
1090 | |
1091 // | |
1092 | |
1093 class arma_junk_class; | |
1094 | |
1095 template<typename T1, typename T2> | |
1096 struct force_different_type | |
1097 { | |
1098 typedef T1 T1_result; | |
1099 typedef T2 T2_result; | |
1100 }; | |
1101 | |
1102 | |
1103 template<typename T1> | |
1104 struct force_different_type<T1,T1> | |
1105 { | |
1106 typedef T1 T1_result; | |
1107 typedef arma_junk_class T2_result; | |
1108 }; | |
1109 | |
1110 | |
1111 | |
1112 // | |
1113 | |
1114 | |
1115 template<typename T1> | |
1116 struct resolves_to_vector_default { static const bool value = false; }; | |
1117 | |
1118 template<typename T1> | |
1119 struct resolves_to_vector_test { static const bool value = T1::is_col || T1::is_row; }; | |
1120 | |
1121 | |
1122 template<typename T1, bool condition> | |
1123 struct resolves_to_vector_redirect {}; | |
1124 | |
1125 template<typename T1> | |
1126 struct resolves_to_vector_redirect<T1, false> { typedef resolves_to_vector_default<T1> result; }; | |
1127 | |
1128 template<typename T1> | |
1129 struct resolves_to_vector_redirect<T1, true> { typedef resolves_to_vector_test<T1> result; }; | |
1130 | |
1131 | |
1132 template<typename T1> | |
1133 struct resolves_to_vector : public resolves_to_vector_redirect<T1, is_arma_type<T1>::value>::result {}; | |
1134 | |
1135 template<typename T1> | |
1136 struct resolves_to_sparse_vector : public resolves_to_vector_redirect<T1, is_arma_sparse_type<T1>::value>::result {}; | |
1137 | |
1138 | |
1139 | |
1140 template<typename glue_type> struct is_glue_mixed_times { static const bool value = false; }; | |
1141 template<> struct is_glue_mixed_times<glue_mixed_times> { static const bool value = true; }; | |
1142 | |
1143 | |
1144 | |
1145 template<typename glue_type> struct is_glue_mixed_elem { static const bool value = false; }; | |
1146 | |
1147 template<> struct is_glue_mixed_elem<glue_mixed_plus> { static const bool value = true; }; | |
1148 template<> struct is_glue_mixed_elem<glue_mixed_minus> { static const bool value = true; }; | |
1149 template<> struct is_glue_mixed_elem<glue_mixed_div> { static const bool value = true; }; | |
1150 template<> struct is_glue_mixed_elem<glue_mixed_schur> { static const bool value = true; }; | |
1151 | |
1152 template<> struct is_glue_mixed_elem<glue_rel_lt> { static const bool value = true; }; | |
1153 template<> struct is_glue_mixed_elem<glue_rel_gt> { static const bool value = true; }; | |
1154 template<> struct is_glue_mixed_elem<glue_rel_lteq> { static const bool value = true; }; | |
1155 template<> struct is_glue_mixed_elem<glue_rel_gteq> { static const bool value = true; }; | |
1156 template<> struct is_glue_mixed_elem<glue_rel_eq> { static const bool value = true; }; | |
1157 template<> struct is_glue_mixed_elem<glue_rel_noteq> { static const bool value = true; }; | |
1158 | |
1159 | |
1160 | |
1161 template<typename op_type> struct is_op_mixed_elem { static const bool value = false; }; | |
1162 | |
1163 template<> struct is_op_mixed_elem<op_cx_scalar_times> { static const bool value = true; }; | |
1164 template<> struct is_op_mixed_elem<op_cx_scalar_plus> { static const bool value = true; }; | |
1165 template<> struct is_op_mixed_elem<op_cx_scalar_minus_pre> { static const bool value = true; }; | |
1166 template<> struct is_op_mixed_elem<op_cx_scalar_minus_post> { static const bool value = true; }; | |
1167 template<> struct is_op_mixed_elem<op_cx_scalar_div_pre> { static const bool value = true; }; | |
1168 template<> struct is_op_mixed_elem<op_cx_scalar_div_post> { static const bool value = true; }; | |
1169 | |
1170 template<> struct is_op_mixed_elem<op_rel_lt_pre> { static const bool value = true; }; | |
1171 template<> struct is_op_mixed_elem<op_rel_lt_post> { static const bool value = true; }; | |
1172 template<> struct is_op_mixed_elem<op_rel_gt_pre> { static const bool value = true; }; | |
1173 template<> struct is_op_mixed_elem<op_rel_gt_post> { static const bool value = true; }; | |
1174 template<> struct is_op_mixed_elem<op_rel_lteq_pre> { static const bool value = true; }; | |
1175 template<> struct is_op_mixed_elem<op_rel_lteq_post> { static const bool value = true; }; | |
1176 template<> struct is_op_mixed_elem<op_rel_gteq_pre> { static const bool value = true; }; | |
1177 template<> struct is_op_mixed_elem<op_rel_gteq_post> { static const bool value = true; }; | |
1178 template<> struct is_op_mixed_elem<op_rel_eq> { static const bool value = true; }; | |
1179 template<> struct is_op_mixed_elem<op_rel_noteq> { static const bool value = true; }; | |
1180 | |
1181 | |
1182 | |
1183 template<typename spop_type> struct is_spop_elem { static const bool value = false; }; | |
1184 template<> struct is_spop_elem<spop_scalar_times> { static const bool value = true; }; | |
1185 | |
1186 | |
1187 template<typename spglue_type> struct is_spglue_elem { static const bool value = false; }; | |
1188 template<> struct is_spglue_elem<spglue_plus> { static const bool value = true; }; | |
1189 template<> struct is_spglue_elem<spglue_plus2> { static const bool value = true; }; | |
1190 template<> struct is_spglue_elem<spglue_minus> { static const bool value = true; }; | |
1191 template<> struct is_spglue_elem<spglue_minus2> { static const bool value = true; }; | |
1192 | |
1193 | |
1194 template<typename spglue_type> struct is_spglue_times { static const bool value = false; }; | |
1195 template<> struct is_spglue_times<spglue_times> { static const bool value = true; }; | |
1196 | |
1197 | |
1198 template<typename spglue_type> struct is_spglue_times2 { static const bool value = false; }; | |
1199 template<> struct is_spglue_times<spglue_times2> { static const bool value = true; }; | |
1200 | |
1201 | |
1202 | |
1203 //! @} |