go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkOpenCLOstreamSupport.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 //
19 // \author Denis P. Shamonin and Marius Staring. Division of Image Processing,
20 // Department of Radiology, Leiden, The Netherlands
21 //
22 // \note This work was funded by the Netherlands Organisation for
23 // Scientific Research (NWO NRG-2010.02 and NWO 639.021.124).
24 //
25 
26 #ifndef __itkOpenCLOstreamSupport_h
27 #define __itkOpenCLOstreamSupport_h
28 
29 #include "itkOpenCL.h"
30 
31 #include <ostream>
32 #include <iomanip>
33 
34 //------------------------------------------------------------------------------
35 // uchar
36 namespace itk
37 {
38 template< typename ucharT, typename traits >
39 inline
40 std::basic_ostream< ucharT, traits > &
42  std::basic_ostream< ucharT, traits > & strm,
43  const cl_uchar & _v )
44 {
45  strm << "(uchar)(" << _v << ")";
46  return strm;
47 }
48 
49 
50 template< typename ucharT, typename traits >
51 inline
52 std::basic_ostream< ucharT, traits > &
54  std::basic_ostream< ucharT, traits > & strm,
55  const cl_uchar2 & _v )
56 {
57  strm << "(uchar2)(";
58  for( unsigned int i = 0; i < 2; ++i )
59  {
60  strm << _v.s[ i ];
61  if( i != 1 ) { strm << ", "; }
62  }
63  strm << ")";
64  return strm;
65 }
66 
67 
68 template< typename ucharT, typename traits >
69 inline
70 std::basic_ostream< ucharT, traits > &
72  std::basic_ostream< ucharT, traits > & strm,
73  const cl_uchar4 & _v )
74 {
75  strm << "(uchar4)(";
76  for( unsigned int i = 0; i < 4; ++i )
77  {
78  strm << _v.s[ i ];
79  if( i != 3 ) { strm << ", "; }
80  }
81  strm << ")";
82  return strm;
83 }
84 
85 
86 template< typename ucharT, typename traits >
87 inline
88 std::basic_ostream< ucharT, traits > &
90  std::basic_ostream< ucharT, traits > & strm,
91  const cl_uchar8 & _v )
92 {
93  strm << "(uchar8)(";
94  for( unsigned int i = 0; i < 8; ++i )
95  {
96  strm << _v.s[ i ];
97  if( i != 7 ) { strm << ", "; }
98  }
99  strm << ")";
100  return strm;
101 }
102 
103 
104 template< typename ucharT, typename traits >
105 inline
106 std::basic_ostream< ucharT, traits > &
108  std::basic_ostream< ucharT, traits > & strm,
109  const cl_uchar16 & _v )
110 {
111  strm << "(uchar16)(";
112  for( unsigned int i = 0; i < 16; ++i )
113  {
114  strm << _v.s[ i ];
115  if( i != 15 ) { strm << ", "; }
116  }
117  strm << ")";
118  return strm;
119 }
120 
121 
122 //------------------------------------------------------------------------------
123 // char
124 template< typename charT, typename traits >
125 inline
126 std::basic_ostream< charT, traits > &
128  std::basic_ostream< charT, traits > & strm,
129  const cl_char & _v )
130 {
131  strm << "(char)(" << _v << ")";
132  return strm;
133 }
134 
135 
136 template< typename charT, typename traits >
137 inline
138 std::basic_ostream< charT, traits > &
140  std::basic_ostream< charT, traits > & strm,
141  const cl_char2 & _v )
142 {
143  strm << "(char2)(";
144  for( unsigned int i = 0; i < 2; ++i )
145  {
146  strm << _v.s[ i ];
147  if( i != 1 ) { strm << ", "; }
148  }
149  strm << ")";
150  return strm;
151 }
152 
153 
154 template< typename charT, typename traits >
155 inline
156 std::basic_ostream< charT, traits > &
158  std::basic_ostream< charT, traits > & strm,
159  const cl_char4 & _v )
160 {
161  strm << "(char4)(";
162  for( unsigned int i = 0; i < 4; ++i )
163  {
164  strm << _v.s[ i ];
165  if( i != 3 ) { strm << ", "; }
166  }
167  strm << ")";
168  return strm;
169 }
170 
171 
172 template< typename charT, typename traits >
173 inline
174 std::basic_ostream< charT, traits > &
176  std::basic_ostream< charT, traits > & strm,
177  const cl_char8 & _v )
178 {
179  strm << "(char8)(";
180  for( unsigned int i = 0; i < 8; ++i )
181  {
182  strm << _v.s[ i ];
183  if( i != 7 ) { strm << ", "; }
184  }
185  strm << ")";
186  return strm;
187 }
188 
189 
190 template< typename charT, typename traits >
191 inline
192 std::basic_ostream< charT, traits > &
194  std::basic_ostream< charT, traits > & strm,
195  const cl_char16 & _v )
196 {
197  strm << "(char16)(";
198  for( unsigned int i = 0; i < 16; ++i )
199  {
200  strm << _v.s[ i ];
201  if( i != 15 ) { strm << ", "; }
202  }
203  strm << ")";
204  return strm;
205 }
206 
207 
208 //------------------------------------------------------------------------------
209 // ushort
210 template< typename ushortT, typename traits >
211 inline
212 std::basic_ostream< ushortT, traits > &
214  std::basic_ostream< ushortT, traits > & strm,
215  const cl_ushort & _v )
216 {
217  strm << "(ushort)(" << _v << ")";
218  return strm;
219 }
220 
221 
222 template< typename ushortT, typename traits >
223 inline
224 std::basic_ostream< ushortT, traits > &
226  std::basic_ostream< ushortT, traits > & strm,
227  const cl_ushort2 & _v )
228 {
229  strm << "(ushort2)(";
230  for( unsigned int i = 0; i < 2; ++i )
231  {
232  strm << _v.s[ i ];
233  if( i != 1 ) { strm << ", "; }
234  }
235  strm << ")";
236  return strm;
237 }
238 
239 
240 template< typename ushortT, typename traits >
241 inline
242 std::basic_ostream< ushortT, traits > &
244  std::basic_ostream< ushortT, traits > & strm,
245  const cl_ushort4 & _v )
246 {
247  strm << "(ushort4)(";
248  for( unsigned int i = 0; i < 4; ++i )
249  {
250  strm << _v.s[ i ];
251  if( i != 3 ) { strm << ", "; }
252  }
253  strm << ")";
254  return strm;
255 }
256 
257 
258 template< typename ushortT, typename traits >
259 inline
260 std::basic_ostream< ushortT, traits > &
262  std::basic_ostream< ushortT, traits > & strm,
263  const cl_ushort8 & _v )
264 {
265  strm << "(ushort8)(";
266  for( unsigned int i = 0; i < 8; ++i )
267  {
268  strm << _v.s[ i ];
269  if( i != 7 ) { strm << ", "; }
270  }
271  strm << ")";
272  return strm;
273 }
274 
275 
276 template< typename ushortT, typename traits >
277 inline
278 std::basic_ostream< ushortT, traits > &
280  std::basic_ostream< ushortT, traits > & strm,
281  const cl_ushort16 & _v )
282 {
283  strm << "(ushort16)(";
284  for( unsigned int i = 0; i < 16; ++i )
285  {
286  strm << _v.s[ i ];
287  if( i != 15 ) { strm << ", "; }
288  }
289  strm << ")";
290  return strm;
291 }
292 
293 
294 //------------------------------------------------------------------------------
295 // short
296 template< typename shortT, typename traits >
297 inline
298 std::basic_ostream< shortT, traits > &
300  std::basic_ostream< shortT, traits > & strm,
301  const cl_short & _v )
302 {
303  strm << "(short)(" << _v << ")";
304  return strm;
305 }
306 
307 
308 template< typename shortT, typename traits >
309 inline
310 std::basic_ostream< shortT, traits > &
312  std::basic_ostream< shortT, traits > & strm,
313  const cl_short2 & _v )
314 {
315  strm << "(short2)(";
316  for( unsigned int i = 0; i < 2; ++i )
317  {
318  strm << _v.s[ i ];
319  if( i != 1 ) { strm << ", "; }
320  }
321  strm << ")";
322  return strm;
323 }
324 
325 
326 template< typename shortT, typename traits >
327 inline
328 std::basic_ostream< shortT, traits > &
330  std::basic_ostream< shortT, traits > & strm,
331  const cl_short4 & _v )
332 {
333  strm << "(short4)(";
334  for( unsigned int i = 0; i < 4; ++i )
335  {
336  strm << _v.s[ i ];
337  if( i != 3 ) { strm << ", "; }
338  }
339  strm << ")";
340  return strm;
341 }
342 
343 
344 template< typename shortT, typename traits >
345 inline
346 std::basic_ostream< shortT, traits > &
348  std::basic_ostream< shortT, traits > & strm,
349  const cl_short8 & _v )
350 {
351  strm << "(short8)(";
352  for( unsigned int i = 0; i < 8; ++i )
353  {
354  strm << _v.s[ i ];
355  if( i != 7 ) { strm << ", "; }
356  }
357  strm << ")";
358  return strm;
359 }
360 
361 
362 template< typename shortT, typename traits >
363 inline
364 std::basic_ostream< shortT, traits > &
366  std::basic_ostream< shortT, traits > & strm,
367  const cl_short16 & _v )
368 {
369  strm << "(short16)(";
370  for( unsigned int i = 0; i < 16; ++i )
371  {
372  strm << _v.s[ i ];
373  if( i != 15 ) { strm << ", "; }
374  }
375  strm << ")";
376  return strm;
377 }
378 
379 
380 //------------------------------------------------------------------------------
381 // uint
382 template< typename charT, typename traits >
383 inline
384 std::basic_ostream< charT, traits > &
386  std::basic_ostream< charT, traits > & strm,
387  const cl_uint & _v )
388 {
389  strm << "(uint)(" << _v << ")";
390  return strm;
391 }
392 
393 
394 template< typename charT, typename traits >
395 inline
396 std::basic_ostream< charT, traits > &
398  std::basic_ostream< charT, traits > & strm,
399  const cl_uint2 & _v )
400 {
401  strm << "(uint2)(";
402  for( unsigned int i = 0; i < 2; ++i )
403  {
404  strm << _v.s[ i ];
405  if( i != 1 ) { strm << ", "; }
406  }
407  strm << ")";
408  return strm;
409 }
410 
411 
412 template< typename charT, typename traits >
413 inline
414 std::basic_ostream< charT, traits > &
416  std::basic_ostream< charT, traits > & strm,
417  const cl_uint4 & _v )
418 {
419  strm << "(uint4)(";
420  for( unsigned int i = 0; i < 4; ++i )
421  {
422  strm << _v.s[ i ];
423  if( i != 3 ) { strm << ", "; }
424  }
425  strm << ")";
426  return strm;
427 }
428 
429 
430 template< typename charT, typename traits >
431 inline
432 std::basic_ostream< charT, traits > &
434  std::basic_ostream< charT, traits > & strm,
435  const cl_uint8 & _v )
436 {
437  strm << "(uint8)(";
438  for( unsigned int i = 0; i < 8; ++i )
439  {
440  strm << _v.s[ i ];
441  if( i != 7 ) { strm << ", "; }
442  }
443  strm << ")";
444  return strm;
445 }
446 
447 
448 template< typename charT, typename traits >
449 inline
450 std::basic_ostream< charT, traits > &
452  std::basic_ostream< charT, traits > & strm,
453  const cl_uint16 & _v )
454 {
455  strm << "(uint16)(";
456  for( unsigned int i = 0; i < 16; ++i )
457  {
458  strm << _v.s[ i ];
459  if( i != 15 ) { strm << ", "; }
460  }
461  strm << ")";
462  return strm;
463 }
464 
465 
466 //------------------------------------------------------------------------------
467 // int
468 template< typename charT, typename traits >
469 inline
470 std::basic_ostream< charT, traits > &
472  std::basic_ostream< charT, traits > & strm,
473  const cl_int & _v )
474 {
475  strm << "(int)(" << _v << ")";
476  return strm;
477 }
478 
479 
480 template< typename charT, typename traits >
481 inline
482 std::basic_ostream< charT, traits > &
484  std::basic_ostream< charT, traits > & strm,
485  const cl_int2 & _v )
486 {
487  strm << "(int2)(";
488  for( unsigned int i = 0; i < 2; ++i )
489  {
490  strm << _v.s[ i ];
491  if( i != 1 ) { strm << ", "; }
492  }
493  strm << ")";
494  return strm;
495 }
496 
497 
498 template< typename charT, typename traits >
499 inline
500 std::basic_ostream< charT, traits > &
502  std::basic_ostream< charT, traits > & strm,
503  const cl_int4 & _v )
504 {
505  strm << "(int4)(";
506  for( unsigned int i = 0; i < 4; ++i )
507  {
508  strm << _v.s[ i ];
509  if( i != 3 ) { strm << ", "; }
510  }
511  strm << ")";
512  return strm;
513 }
514 
515 
516 template< typename charT, typename traits >
517 inline
518 std::basic_ostream< charT, traits > &
520  std::basic_ostream< charT, traits > & strm,
521  const cl_int8 & _v )
522 {
523  strm << "(int8)(";
524  for( unsigned int i = 0; i < 8; ++i )
525  {
526  strm << _v.s[ i ];
527  if( i != 7 ) { strm << ", "; }
528  }
529  strm << ")";
530  return strm;
531 }
532 
533 
534 template< typename charT, typename traits >
535 inline
536 std::basic_ostream< charT, traits > &
538  std::basic_ostream< charT, traits > & strm,
539  const cl_int16 & _v )
540 {
541  strm << "(int16)(";
542  for( unsigned int i = 0; i < 16; ++i )
543  {
544  strm << _v.s[ i ];
545  if( i != 15 ) { strm << ", "; }
546  }
547  strm << ")";
548  return strm;
549 }
550 
551 
552 //------------------------------------------------------------------------------
553 // ulong
554 template< typename ulongT, typename traits >
555 inline
556 std::basic_ostream< ulongT, traits > &
558  std::basic_ostream< ulongT, traits > & strm,
559  const cl_ulong & _v )
560 {
561  strm << "(ulong)(" << _v << ")";
562  return strm;
563 }
564 
565 
566 template< typename ulongT, typename traits >
567 inline
568 std::basic_ostream< ulongT, traits > &
570  std::basic_ostream< ulongT, traits > & strm,
571  const cl_ulong2 & _v )
572 {
573  strm << "(ulong2)(";
574  for( unsigned int i = 0; i < 2; ++i )
575  {
576  strm << _v.s[ i ];
577  if( i != 1 ) { strm << ", "; }
578  }
579  strm << ")";
580  return strm;
581 }
582 
583 
584 template< typename ulongT, typename traits >
585 inline
586 std::basic_ostream< ulongT, traits > &
588  std::basic_ostream< ulongT, traits > & strm,
589  const cl_ulong4 & _v )
590 {
591  strm << "(ulong4)(";
592  for( unsigned int i = 0; i < 4; ++i )
593  {
594  strm << _v.s[ i ];
595  if( i != 3 ) { strm << ", "; }
596  }
597  strm << ")";
598  return strm;
599 }
600 
601 
602 template< typename ulongT, typename traits >
603 inline
604 std::basic_ostream< ulongT, traits > &
606  std::basic_ostream< ulongT, traits > & strm,
607  const cl_ulong8 & _v )
608 {
609  strm << "(ulong8)(";
610  for( unsigned int i = 0; i < 8; ++i )
611  {
612  strm << _v.s[ i ];
613  if( i != 7 ) { strm << ", "; }
614  }
615  strm << ")";
616  return strm;
617 }
618 
619 
620 template< typename ulongT, typename traits >
621 inline
622 std::basic_ostream< ulongT, traits > &
624  std::basic_ostream< ulongT, traits > & strm,
625  const cl_ulong16 & _v )
626 {
627  strm << "(ulong16)(";
628  for( unsigned int i = 0; i < 16; ++i )
629  {
630  strm << _v.s[ i ];
631  if( i != 15 ) { strm << ", "; }
632  }
633  strm << ")";
634  return strm;
635 }
636 
637 
638 //------------------------------------------------------------------------------
639 // long
640 template< typename longT, typename traits >
641 inline
642 std::basic_ostream< longT, traits > &
644  std::basic_ostream< longT, traits > & strm,
645  const cl_long & _v )
646 {
647  strm << "(long)(" << _v << ")";
648  return strm;
649 }
650 
651 
652 template< typename longT, typename traits >
653 inline
654 std::basic_ostream< longT, traits > &
656  std::basic_ostream< longT, traits > & strm,
657  const cl_long2 & _v )
658 {
659  strm << "(long2)(";
660  for( unsigned int i = 0; i < 2; ++i )
661  {
662  strm << _v.s[ i ];
663  if( i != 1 ) { strm << ", "; }
664  }
665  strm << ")";
666  return strm;
667 }
668 
669 
670 template< typename longT, typename traits >
671 inline
672 std::basic_ostream< longT, traits > &
674  std::basic_ostream< longT, traits > & strm,
675  const cl_long4 & _v )
676 {
677  strm << "(long4)(";
678  for( unsigned int i = 0; i < 4; ++i )
679  {
680  strm << _v.s[ i ];
681  if( i != 3 ) { strm << ", "; }
682  }
683  strm << ")";
684  return strm;
685 }
686 
687 
688 template< typename longT, typename traits >
689 inline
690 std::basic_ostream< longT, traits > &
692  std::basic_ostream< longT, traits > & strm,
693  const cl_long8 & _v )
694 {
695  strm << "(long8)(";
696  for( unsigned int i = 0; i < 8; ++i )
697  {
698  strm << _v.s[ i ];
699  if( i != 7 ) { strm << ", "; }
700  }
701  strm << ")";
702  return strm;
703 }
704 
705 
706 template< typename longT, typename traits >
707 inline
708 std::basic_ostream< longT, traits > &
710  std::basic_ostream< longT, traits > & strm,
711  const cl_long16 & _v )
712 {
713  strm << "(long16)(";
714  for( unsigned int i = 0; i < 16; ++i )
715  {
716  strm << _v.s[ i ];
717  if( i != 15 ) { strm << ", "; }
718  }
719  strm << ")";
720  return strm;
721 }
722 
723 
724 //------------------------------------------------------------------------------
725 // float
726 template< typename charT, typename traits >
727 inline
728 std::basic_ostream< charT, traits > &
730  std::basic_ostream< charT, traits > & strm,
731  const cl_float & _v )
732 {
733  strm << "(float)(" << _v << ")";
734  return strm;
735 }
736 
737 
738 template< typename charT, typename traits >
739 inline
740 std::basic_ostream< charT, traits > &
742  std::basic_ostream< charT, traits > & strm,
743  const cl_float2 & _v )
744 {
745  strm << "(float2)(";
746  for( unsigned int i = 0; i < 2; ++i )
747  {
748  strm << std::fixed << std::setprecision( 8 ) << _v.s[ i ];
749  if( i != 1 ) { strm << ", "; }
750  }
751  strm << ")";
752  return strm;
753 }
754 
755 
756 template< typename charT, typename traits >
757 inline
758 std::basic_ostream< charT, traits > &
760  std::basic_ostream< charT, traits > & strm,
761  const cl_float4 & _v )
762 {
763  strm << "(float4)(";
764  for( unsigned int i = 0; i < 4; ++i )
765  {
766  strm << std::fixed << std::setprecision( 8 ) << _v.s[ i ];
767  if( i != 3 ) { strm << ", "; }
768  }
769  strm << ")";
770  return strm;
771 }
772 
773 
774 template< typename charT, typename traits >
775 inline
776 std::basic_ostream< charT, traits > &
778  std::basic_ostream< charT, traits > & strm,
779  const cl_float8 & _v )
780 {
781  strm << "(float8)(";
782  for( unsigned int i = 0; i < 8; ++i )
783  {
784  strm << std::fixed << std::setprecision( 8 ) << _v.s[ i ];
785  if( i != 7 ) { strm << ", "; }
786  }
787  strm << ")";
788  return strm;
789 }
790 
791 
792 template< typename charT, typename traits >
793 inline
794 std::basic_ostream< charT, traits > &
796  std::basic_ostream< charT, traits > & strm,
797  const cl_float16 & _v )
798 {
799  strm << "(float16)(";
800  for( unsigned int i = 0; i < 16; ++i )
801  {
802  strm << std::fixed << std::setprecision( 8 ) << _v.s[ i ];
803  if( i != 15 ) { strm << ", "; }
804  }
805  strm << ")";
806  return strm;
807 }
808 
809 
810 } // end namespace itk
811 
812 #endif // /* __itkOpenCLOstreamSupport_h */
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo