VTK-m  2.0
VecOperators.h
Go to the documentation of this file.
1 //============================================================================
2 // Copyright (c) Kitware, Inc.
3 // All rights reserved.
4 // See LICENSE.txt for details.
5 //
6 // This software is distributed WITHOUT ANY WARRANTY; without even
7 // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8 // PURPOSE. See the above copyright notice for more information.
9 //============================================================================
11 // This file is automatically generated by VecOperators.h.in
12 // clang-format off
13 #ifndef vtk_m_internal_VecOperators_h
14 #define vtk_m_internal_VecOperators_h
15 
16 #include <vtkm/internal/Configure.h>
17 
18 namespace vtkm {
19 
20 #if (!(defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8)))
21 #if (defined(VTKM_GCC) || defined(VTKM_CLANG))
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
24 #pragma GCC diagnostic ignored "-Wpragmas"
25 #pragma GCC diagnostic ignored "-Wconversion"
26 #pragma GCC diagnostic ignored "-Wfloat-conversion"
27 #endif // gcc || clang
28 #endif // not using cuda < 8
29 
30 #if defined(VTKM_MSVC)
31 #pragma warning(push)
32 #pragma warning(disable : 4244)
33 #endif
34 
35 
36 // operator- unary overloads for generic and specific sizes {{{
37 template <typename T, vtkm::IdComponent Size>
38 inline VTKM_EXEC_CONT
39 typename std::enable_if<(std::is_floating_point<T>::value || std::is_signed<T>::value),
40  vtkm::Vec<T, Size>>::type
41 operator-(vtkm::Vec<T, Size> x)
42 {
43  for(int i=0; i < Size; ++i)
44  {
45  x[i] = -x[i];
46  }
47  return x;
48 }
49 
50 template <typename T>
51 inline VTKM_EXEC_CONT
52 typename std::enable_if<(std::is_floating_point<T>::value || std::is_signed<T>::value),
53  vtkm::Vec<T, 1>>::type
54 operator-(const vtkm::Vec<T, 1>& x)
55 {
56  return vtkm::Vec<T, 1>(-x[0]);
57 }
58 
59 template <typename T>
60 inline VTKM_EXEC_CONT
61 typename std::enable_if<(std::is_floating_point<T>::value || std::is_signed<T>::value),
62  vtkm::Vec<T, 2>>::type
63 operator-(const vtkm::Vec<T, 2>& x)
64 {
65  return vtkm::Vec<T, 2>(-x[0], -x[1]);
66 }
67 
68 template <typename T>
69 inline VTKM_EXEC_CONT
70 typename std::enable_if<(std::is_floating_point<T>::value || std::is_signed<T>::value),
71  vtkm::Vec<T, 3>>::type
72 operator-(const vtkm::Vec<T, 3>& x)
73 {
74  return vtkm::Vec<T, 3>(-x[0], -x[1], -x[2]);
75 }
76 
77 template <typename T>
78 inline VTKM_EXEC_CONT
79 typename std::enable_if<(std::is_floating_point<T>::value || std::is_signed<T>::value),
80  vtkm::Vec<T, 4>>::type
81 operator-(const vtkm::Vec<T, 4>& x)
82 {
83  return vtkm::Vec<T, 4>(-x[0], -x[1], -x[2], -x[3]);
84 }
85 
86 
87 //}}}
88 
89 // operator+ overloads for generic vector sizes -------------------{{{
90 // Vec_Vec for ['T', 'T']
91 template <typename T, IdComponent Size>
94 )
95 {
96  for (int i = 0; i < Size; ++i)
97  {
98  a[i] = a[i] + b[i];
99  }
100  return a;
101 }
102 
103 // Vec_Scalar for ['T', 'T']
104 template <typename T, IdComponent Size>
106  vtkm::Vec<T, Size> a, T scalar
107 )
108 {
109  for (int i = 0; i < Size; ++i)
110  {
111  a[i] = a[i] + scalar;
112  }
113  return a;
114 }
115 
116 // Vec_Scalar for ['T', 'vtkm::Float64']
117 template <typename T, IdComponent Size>
120 )
121 {
122  for (int i = 0; i < Size; ++i)
123  {
124  a[i] = a[i] + scalar;
125  }
126  return a;
127 }
128 
129 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
130 template <IdComponent Size>
133 )
134 {
135  for (int i = 0; i < Size; ++i)
136  {
137  a[i] = a[i] + scalar;
138  }
139  return a;
140 }
141 
142 // Scalar_Vec for ['T', 'T']
143 template <typename T, IdComponent Size>
145  T scalar, vtkm::Vec<T, Size> a
146 )
147 {
148  for (int i = 0; i < Size; ++i)
149  {
150  a[i] = scalar + a[i];
151  }
152  return a;
153 }
154 
155 // Scalar_Vec for ['T', 'vtkm::Float64']
156 template <typename T, IdComponent Size>
159 )
160 {
161  for (int i = 0; i < Size; ++i)
162  {
163  a[i] = scalar + a[i];
164  }
165  return a;
166 }
167 
168 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
169 template <IdComponent Size>
172 )
173 {
174  for (int i = 0; i < Size; ++i)
175  {
176  a[i] = scalar + a[i];
177  }
178  return a;
179 }
180 
181 //}}}
182 // operator* overloads for generic vector sizes -------------------{{{
183 // Vec_Vec for ['T', 'T']
184 template <typename T, IdComponent Size>
187 )
188 {
189  for (int i = 0; i < Size; ++i)
190  {
191  a[i] = a[i] * b[i];
192  }
193  return a;
194 }
195 
196 // Vec_Scalar for ['T', 'T']
197 template <typename T, IdComponent Size>
199  vtkm::Vec<T, Size> a, T scalar
200 )
201 {
202  for (int i = 0; i < Size; ++i)
203  {
204  a[i] = a[i] * scalar;
205  }
206  return a;
207 }
208 
209 // Vec_Scalar for ['T', 'vtkm::Float64']
210 template <typename T, IdComponent Size>
213 )
214 {
215  for (int i = 0; i < Size; ++i)
216  {
217  a[i] = a[i] * scalar;
218  }
219  return a;
220 }
221 
222 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
223 template <IdComponent Size>
226 )
227 {
228  for (int i = 0; i < Size; ++i)
229  {
230  a[i] = a[i] * scalar;
231  }
232  return a;
233 }
234 
235 // Scalar_Vec for ['T', 'T']
236 template <typename T, IdComponent Size>
238  T scalar, vtkm::Vec<T, Size> a
239 )
240 {
241  for (int i = 0; i < Size; ++i)
242  {
243  a[i] = scalar * a[i];
244  }
245  return a;
246 }
247 
248 // Scalar_Vec for ['T', 'vtkm::Float64']
249 template <typename T, IdComponent Size>
252 )
253 {
254  for (int i = 0; i < Size; ++i)
255  {
256  a[i] = scalar * a[i];
257  }
258  return a;
259 }
260 
261 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
262 template <IdComponent Size>
265 )
266 {
267  for (int i = 0; i < Size; ++i)
268  {
269  a[i] = scalar * a[i];
270  }
271  return a;
272 }
273 
274 //}}}
275 // operator- overloads for generic vector sizes -------------------{{{
276 // Vec_Vec for ['T', 'T']
277 template <typename T, IdComponent Size>
280 )
281 {
282  for (int i = 0; i < Size; ++i)
283  {
284  a[i] = a[i] - b[i];
285  }
286  return a;
287 }
288 
289 // Vec_Scalar for ['T', 'T']
290 template <typename T, IdComponent Size>
292  vtkm::Vec<T, Size> a, T scalar
293 )
294 {
295  for (int i = 0; i < Size; ++i)
296  {
297  a[i] = a[i] - scalar;
298  }
299  return a;
300 }
301 
302 // Vec_Scalar for ['T', 'vtkm::Float64']
303 template <typename T, IdComponent Size>
306 )
307 {
308  for (int i = 0; i < Size; ++i)
309  {
310  a[i] = a[i] - scalar;
311  }
312  return a;
313 }
314 
315 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
316 template <IdComponent Size>
319 )
320 {
321  for (int i = 0; i < Size; ++i)
322  {
323  a[i] = a[i] - scalar;
324  }
325  return a;
326 }
327 
328 // Scalar_Vec for ['T', 'T']
329 template <typename T, IdComponent Size>
331  T scalar, vtkm::Vec<T, Size> a
332 )
333 {
334  for (int i = 0; i < Size; ++i)
335  {
336  a[i] = scalar - a[i];
337  }
338  return a;
339 }
340 
341 // Scalar_Vec for ['T', 'vtkm::Float64']
342 template <typename T, IdComponent Size>
345 )
346 {
347  for (int i = 0; i < Size; ++i)
348  {
349  a[i] = scalar - a[i];
350  }
351  return a;
352 }
353 
354 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
355 template <IdComponent Size>
358 )
359 {
360  for (int i = 0; i < Size; ++i)
361  {
362  a[i] = scalar - a[i];
363  }
364  return a;
365 }
366 
367 //}}}
368 // operator/ overloads for generic vector sizes -------------------{{{
369 // Vec_Vec for ['T', 'T']
370 template <typename T, IdComponent Size>
373 )
374 {
375  for (int i = 0; i < Size; ++i)
376  {
377  a[i] = a[i] / b[i];
378  }
379  return a;
380 }
381 
382 // Vec_Scalar for ['T', 'T']
383 template <typename T, IdComponent Size>
385  vtkm::Vec<T, Size> a, T scalar
386 )
387 {
388  for (int i = 0; i < Size; ++i)
389  {
390  a[i] = a[i] / scalar;
391  }
392  return a;
393 }
394 
395 // Vec_Scalar for ['T', 'vtkm::Float64']
396 template <typename T, IdComponent Size>
399 )
400 {
401  for (int i = 0; i < Size; ++i)
402  {
403  a[i] = a[i] / scalar;
404  }
405  return a;
406 }
407 
408 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
409 template <IdComponent Size>
412 )
413 {
414  for (int i = 0; i < Size; ++i)
415  {
416  a[i] = a[i] / scalar;
417  }
418  return a;
419 }
420 
421 // Scalar_Vec for ['T', 'T']
422 template <typename T, IdComponent Size>
424  T scalar, vtkm::Vec<T, Size> a
425 )
426 {
427  for (int i = 0; i < Size; ++i)
428  {
429  a[i] = scalar / a[i];
430  }
431  return a;
432 }
433 
434 // Scalar_Vec for ['T', 'vtkm::Float64']
435 template <typename T, IdComponent Size>
438 )
439 {
440  for (int i = 0; i < Size; ++i)
441  {
442  a[i] = scalar / a[i];
443  }
444  return a;
445 }
446 
447 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
448 template <IdComponent Size>
451 )
452 {
453  for (int i = 0; i < Size; ++i)
454  {
455  a[i] = scalar / a[i];
456  }
457  return a;
458 }
459 
460 //}}}
461 
462 // operator+ overloads for specific vector sizes -------------------{{{
463 // Vec_Vec for ['T', 'T']
464 template <typename T>
466  const vtkm::Vec<T, 1>& a, const vtkm::Vec<T, 1>& b
467 )
468 {
469  return vtkm::Vec<T, 1>(a[0] + b[0]);
470 }
471 
472 // Vec_Scalar for ['T', 'T']
473 template <typename T>
475  const vtkm::Vec<T, 1>& a, T scalar
476 )
477 {
478  return vtkm::Vec<T, 1>(a[0] + scalar);
479 }
480 
481 // Vec_Scalar for ['T', 'vtkm::Float64']
482 template <typename T>
484  const vtkm::Vec<T, 1>& a, vtkm::Float64 scalar
485 )
486 {
487  return vtkm::Vec<T, 1>(a[0] + scalar);
488 }
489 
490 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
493 )
494 {
495  return vtkm::Vec<vtkm::Float64, 1>(a[0] + scalar);
496 }
497 
498 // Scalar_Vec for ['T', 'T']
499 template <typename T>
501  T scalar, const vtkm::Vec<T, 1>& a
502 )
503 {
504  return vtkm::Vec<T, 1>(scalar + a[0]);
505 }
506 
507 // Scalar_Vec for ['T', 'vtkm::Float64']
508 template <typename T>
510  vtkm::Float64 scalar, const vtkm::Vec<T, 1>& a
511 )
512 {
513  return vtkm::Vec<T, 1>(scalar + a[0]);
514 }
515 
516 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
519 )
520 {
521  return vtkm::Vec<vtkm::Float64, 1>(scalar + a[0]);
522 }
523 
524 // Vec_Vec for ['T', 'T']
525 template <typename T>
527  const vtkm::Vec<T, 2>& a, const vtkm::Vec<T, 2>& b
528 )
529 {
530  return vtkm::Vec<T, 2>(a[0] + b[0], a[1] + b[1]);
531 }
532 
533 // Vec_Scalar for ['T', 'T']
534 template <typename T>
536  const vtkm::Vec<T, 2>& a, T scalar
537 )
538 {
539  return vtkm::Vec<T, 2>(a[0] + scalar, a[1] + scalar);
540 }
541 
542 // Vec_Scalar for ['T', 'vtkm::Float64']
543 template <typename T>
545  const vtkm::Vec<T, 2>& a, vtkm::Float64 scalar
546 )
547 {
548  return vtkm::Vec<T, 2>(a[0] + scalar, a[1] + scalar);
549 }
550 
551 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
554 )
555 {
556  return vtkm::Vec<vtkm::Float64, 2>(a[0] + scalar, a[1] + scalar);
557 }
558 
559 // Scalar_Vec for ['T', 'T']
560 template <typename T>
562  T scalar, const vtkm::Vec<T, 2>& a
563 )
564 {
565  return vtkm::Vec<T, 2>(scalar + a[0], scalar + a[1]);
566 }
567 
568 // Scalar_Vec for ['T', 'vtkm::Float64']
569 template <typename T>
571  vtkm::Float64 scalar, const vtkm::Vec<T, 2>& a
572 )
573 {
574  return vtkm::Vec<T, 2>(scalar + a[0], scalar + a[1]);
575 }
576 
577 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
580 )
581 {
582  return vtkm::Vec<vtkm::Float64, 2>(scalar + a[0], scalar + a[1]);
583 }
584 
585 // Vec_Vec for ['T', 'T']
586 template <typename T>
588  const vtkm::Vec<T, 3>& a, const vtkm::Vec<T, 3>& b
589 )
590 {
591  return vtkm::Vec<T, 3>(a[0] + b[0], a[1] + b[1], a[2] + b[2]);
592 }
593 
594 // Vec_Scalar for ['T', 'T']
595 template <typename T>
597  const vtkm::Vec<T, 3>& a, T scalar
598 )
599 {
600  return vtkm::Vec<T, 3>(a[0] + scalar, a[1] + scalar, a[2] + scalar);
601 }
602 
603 // Vec_Scalar for ['T', 'vtkm::Float64']
604 template <typename T>
606  const vtkm::Vec<T, 3>& a, vtkm::Float64 scalar
607 )
608 {
609  return vtkm::Vec<T, 3>(a[0] + scalar, a[1] + scalar, a[2] + scalar);
610 }
611 
612 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
615 )
616 {
617  return vtkm::Vec<vtkm::Float64, 3>(a[0] + scalar, a[1] + scalar, a[2] + scalar);
618 }
619 
620 // Scalar_Vec for ['T', 'T']
621 template <typename T>
623  T scalar, const vtkm::Vec<T, 3>& a
624 )
625 {
626  return vtkm::Vec<T, 3>(scalar + a[0], scalar + a[1], scalar + a[2]);
627 }
628 
629 // Scalar_Vec for ['T', 'vtkm::Float64']
630 template <typename T>
632  vtkm::Float64 scalar, const vtkm::Vec<T, 3>& a
633 )
634 {
635  return vtkm::Vec<T, 3>(scalar + a[0], scalar + a[1], scalar + a[2]);
636 }
637 
638 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
641 )
642 {
643  return vtkm::Vec<vtkm::Float64, 3>(scalar + a[0], scalar + a[1], scalar + a[2]);
644 }
645 
646 // Vec_Vec for ['T', 'T']
647 template <typename T>
649  const vtkm::Vec<T, 4>& a, const vtkm::Vec<T, 4>& b
650 )
651 {
652  return vtkm::Vec<T, 4>(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]);
653 }
654 
655 // Vec_Scalar for ['T', 'T']
656 template <typename T>
658  const vtkm::Vec<T, 4>& a, T scalar
659 )
660 {
661  return vtkm::Vec<T, 4>(a[0] + scalar, a[1] + scalar, a[2] + scalar, a[3] + scalar);
662 }
663 
664 // Vec_Scalar for ['T', 'vtkm::Float64']
665 template <typename T>
667  const vtkm::Vec<T, 4>& a, vtkm::Float64 scalar
668 )
669 {
670  return vtkm::Vec<T, 4>(a[0] + scalar, a[1] + scalar, a[2] + scalar, a[3] + scalar);
671 }
672 
673 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
676 )
677 {
678  return vtkm::Vec<vtkm::Float64, 4>(a[0] + scalar, a[1] + scalar, a[2] + scalar, a[3] + scalar);
679 }
680 
681 // Scalar_Vec for ['T', 'T']
682 template <typename T>
684  T scalar, const vtkm::Vec<T, 4>& a
685 )
686 {
687  return vtkm::Vec<T, 4>(scalar + a[0], scalar + a[1], scalar + a[2], scalar + a[3]);
688 }
689 
690 // Scalar_Vec for ['T', 'vtkm::Float64']
691 template <typename T>
693  vtkm::Float64 scalar, const vtkm::Vec<T, 4>& a
694 )
695 {
696  return vtkm::Vec<T, 4>(scalar + a[0], scalar + a[1], scalar + a[2], scalar + a[3]);
697 }
698 
699 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
702 )
703 {
704  return vtkm::Vec<vtkm::Float64, 4>(scalar + a[0], scalar + a[1], scalar + a[2], scalar + a[3]);
705 }
706 
707 //}}}
708 // operator* overloads for specific vector sizes -------------------{{{
709 // Vec_Vec for ['T', 'T']
710 template <typename T>
712  const vtkm::Vec<T, 1>& a, const vtkm::Vec<T, 1>& b
713 )
714 {
715  return vtkm::Vec<T, 1>(a[0] * b[0]);
716 }
717 
718 // Vec_Scalar for ['T', 'T']
719 template <typename T>
721  const vtkm::Vec<T, 1>& a, T scalar
722 )
723 {
724  return vtkm::Vec<T, 1>(a[0] * scalar);
725 }
726 
727 // Vec_Scalar for ['T', 'vtkm::Float64']
728 template <typename T>
730  const vtkm::Vec<T, 1>& a, vtkm::Float64 scalar
731 )
732 {
733  return vtkm::Vec<T, 1>(a[0] * scalar);
734 }
735 
736 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
739 )
740 {
741  return vtkm::Vec<vtkm::Float64, 1>(a[0] * scalar);
742 }
743 
744 // Scalar_Vec for ['T', 'T']
745 template <typename T>
747  T scalar, const vtkm::Vec<T, 1>& a
748 )
749 {
750  return vtkm::Vec<T, 1>(scalar * a[0]);
751 }
752 
753 // Scalar_Vec for ['T', 'vtkm::Float64']
754 template <typename T>
756  vtkm::Float64 scalar, const vtkm::Vec<T, 1>& a
757 )
758 {
759  return vtkm::Vec<T, 1>(scalar * a[0]);
760 }
761 
762 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
765 )
766 {
767  return vtkm::Vec<vtkm::Float64, 1>(scalar * a[0]);
768 }
769 
770 // Vec_Vec for ['T', 'T']
771 template <typename T>
773  const vtkm::Vec<T, 2>& a, const vtkm::Vec<T, 2>& b
774 )
775 {
776  return vtkm::Vec<T, 2>(a[0] * b[0], a[1] * b[1]);
777 }
778 
779 // Vec_Scalar for ['T', 'T']
780 template <typename T>
782  const vtkm::Vec<T, 2>& a, T scalar
783 )
784 {
785  return vtkm::Vec<T, 2>(a[0] * scalar, a[1] * scalar);
786 }
787 
788 // Vec_Scalar for ['T', 'vtkm::Float64']
789 template <typename T>
791  const vtkm::Vec<T, 2>& a, vtkm::Float64 scalar
792 )
793 {
794  return vtkm::Vec<T, 2>(a[0] * scalar, a[1] * scalar);
795 }
796 
797 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
800 )
801 {
802  return vtkm::Vec<vtkm::Float64, 2>(a[0] * scalar, a[1] * scalar);
803 }
804 
805 // Scalar_Vec for ['T', 'T']
806 template <typename T>
808  T scalar, const vtkm::Vec<T, 2>& a
809 )
810 {
811  return vtkm::Vec<T, 2>(scalar * a[0], scalar * a[1]);
812 }
813 
814 // Scalar_Vec for ['T', 'vtkm::Float64']
815 template <typename T>
817  vtkm::Float64 scalar, const vtkm::Vec<T, 2>& a
818 )
819 {
820  return vtkm::Vec<T, 2>(scalar * a[0], scalar * a[1]);
821 }
822 
823 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
826 )
827 {
828  return vtkm::Vec<vtkm::Float64, 2>(scalar * a[0], scalar * a[1]);
829 }
830 
831 // Vec_Vec for ['T', 'T']
832 template <typename T>
834  const vtkm::Vec<T, 3>& a, const vtkm::Vec<T, 3>& b
835 )
836 {
837  return vtkm::Vec<T, 3>(a[0] * b[0], a[1] * b[1], a[2] * b[2]);
838 }
839 
840 // Vec_Scalar for ['T', 'T']
841 template <typename T>
843  const vtkm::Vec<T, 3>& a, T scalar
844 )
845 {
846  return vtkm::Vec<T, 3>(a[0] * scalar, a[1] * scalar, a[2] * scalar);
847 }
848 
849 // Vec_Scalar for ['T', 'vtkm::Float64']
850 template <typename T>
852  const vtkm::Vec<T, 3>& a, vtkm::Float64 scalar
853 )
854 {
855  return vtkm::Vec<T, 3>(a[0] * scalar, a[1] * scalar, a[2] * scalar);
856 }
857 
858 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
861 )
862 {
863  return vtkm::Vec<vtkm::Float64, 3>(a[0] * scalar, a[1] * scalar, a[2] * scalar);
864 }
865 
866 // Scalar_Vec for ['T', 'T']
867 template <typename T>
869  T scalar, const vtkm::Vec<T, 3>& a
870 )
871 {
872  return vtkm::Vec<T, 3>(scalar * a[0], scalar * a[1], scalar * a[2]);
873 }
874 
875 // Scalar_Vec for ['T', 'vtkm::Float64']
876 template <typename T>
878  vtkm::Float64 scalar, const vtkm::Vec<T, 3>& a
879 )
880 {
881  return vtkm::Vec<T, 3>(scalar * a[0], scalar * a[1], scalar * a[2]);
882 }
883 
884 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
887 )
888 {
889  return vtkm::Vec<vtkm::Float64, 3>(scalar * a[0], scalar * a[1], scalar * a[2]);
890 }
891 
892 // Vec_Vec for ['T', 'T']
893 template <typename T>
895  const vtkm::Vec<T, 4>& a, const vtkm::Vec<T, 4>& b
896 )
897 {
898  return vtkm::Vec<T, 4>(a[0] * b[0], a[1] * b[1], a[2] * b[2], a[3] * b[3]);
899 }
900 
901 // Vec_Scalar for ['T', 'T']
902 template <typename T>
904  const vtkm::Vec<T, 4>& a, T scalar
905 )
906 {
907  return vtkm::Vec<T, 4>(a[0] * scalar, a[1] * scalar, a[2] * scalar, a[3] * scalar);
908 }
909 
910 // Vec_Scalar for ['T', 'vtkm::Float64']
911 template <typename T>
913  const vtkm::Vec<T, 4>& a, vtkm::Float64 scalar
914 )
915 {
916  return vtkm::Vec<T, 4>(a[0] * scalar, a[1] * scalar, a[2] * scalar, a[3] * scalar);
917 }
918 
919 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
922 )
923 {
924  return vtkm::Vec<vtkm::Float64, 4>(a[0] * scalar, a[1] * scalar, a[2] * scalar, a[3] * scalar);
925 }
926 
927 // Scalar_Vec for ['T', 'T']
928 template <typename T>
930  T scalar, const vtkm::Vec<T, 4>& a
931 )
932 {
933  return vtkm::Vec<T, 4>(scalar * a[0], scalar * a[1], scalar * a[2], scalar * a[3]);
934 }
935 
936 // Scalar_Vec for ['T', 'vtkm::Float64']
937 template <typename T>
939  vtkm::Float64 scalar, const vtkm::Vec<T, 4>& a
940 )
941 {
942  return vtkm::Vec<T, 4>(scalar * a[0], scalar * a[1], scalar * a[2], scalar * a[3]);
943 }
944 
945 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
948 )
949 {
950  return vtkm::Vec<vtkm::Float64, 4>(scalar * a[0], scalar * a[1], scalar * a[2], scalar * a[3]);
951 }
952 
953 //}}}
954 // operator- overloads for specific vector sizes -------------------{{{
955 // Vec_Vec for ['T', 'T']
956 template <typename T>
958  const vtkm::Vec<T, 1>& a, const vtkm::Vec<T, 1>& b
959 )
960 {
961  return vtkm::Vec<T, 1>(a[0] - b[0]);
962 }
963 
964 // Vec_Scalar for ['T', 'T']
965 template <typename T>
967  const vtkm::Vec<T, 1>& a, T scalar
968 )
969 {
970  return vtkm::Vec<T, 1>(a[0] - scalar);
971 }
972 
973 // Vec_Scalar for ['T', 'vtkm::Float64']
974 template <typename T>
976  const vtkm::Vec<T, 1>& a, vtkm::Float64 scalar
977 )
978 {
979  return vtkm::Vec<T, 1>(a[0] - scalar);
980 }
981 
982 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
985 )
986 {
987  return vtkm::Vec<vtkm::Float64, 1>(a[0] - scalar);
988 }
989 
990 // Scalar_Vec for ['T', 'T']
991 template <typename T>
993  T scalar, const vtkm::Vec<T, 1>& a
994 )
995 {
996  return vtkm::Vec<T, 1>(scalar - a[0]);
997 }
998 
999 // Scalar_Vec for ['T', 'vtkm::Float64']
1000 template <typename T>
1002  vtkm::Float64 scalar, const vtkm::Vec<T, 1>& a
1003 )
1004 {
1005  return vtkm::Vec<T, 1>(scalar - a[0]);
1006 }
1007 
1008 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1011 )
1012 {
1013  return vtkm::Vec<vtkm::Float64, 1>(scalar - a[0]);
1014 }
1015 
1016 // Vec_Vec for ['T', 'T']
1017 template <typename T>
1019  const vtkm::Vec<T, 2>& a, const vtkm::Vec<T, 2>& b
1020 )
1021 {
1022  return vtkm::Vec<T, 2>(a[0] - b[0], a[1] - b[1]);
1023 }
1024 
1025 // Vec_Scalar for ['T', 'T']
1026 template <typename T>
1028  const vtkm::Vec<T, 2>& a, T scalar
1029 )
1030 {
1031  return vtkm::Vec<T, 2>(a[0] - scalar, a[1] - scalar);
1032 }
1033 
1034 // Vec_Scalar for ['T', 'vtkm::Float64']
1035 template <typename T>
1037  const vtkm::Vec<T, 2>& a, vtkm::Float64 scalar
1038 )
1039 {
1040  return vtkm::Vec<T, 2>(a[0] - scalar, a[1] - scalar);
1041 }
1042 
1043 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1046 )
1047 {
1048  return vtkm::Vec<vtkm::Float64, 2>(a[0] - scalar, a[1] - scalar);
1049 }
1050 
1051 // Scalar_Vec for ['T', 'T']
1052 template <typename T>
1054  T scalar, const vtkm::Vec<T, 2>& a
1055 )
1056 {
1057  return vtkm::Vec<T, 2>(scalar - a[0], scalar - a[1]);
1058 }
1059 
1060 // Scalar_Vec for ['T', 'vtkm::Float64']
1061 template <typename T>
1063  vtkm::Float64 scalar, const vtkm::Vec<T, 2>& a
1064 )
1065 {
1066  return vtkm::Vec<T, 2>(scalar - a[0], scalar - a[1]);
1067 }
1068 
1069 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1072 )
1073 {
1074  return vtkm::Vec<vtkm::Float64, 2>(scalar - a[0], scalar - a[1]);
1075 }
1076 
1077 // Vec_Vec for ['T', 'T']
1078 template <typename T>
1080  const vtkm::Vec<T, 3>& a, const vtkm::Vec<T, 3>& b
1081 )
1082 {
1083  return vtkm::Vec<T, 3>(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
1084 }
1085 
1086 // Vec_Scalar for ['T', 'T']
1087 template <typename T>
1089  const vtkm::Vec<T, 3>& a, T scalar
1090 )
1091 {
1092  return vtkm::Vec<T, 3>(a[0] - scalar, a[1] - scalar, a[2] - scalar);
1093 }
1094 
1095 // Vec_Scalar for ['T', 'vtkm::Float64']
1096 template <typename T>
1098  const vtkm::Vec<T, 3>& a, vtkm::Float64 scalar
1099 )
1100 {
1101  return vtkm::Vec<T, 3>(a[0] - scalar, a[1] - scalar, a[2] - scalar);
1102 }
1103 
1104 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1107 )
1108 {
1109  return vtkm::Vec<vtkm::Float64, 3>(a[0] - scalar, a[1] - scalar, a[2] - scalar);
1110 }
1111 
1112 // Scalar_Vec for ['T', 'T']
1113 template <typename T>
1115  T scalar, const vtkm::Vec<T, 3>& a
1116 )
1117 {
1118  return vtkm::Vec<T, 3>(scalar - a[0], scalar - a[1], scalar - a[2]);
1119 }
1120 
1121 // Scalar_Vec for ['T', 'vtkm::Float64']
1122 template <typename T>
1124  vtkm::Float64 scalar, const vtkm::Vec<T, 3>& a
1125 )
1126 {
1127  return vtkm::Vec<T, 3>(scalar - a[0], scalar - a[1], scalar - a[2]);
1128 }
1129 
1130 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1133 )
1134 {
1135  return vtkm::Vec<vtkm::Float64, 3>(scalar - a[0], scalar - a[1], scalar - a[2]);
1136 }
1137 
1138 // Vec_Vec for ['T', 'T']
1139 template <typename T>
1141  const vtkm::Vec<T, 4>& a, const vtkm::Vec<T, 4>& b
1142 )
1143 {
1144  return vtkm::Vec<T, 4>(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]);
1145 }
1146 
1147 // Vec_Scalar for ['T', 'T']
1148 template <typename T>
1150  const vtkm::Vec<T, 4>& a, T scalar
1151 )
1152 {
1153  return vtkm::Vec<T, 4>(a[0] - scalar, a[1] - scalar, a[2] - scalar, a[3] - scalar);
1154 }
1155 
1156 // Vec_Scalar for ['T', 'vtkm::Float64']
1157 template <typename T>
1159  const vtkm::Vec<T, 4>& a, vtkm::Float64 scalar
1160 )
1161 {
1162  return vtkm::Vec<T, 4>(a[0] - scalar, a[1] - scalar, a[2] - scalar, a[3] - scalar);
1163 }
1164 
1165 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1168 )
1169 {
1170  return vtkm::Vec<vtkm::Float64, 4>(a[0] - scalar, a[1] - scalar, a[2] - scalar, a[3] - scalar);
1171 }
1172 
1173 // Scalar_Vec for ['T', 'T']
1174 template <typename T>
1176  T scalar, const vtkm::Vec<T, 4>& a
1177 )
1178 {
1179  return vtkm::Vec<T, 4>(scalar - a[0], scalar - a[1], scalar - a[2], scalar - a[3]);
1180 }
1181 
1182 // Scalar_Vec for ['T', 'vtkm::Float64']
1183 template <typename T>
1185  vtkm::Float64 scalar, const vtkm::Vec<T, 4>& a
1186 )
1187 {
1188  return vtkm::Vec<T, 4>(scalar - a[0], scalar - a[1], scalar - a[2], scalar - a[3]);
1189 }
1190 
1191 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1194 )
1195 {
1196  return vtkm::Vec<vtkm::Float64, 4>(scalar - a[0], scalar - a[1], scalar - a[2], scalar - a[3]);
1197 }
1198 
1199 //}}}
1200 // operator/ overloads for specific vector sizes -------------------{{{
1201 // Vec_Vec for ['T', 'T']
1202 template <typename T>
1204  const vtkm::Vec<T, 1>& a, const vtkm::Vec<T, 1>& b
1205 )
1206 {
1207  return vtkm::Vec<T, 1>(a[0] / b[0]);
1208 }
1209 
1210 // Vec_Scalar for ['T', 'T']
1211 template <typename T>
1213  const vtkm::Vec<T, 1>& a, T scalar
1214 )
1215 {
1216  return vtkm::Vec<T, 1>(a[0] / scalar);
1217 }
1218 
1219 // Vec_Scalar for ['T', 'vtkm::Float64']
1220 template <typename T>
1222  const vtkm::Vec<T, 1>& a, vtkm::Float64 scalar
1223 )
1224 {
1225  return vtkm::Vec<T, 1>(a[0] / scalar);
1226 }
1227 
1228 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1231 )
1232 {
1233  return vtkm::Vec<vtkm::Float64, 1>(a[0] / scalar);
1234 }
1235 
1236 // Scalar_Vec for ['T', 'T']
1237 template <typename T>
1239  T scalar, const vtkm::Vec<T, 1>& a
1240 )
1241 {
1242  return vtkm::Vec<T, 1>(scalar / a[0]);
1243 }
1244 
1245 // Scalar_Vec for ['T', 'vtkm::Float64']
1246 template <typename T>
1248  vtkm::Float64 scalar, const vtkm::Vec<T, 1>& a
1249 )
1250 {
1251  return vtkm::Vec<T, 1>(scalar / a[0]);
1252 }
1253 
1254 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1257 )
1258 {
1259  return vtkm::Vec<vtkm::Float64, 1>(scalar / a[0]);
1260 }
1261 
1262 // Vec_Vec for ['T', 'T']
1263 template <typename T>
1265  const vtkm::Vec<T, 2>& a, const vtkm::Vec<T, 2>& b
1266 )
1267 {
1268  return vtkm::Vec<T, 2>(a[0] / b[0], a[1] / b[1]);
1269 }
1270 
1271 // Vec_Scalar for ['T', 'T']
1272 template <typename T>
1274  const vtkm::Vec<T, 2>& a, T scalar
1275 )
1276 {
1277  return vtkm::Vec<T, 2>(a[0] / scalar, a[1] / scalar);
1278 }
1279 
1280 // Vec_Scalar for ['T', 'vtkm::Float64']
1281 template <typename T>
1283  const vtkm::Vec<T, 2>& a, vtkm::Float64 scalar
1284 )
1285 {
1286  return vtkm::Vec<T, 2>(a[0] / scalar, a[1] / scalar);
1287 }
1288 
1289 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1292 )
1293 {
1294  return vtkm::Vec<vtkm::Float64, 2>(a[0] / scalar, a[1] / scalar);
1295 }
1296 
1297 // Scalar_Vec for ['T', 'T']
1298 template <typename T>
1300  T scalar, const vtkm::Vec<T, 2>& a
1301 )
1302 {
1303  return vtkm::Vec<T, 2>(scalar / a[0], scalar / a[1]);
1304 }
1305 
1306 // Scalar_Vec for ['T', 'vtkm::Float64']
1307 template <typename T>
1309  vtkm::Float64 scalar, const vtkm::Vec<T, 2>& a
1310 )
1311 {
1312  return vtkm::Vec<T, 2>(scalar / a[0], scalar / a[1]);
1313 }
1314 
1315 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1318 )
1319 {
1320  return vtkm::Vec<vtkm::Float64, 2>(scalar / a[0], scalar / a[1]);
1321 }
1322 
1323 // Vec_Vec for ['T', 'T']
1324 template <typename T>
1326  const vtkm::Vec<T, 3>& a, const vtkm::Vec<T, 3>& b
1327 )
1328 {
1329  return vtkm::Vec<T, 3>(a[0] / b[0], a[1] / b[1], a[2] / b[2]);
1330 }
1331 
1332 // Vec_Scalar for ['T', 'T']
1333 template <typename T>
1335  const vtkm::Vec<T, 3>& a, T scalar
1336 )
1337 {
1338  return vtkm::Vec<T, 3>(a[0] / scalar, a[1] / scalar, a[2] / scalar);
1339 }
1340 
1341 // Vec_Scalar for ['T', 'vtkm::Float64']
1342 template <typename T>
1344  const vtkm::Vec<T, 3>& a, vtkm::Float64 scalar
1345 )
1346 {
1347  return vtkm::Vec<T, 3>(a[0] / scalar, a[1] / scalar, a[2] / scalar);
1348 }
1349 
1350 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1353 )
1354 {
1355  return vtkm::Vec<vtkm::Float64, 3>(a[0] / scalar, a[1] / scalar, a[2] / scalar);
1356 }
1357 
1358 // Scalar_Vec for ['T', 'T']
1359 template <typename T>
1361  T scalar, const vtkm::Vec<T, 3>& a
1362 )
1363 {
1364  return vtkm::Vec<T, 3>(scalar / a[0], scalar / a[1], scalar / a[2]);
1365 }
1366 
1367 // Scalar_Vec for ['T', 'vtkm::Float64']
1368 template <typename T>
1370  vtkm::Float64 scalar, const vtkm::Vec<T, 3>& a
1371 )
1372 {
1373  return vtkm::Vec<T, 3>(scalar / a[0], scalar / a[1], scalar / a[2]);
1374 }
1375 
1376 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1379 )
1380 {
1381  return vtkm::Vec<vtkm::Float64, 3>(scalar / a[0], scalar / a[1], scalar / a[2]);
1382 }
1383 
1384 // Vec_Vec for ['T', 'T']
1385 template <typename T>
1387  const vtkm::Vec<T, 4>& a, const vtkm::Vec<T, 4>& b
1388 )
1389 {
1390  return vtkm::Vec<T, 4>(a[0] / b[0], a[1] / b[1], a[2] / b[2], a[3] / b[3]);
1391 }
1392 
1393 // Vec_Scalar for ['T', 'T']
1394 template <typename T>
1396  const vtkm::Vec<T, 4>& a, T scalar
1397 )
1398 {
1399  return vtkm::Vec<T, 4>(a[0] / scalar, a[1] / scalar, a[2] / scalar, a[3] / scalar);
1400 }
1401 
1402 // Vec_Scalar for ['T', 'vtkm::Float64']
1403 template <typename T>
1405  const vtkm::Vec<T, 4>& a, vtkm::Float64 scalar
1406 )
1407 {
1408  return vtkm::Vec<T, 4>(a[0] / scalar, a[1] / scalar, a[2] / scalar, a[3] / scalar);
1409 }
1410 
1411 // Vec_Scalar for ['vtkm::Float64', 'vtkm::Float64']
1414 )
1415 {
1416  return vtkm::Vec<vtkm::Float64, 4>(a[0] / scalar, a[1] / scalar, a[2] / scalar, a[3] / scalar);
1417 }
1418 
1419 // Scalar_Vec for ['T', 'T']
1420 template <typename T>
1422  T scalar, const vtkm::Vec<T, 4>& a
1423 )
1424 {
1425  return vtkm::Vec<T, 4>(scalar / a[0], scalar / a[1], scalar / a[2], scalar / a[3]);
1426 }
1427 
1428 // Scalar_Vec for ['T', 'vtkm::Float64']
1429 template <typename T>
1431  vtkm::Float64 scalar, const vtkm::Vec<T, 4>& a
1432 )
1433 {
1434  return vtkm::Vec<T, 4>(scalar / a[0], scalar / a[1], scalar / a[2], scalar / a[3]);
1435 }
1436 
1437 // Scalar_Vec for ['vtkm::Float64', 'vtkm::Float64']
1440 )
1441 {
1442  return vtkm::Vec<vtkm::Float64, 4>(scalar / a[0], scalar / a[1], scalar / a[2], scalar / a[3]);
1443 }
1444 
1445 //}}}
1446 
1447 
1448 #if defined(VTKM_MSVC)
1449 #pragma warning(pop)
1450 #endif
1451 
1452 #if (defined(VTKM_CUDA) && (__CUDACC_VER_MAJOR__ < 8))
1453 #if (defined(VTKM_GCC) || defined(VTKM_CLANG))
1454 #pragma GCC diagnostic pop
1455 #endif // gcc || clang
1456 #endif // use cuda < 8
1457 
1458 }
1459 
1460 // clang-format on
1461 #endif //vtk_m_internal_VecOperators_h
vtkm
Groups connected points that have the same field value.
Definition: Atomic.h:19
VTKM_EXEC_CONT
#define VTKM_EXEC_CONT
Definition: ExportMacros.h:52
vtkm::operator/
VTKM_EXEC_CONT vtkm::Vec< T, Size > operator/(vtkm::Vec< T, Size > a, const vtkm::Vec< T, Size > &b)
Definition: VecOperators.h:371
vtkm::Vec< T, 1 >
Definition: Types.h:837
vtkm::operator*
VTKM_EXEC_CONT vtkm::Vec< T, Size > operator*(vtkm::Vec< T, Size > a, const vtkm::Vec< T, Size > &b)
Definition: VecOperators.h:185
vtkm::operator+
VTKM_EXEC_CONT vtkm::Vec< T, Size > operator+(vtkm::Vec< T, Size > a, const vtkm::Vec< T, Size > &b)
Definition: VecOperators.h:92
vtkm::Vec< T, 4 >
Definition: Types.h:1093
vtkm::operator-
VTKM_EXEC_CONT std::enable_if<(std::is_floating_point< T >::value||std::is_signed< T >::value), vtkm::Vec< T, Size > >::type operator-(vtkm::Vec< T, Size > x)
Definition: VecOperators.h:41
vtkm::Vec< T, 2 >
Definition: Types.h:859
vtkm::Vec< T, 3 >
Definition: Types.h:975
vtkm::Vec
A short fixed-length array.
Definition: Types.h:767
vtkm::Float64
double Float64
Definition: Types.h:155