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
36namespace itk
37{
38template <typename ucharT, typename traits>
39inline std::basic_ostream<ucharT, traits> &
40operator<<(std::basic_ostream<ucharT, traits> & strm, const cl_uchar & _v)
41{
42 strm << "(uchar)(" << _v << ")";
43 return strm;
44}
45
46
47template <typename ucharT, typename traits>
48inline std::basic_ostream<ucharT, traits> &
49operator<<(std::basic_ostream<ucharT, traits> & strm, const cl_uchar2 & _v)
50{
51 strm << "(uchar2)(";
52 for (unsigned int i = 0; i < 2; ++i)
53 {
54 strm << _v.s[i];
55 if (i != 1)
56 {
57 strm << ", ";
58 }
59 }
60 strm << ")";
61 return strm;
62}
63
64
65template <typename ucharT, typename traits>
66inline std::basic_ostream<ucharT, traits> &
67operator<<(std::basic_ostream<ucharT, traits> & strm, const cl_uchar4 & _v)
68{
69 strm << "(uchar4)(";
70 for (unsigned int i = 0; i < 4; ++i)
71 {
72 strm << _v.s[i];
73 if (i != 3)
74 {
75 strm << ", ";
76 }
77 }
78 strm << ")";
79 return strm;
80}
81
82
83template <typename ucharT, typename traits>
84inline std::basic_ostream<ucharT, traits> &
85operator<<(std::basic_ostream<ucharT, traits> & strm, const cl_uchar8 & _v)
86{
87 strm << "(uchar8)(";
88 for (unsigned int i = 0; i < 8; ++i)
89 {
90 strm << _v.s[i];
91 if (i != 7)
92 {
93 strm << ", ";
94 }
95 }
96 strm << ")";
97 return strm;
98}
99
100
101template <typename ucharT, typename traits>
102inline std::basic_ostream<ucharT, traits> &
103operator<<(std::basic_ostream<ucharT, traits> & strm, const cl_uchar16 & _v)
104{
105 strm << "(uchar16)(";
106 for (unsigned int i = 0; i < 16; ++i)
107 {
108 strm << _v.s[i];
109 if (i != 15)
110 {
111 strm << ", ";
112 }
113 }
114 strm << ")";
115 return strm;
116}
117
118
119//------------------------------------------------------------------------------
120// char
121template <typename charT, typename traits>
122inline std::basic_ostream<charT, traits> &
123operator<<(std::basic_ostream<charT, traits> & strm, const cl_char & _v)
124{
125 strm << "(char)(" << _v << ")";
126 return strm;
127}
128
129
130template <typename charT, typename traits>
131inline std::basic_ostream<charT, traits> &
132operator<<(std::basic_ostream<charT, traits> & strm, const cl_char2 & _v)
133{
134 strm << "(char2)(";
135 for (unsigned int i = 0; i < 2; ++i)
136 {
137 strm << _v.s[i];
138 if (i != 1)
139 {
140 strm << ", ";
141 }
142 }
143 strm << ")";
144 return strm;
145}
146
147
148template <typename charT, typename traits>
149inline std::basic_ostream<charT, traits> &
150operator<<(std::basic_ostream<charT, traits> & strm, const cl_char4 & _v)
151{
152 strm << "(char4)(";
153 for (unsigned int i = 0; i < 4; ++i)
154 {
155 strm << _v.s[i];
156 if (i != 3)
157 {
158 strm << ", ";
159 }
160 }
161 strm << ")";
162 return strm;
163}
164
165
166template <typename charT, typename traits>
167inline std::basic_ostream<charT, traits> &
168operator<<(std::basic_ostream<charT, traits> & strm, const cl_char8 & _v)
169{
170 strm << "(char8)(";
171 for (unsigned int i = 0; i < 8; ++i)
172 {
173 strm << _v.s[i];
174 if (i != 7)
175 {
176 strm << ", ";
177 }
178 }
179 strm << ")";
180 return strm;
181}
182
183
184template <typename charT, typename traits>
185inline std::basic_ostream<charT, traits> &
186operator<<(std::basic_ostream<charT, traits> & strm, const cl_char16 & _v)
187{
188 strm << "(char16)(";
189 for (unsigned int i = 0; i < 16; ++i)
190 {
191 strm << _v.s[i];
192 if (i != 15)
193 {
194 strm << ", ";
195 }
196 }
197 strm << ")";
198 return strm;
199}
200
201
202//------------------------------------------------------------------------------
203// ushort
204template <typename ushortT, typename traits>
205inline std::basic_ostream<ushortT, traits> &
206operator<<(std::basic_ostream<ushortT, traits> & strm, const cl_ushort & _v)
207{
208 strm << "(ushort)(" << _v << ")";
209 return strm;
210}
211
212
213template <typename ushortT, typename traits>
214inline std::basic_ostream<ushortT, traits> &
215operator<<(std::basic_ostream<ushortT, traits> & strm, const cl_ushort2 & _v)
216{
217 strm << "(ushort2)(";
218 for (unsigned int i = 0; i < 2; ++i)
219 {
220 strm << _v.s[i];
221 if (i != 1)
222 {
223 strm << ", ";
224 }
225 }
226 strm << ")";
227 return strm;
228}
229
230
231template <typename ushortT, typename traits>
232inline std::basic_ostream<ushortT, traits> &
233operator<<(std::basic_ostream<ushortT, traits> & strm, const cl_ushort4 & _v)
234{
235 strm << "(ushort4)(";
236 for (unsigned int i = 0; i < 4; ++i)
237 {
238 strm << _v.s[i];
239 if (i != 3)
240 {
241 strm << ", ";
242 }
243 }
244 strm << ")";
245 return strm;
246}
247
248
249template <typename ushortT, typename traits>
250inline std::basic_ostream<ushortT, traits> &
251operator<<(std::basic_ostream<ushortT, traits> & strm, const cl_ushort8 & _v)
252{
253 strm << "(ushort8)(";
254 for (unsigned int i = 0; i < 8; ++i)
255 {
256 strm << _v.s[i];
257 if (i != 7)
258 {
259 strm << ", ";
260 }
261 }
262 strm << ")";
263 return strm;
264}
265
266
267template <typename ushortT, typename traits>
268inline std::basic_ostream<ushortT, traits> &
269operator<<(std::basic_ostream<ushortT, traits> & strm, const cl_ushort16 & _v)
270{
271 strm << "(ushort16)(";
272 for (unsigned int i = 0; i < 16; ++i)
273 {
274 strm << _v.s[i];
275 if (i != 15)
276 {
277 strm << ", ";
278 }
279 }
280 strm << ")";
281 return strm;
282}
283
284
285//------------------------------------------------------------------------------
286// short
287template <typename shortT, typename traits>
288inline std::basic_ostream<shortT, traits> &
289operator<<(std::basic_ostream<shortT, traits> & strm, const cl_short & _v)
290{
291 strm << "(short)(" << _v << ")";
292 return strm;
293}
294
295
296template <typename shortT, typename traits>
297inline std::basic_ostream<shortT, traits> &
298operator<<(std::basic_ostream<shortT, traits> & strm, const cl_short2 & _v)
299{
300 strm << "(short2)(";
301 for (unsigned int i = 0; i < 2; ++i)
302 {
303 strm << _v.s[i];
304 if (i != 1)
305 {
306 strm << ", ";
307 }
308 }
309 strm << ")";
310 return strm;
311}
312
313
314template <typename shortT, typename traits>
315inline std::basic_ostream<shortT, traits> &
316operator<<(std::basic_ostream<shortT, traits> & strm, const cl_short4 & _v)
317{
318 strm << "(short4)(";
319 for (unsigned int i = 0; i < 4; ++i)
320 {
321 strm << _v.s[i];
322 if (i != 3)
323 {
324 strm << ", ";
325 }
326 }
327 strm << ")";
328 return strm;
329}
330
331
332template <typename shortT, typename traits>
333inline std::basic_ostream<shortT, traits> &
334operator<<(std::basic_ostream<shortT, traits> & strm, const cl_short8 & _v)
335{
336 strm << "(short8)(";
337 for (unsigned int i = 0; i < 8; ++i)
338 {
339 strm << _v.s[i];
340 if (i != 7)
341 {
342 strm << ", ";
343 }
344 }
345 strm << ")";
346 return strm;
347}
348
349
350template <typename shortT, typename traits>
351inline std::basic_ostream<shortT, traits> &
352operator<<(std::basic_ostream<shortT, traits> & strm, const cl_short16 & _v)
353{
354 strm << "(short16)(";
355 for (unsigned int i = 0; i < 16; ++i)
356 {
357 strm << _v.s[i];
358 if (i != 15)
359 {
360 strm << ", ";
361 }
362 }
363 strm << ")";
364 return strm;
365}
366
367
368//------------------------------------------------------------------------------
369// uint
370template <typename charT, typename traits>
371inline std::basic_ostream<charT, traits> &
372operator<<(std::basic_ostream<charT, traits> & strm, const cl_uint & _v)
373{
374 strm << "(uint)(" << _v << ")";
375 return strm;
376}
377
378
379template <typename charT, typename traits>
380inline std::basic_ostream<charT, traits> &
381operator<<(std::basic_ostream<charT, traits> & strm, const cl_uint2 & _v)
382{
383 strm << "(uint2)(";
384 for (unsigned int i = 0; i < 2; ++i)
385 {
386 strm << _v.s[i];
387 if (i != 1)
388 {
389 strm << ", ";
390 }
391 }
392 strm << ")";
393 return strm;
394}
395
396
397template <typename charT, typename traits>
398inline std::basic_ostream<charT, traits> &
399operator<<(std::basic_ostream<charT, traits> & strm, const cl_uint4 & _v)
400{
401 strm << "(uint4)(";
402 for (unsigned int i = 0; i < 4; ++i)
403 {
404 strm << _v.s[i];
405 if (i != 3)
406 {
407 strm << ", ";
408 }
409 }
410 strm << ")";
411 return strm;
412}
413
414
415template <typename charT, typename traits>
416inline std::basic_ostream<charT, traits> &
417operator<<(std::basic_ostream<charT, traits> & strm, const cl_uint8 & _v)
418{
419 strm << "(uint8)(";
420 for (unsigned int i = 0; i < 8; ++i)
421 {
422 strm << _v.s[i];
423 if (i != 7)
424 {
425 strm << ", ";
426 }
427 }
428 strm << ")";
429 return strm;
430}
431
432
433template <typename charT, typename traits>
434inline std::basic_ostream<charT, traits> &
435operator<<(std::basic_ostream<charT, traits> & strm, const cl_uint16 & _v)
436{
437 strm << "(uint16)(";
438 for (unsigned int i = 0; i < 16; ++i)
439 {
440 strm << _v.s[i];
441 if (i != 15)
442 {
443 strm << ", ";
444 }
445 }
446 strm << ")";
447 return strm;
448}
449
450
451//------------------------------------------------------------------------------
452// int
453template <typename charT, typename traits>
454inline std::basic_ostream<charT, traits> &
455operator<<(std::basic_ostream<charT, traits> & strm, const cl_int & _v)
456{
457 strm << "(int)(" << _v << ")";
458 return strm;
459}
460
461
462template <typename charT, typename traits>
463inline std::basic_ostream<charT, traits> &
464operator<<(std::basic_ostream<charT, traits> & strm, const cl_int2 & _v)
465{
466 strm << "(int2)(";
467 for (unsigned int i = 0; i < 2; ++i)
468 {
469 strm << _v.s[i];
470 if (i != 1)
471 {
472 strm << ", ";
473 }
474 }
475 strm << ")";
476 return strm;
477}
478
479
480template <typename charT, typename traits>
481inline std::basic_ostream<charT, traits> &
482operator<<(std::basic_ostream<charT, traits> & strm, const cl_int4 & _v)
483{
484 strm << "(int4)(";
485 for (unsigned int i = 0; i < 4; ++i)
486 {
487 strm << _v.s[i];
488 if (i != 3)
489 {
490 strm << ", ";
491 }
492 }
493 strm << ")";
494 return strm;
495}
496
497
498template <typename charT, typename traits>
499inline std::basic_ostream<charT, traits> &
500operator<<(std::basic_ostream<charT, traits> & strm, const cl_int8 & _v)
501{
502 strm << "(int8)(";
503 for (unsigned int i = 0; i < 8; ++i)
504 {
505 strm << _v.s[i];
506 if (i != 7)
507 {
508 strm << ", ";
509 }
510 }
511 strm << ")";
512 return strm;
513}
514
515
516template <typename charT, typename traits>
517inline std::basic_ostream<charT, traits> &
518operator<<(std::basic_ostream<charT, traits> & strm, const cl_int16 & _v)
519{
520 strm << "(int16)(";
521 for (unsigned int i = 0; i < 16; ++i)
522 {
523 strm << _v.s[i];
524 if (i != 15)
525 {
526 strm << ", ";
527 }
528 }
529 strm << ")";
530 return strm;
531}
532
533
534//------------------------------------------------------------------------------
535// ulong
536template <typename ulongT, typename traits>
537inline std::basic_ostream<ulongT, traits> &
538operator<<(std::basic_ostream<ulongT, traits> & strm, const cl_ulong & _v)
539{
540 strm << "(ulong)(" << _v << ")";
541 return strm;
542}
543
544
545template <typename ulongT, typename traits>
546inline std::basic_ostream<ulongT, traits> &
547operator<<(std::basic_ostream<ulongT, traits> & strm, const cl_ulong2 & _v)
548{
549 strm << "(ulong2)(";
550 for (unsigned int i = 0; i < 2; ++i)
551 {
552 strm << _v.s[i];
553 if (i != 1)
554 {
555 strm << ", ";
556 }
557 }
558 strm << ")";
559 return strm;
560}
561
562
563template <typename ulongT, typename traits>
564inline std::basic_ostream<ulongT, traits> &
565operator<<(std::basic_ostream<ulongT, traits> & strm, const cl_ulong4 & _v)
566{
567 strm << "(ulong4)(";
568 for (unsigned int i = 0; i < 4; ++i)
569 {
570 strm << _v.s[i];
571 if (i != 3)
572 {
573 strm << ", ";
574 }
575 }
576 strm << ")";
577 return strm;
578}
579
580
581template <typename ulongT, typename traits>
582inline std::basic_ostream<ulongT, traits> &
583operator<<(std::basic_ostream<ulongT, traits> & strm, const cl_ulong8 & _v)
584{
585 strm << "(ulong8)(";
586 for (unsigned int i = 0; i < 8; ++i)
587 {
588 strm << _v.s[i];
589 if (i != 7)
590 {
591 strm << ", ";
592 }
593 }
594 strm << ")";
595 return strm;
596}
597
598
599template <typename ulongT, typename traits>
600inline std::basic_ostream<ulongT, traits> &
601operator<<(std::basic_ostream<ulongT, traits> & strm, const cl_ulong16 & _v)
602{
603 strm << "(ulong16)(";
604 for (unsigned int i = 0; i < 16; ++i)
605 {
606 strm << _v.s[i];
607 if (i != 15)
608 {
609 strm << ", ";
610 }
611 }
612 strm << ")";
613 return strm;
614}
615
616
617//------------------------------------------------------------------------------
618// long
619template <typename longT, typename traits>
620inline std::basic_ostream<longT, traits> &
621operator<<(std::basic_ostream<longT, traits> & strm, const cl_long & _v)
622{
623 strm << "(long)(" << _v << ")";
624 return strm;
625}
626
627
628template <typename longT, typename traits>
629inline std::basic_ostream<longT, traits> &
630operator<<(std::basic_ostream<longT, traits> & strm, const cl_long2 & _v)
631{
632 strm << "(long2)(";
633 for (unsigned int i = 0; i < 2; ++i)
634 {
635 strm << _v.s[i];
636 if (i != 1)
637 {
638 strm << ", ";
639 }
640 }
641 strm << ")";
642 return strm;
643}
644
645
646template <typename longT, typename traits>
647inline std::basic_ostream<longT, traits> &
648operator<<(std::basic_ostream<longT, traits> & strm, const cl_long4 & _v)
649{
650 strm << "(long4)(";
651 for (unsigned int i = 0; i < 4; ++i)
652 {
653 strm << _v.s[i];
654 if (i != 3)
655 {
656 strm << ", ";
657 }
658 }
659 strm << ")";
660 return strm;
661}
662
663
664template <typename longT, typename traits>
665inline std::basic_ostream<longT, traits> &
666operator<<(std::basic_ostream<longT, traits> & strm, const cl_long8 & _v)
667{
668 strm << "(long8)(";
669 for (unsigned int i = 0; i < 8; ++i)
670 {
671 strm << _v.s[i];
672 if (i != 7)
673 {
674 strm << ", ";
675 }
676 }
677 strm << ")";
678 return strm;
679}
680
681
682template <typename longT, typename traits>
683inline std::basic_ostream<longT, traits> &
684operator<<(std::basic_ostream<longT, traits> & strm, const cl_long16 & _v)
685{
686 strm << "(long16)(";
687 for (unsigned int i = 0; i < 16; ++i)
688 {
689 strm << _v.s[i];
690 if (i != 15)
691 {
692 strm << ", ";
693 }
694 }
695 strm << ")";
696 return strm;
697}
698
699
700//------------------------------------------------------------------------------
701// float
702template <typename charT, typename traits>
703inline std::basic_ostream<charT, traits> &
704operator<<(std::basic_ostream<charT, traits> & strm, const cl_float & _v)
705{
706 strm << "(float)(" << _v << ")";
707 return strm;
708}
709
710
711template <typename charT, typename traits>
712inline std::basic_ostream<charT, traits> &
713operator<<(std::basic_ostream<charT, traits> & strm, const cl_float2 & _v)
714{
715 strm << "(float2)(";
716 for (unsigned int i = 0; i < 2; ++i)
717 {
718 strm << std::fixed << std::setprecision(8) << _v.s[i];
719 if (i != 1)
720 {
721 strm << ", ";
722 }
723 }
724 strm << ")";
725 return strm;
726}
727
728
729template <typename charT, typename traits>
730inline std::basic_ostream<charT, traits> &
731operator<<(std::basic_ostream<charT, traits> & strm, const cl_float4 & _v)
732{
733 strm << "(float4)(";
734 for (unsigned int i = 0; i < 4; ++i)
735 {
736 strm << std::fixed << std::setprecision(8) << _v.s[i];
737 if (i != 3)
738 {
739 strm << ", ";
740 }
741 }
742 strm << ")";
743 return strm;
744}
745
746
747template <typename charT, typename traits>
748inline std::basic_ostream<charT, traits> &
749operator<<(std::basic_ostream<charT, traits> & strm, const cl_float8 & _v)
750{
751 strm << "(float8)(";
752 for (unsigned int i = 0; i < 8; ++i)
753 {
754 strm << std::fixed << std::setprecision(8) << _v.s[i];
755 if (i != 7)
756 {
757 strm << ", ";
758 }
759 }
760 strm << ")";
761 return strm;
762}
763
764
765template <typename charT, typename traits>
766inline std::basic_ostream<charT, traits> &
767operator<<(std::basic_ostream<charT, traits> & strm, const cl_float16 & _v)
768{
769 strm << "(float16)(";
770 for (unsigned int i = 0; i < 16; ++i)
771 {
772 strm << std::fixed << std::setprecision(8) << _v.s[i];
773 if (i != 15)
774 {
775 strm << ", ";
776 }
777 }
778 strm << ")";
779 return strm;
780}
781
782
783} // end namespace itk
784
785#endif // /* itkOpenCLOstreamSupport_h */
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &strm, const OpenCLCommandQueue &queue)


Generated on 2023-01-13 for elastix by doxygen 1.9.6 elastix logo