Openholo  v4.2
Open Source Digital Holographic Library
ivec.h
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
46 #ifndef __ivec_h
47 #define __ivec_h
48 //|
49 //| ivec : n-dimensional ivector
50 //|
51 
52 #include <stdio.h>
53 #ifndef OPH_DLL
54 #ifdef _WIN32
55 #define OPH_DLL __declspec(dllexport)
56 #else
57 #define OPH_DLL __attribute__((visibility("default")))
58 #endif
59 #endif
60 
61 namespace oph {
62 
66  struct OPH_DLL ivec2 {
67  int v[2];
68  static const int n;
69 
70  inline ivec2()
71  {
72  v[0] = v[1] = 0;
73  };
74 
75  inline ivec2(int a)
76  {
77  v[0] = a; v[1] = a;
78  }
79 
80  inline ivec2(int v_1, int v_2)
81  {
82  v[0] = v_1; v[1] = v_2;
83  }
84 
85  inline ivec2(const ivec2& a)
86  {
87  v[0] = a[0]; v[1] = a[1];
88  }
89 
90  inline ivec2& operator=(const ivec2& a)
91  {
92  v[0] = a[0]; v[1] = a[1];
93  return *this;
94  }
95 
96 
97  inline int& operator[] (int i) { return v[i]; }
98  inline const int& operator[] (int i) const { return v[i]; }
99  inline int& operator() (int i) { return v[i % 2]; }
100  inline const int& operator() (int i) const { return v[i % 2]; }
101  };
102 
103 
104 
105 
106  //| binary op : componentwise
107 
108 
109  inline ivec2 operator + (const ivec2& a, const ivec2& b)
110  {
111  ivec2 c;
112  for (int i = 0; i < 2; ++i) { c[i] = a[i] + b[i]; }
113  return c;
114  }
115 
116  inline ivec2 operator + (int a, const ivec2& b)
117  {
118  ivec2 c;
119  for (int i = 0; i < 2; ++i) { c[i] = a + b[i]; }
120  return c;
121  }
122 
123  inline ivec2 operator + (const ivec2& a, int b)
124  {
125  ivec2 c;
126  for (int i = 0; i < 2; ++i) { c[i] = a[i] + b; }
127  return c;
128  }
129 
130 
131 
132  inline ivec2 operator - (const ivec2& a, const ivec2& b)
133  {
134  ivec2 c;
135  for (int i = 0; i < 2; ++i) { c[i] = a[i] - b[i]; }
136  return c;
137  }
138 
139  inline ivec2 operator - (int a, const ivec2& b)
140  {
141  ivec2 c;
142  for (int i = 0; i < 2; ++i) { c[i] = a - b[i]; }
143  return c;
144  }
145 
146  inline ivec2 operator - (const ivec2& a, int b)
147  {
148  ivec2 c;
149  for (int i = 0; i < 2; ++i) { c[i] = a[i] - b; }
150  return c;
151  }
152 
153 
154 
155  inline ivec2 operator * (const ivec2& a, const ivec2& b)
156  {
157  ivec2 c;
158  for (int i = 0; i < 2; ++i) { c[i] = a[i] * b[i]; }
159  return c;
160  }
161 
162  inline ivec2 operator * (int a, const ivec2& b)
163  {
164  ivec2 c;
165  for (int i = 0; i < 2; ++i) { c[i] = a * b[i]; }
166  return c;
167  }
168 
169  inline ivec2 operator * (const ivec2& a, int b)
170  {
171  ivec2 c;
172  for (int i = 0; i < 2; ++i) { c[i] = a[i] * b; }
173  return c;
174  }
175 
176 
177  //
178  //inline ivec2 operator / (const ivec2& a, const ivec2& b)
179  //{
180  // ivec2 c;
181  // for(int i = 0; i < 2;++i) { c[i] = a[i] / b[i]; }
182  // return c;
183  //}
184  //
185  //inline ivec2 operator / (int a, const ivec2& b)
186  //{
187  // ivec2 c;
188  // for(int i = 0; i < 2;++i) { c[i] = a / b[i]; }
189  // return c;
190  //}
191  //
192  //inline ivec2 operator / (const ivec2& a, int b)
193  //{
194  // ivec2 c;
195  // for(int i = 0; i < 2;++i) { c[i] = a[i] / b; }
196  // return c;
197  //}
198 
199 
200 
201  //| cumulative op : componentwise
202 
203 
204  inline ivec2 operator += (ivec2& a, const ivec2& b)
205  {
206  return a = (a + b);
207  }
208 
209  inline ivec2 operator += (ivec2& a, int b)
210  {
211  return a = (a + b);
212  }
213 
214 
215 
216  inline ivec2 operator -= (ivec2& a, const ivec2& b)
217  {
218  return a = (a - b);
219  }
220 
221  inline ivec2 operator -= (ivec2& a, int b)
222  {
223  return a = (a - b);
224  }
225 
226 
227 
228  inline ivec2 operator *= (ivec2& a, const ivec2& b)
229  {
230  return a = (a * b);
231  }
232 
233  inline ivec2 operator *= (ivec2& a, int b)
234  {
235  return a = (a * b);
236  }
237 
238 
239 
240  //inline ivec2 operator /= (ivec2& a, const ivec2& b)
241  //{
242  // return a = (a / b);
243  //}
244  //
245  //inline ivec2 operator /= (ivec2& a, int b)
246  //{
247  // return a = (a / b);
248  //}
249 
250 
251 
252  //| logical op : componentwise
253 
254 
255  inline int operator == (const ivec2& a, const ivec2& b)
256  {
257  int c = 1;
258  for (int i = 0; i < 2; ++i) { c = c & (a[i] == b[i]); }
259  return c;
260  }
261 
262  inline int operator == (int a, const ivec2& b)
263  {
264  int c = 1;
265  for (int i = 0; i < 2; ++i) { c = c & (a == b[i]); }
266  return c;
267  }
268 
269  inline int operator == (const ivec2& a, int b)
270  {
271  int c = 1;
272  for (int i = 0; i < 2; ++i) { c = c & (a[i] == b); }
273  return c;
274  }
275 
276 
277 
278  inline int operator < (const ivec2& a, const ivec2& b)
279  {
280  int c = 1;
281  for (int i = 0; i < 2; ++i) { c = c & (a[i] < b[i]); }
282  return c;
283  }
284 
285  inline int operator < (int a, const ivec2& b)
286  {
287  int c = 1;
288  for (int i = 0; i < 2; ++i) { c = c & (a < b[i]); }
289  return c;
290  }
291 
292  inline int operator < (const ivec2& a, int b)
293  {
294  int c = 1;
295  for (int i = 0; i < 2; ++i) { c = c & (a[i] < b); }
296  return c;
297  }
298 
299 
300 
301  inline int operator <= (const ivec2& a, const ivec2& b)
302  {
303  int c = 1;
304  for (int i = 0; i < 2; ++i) { c = c & (a[i] <= b[i]); }
305  return c;
306  }
307 
308  inline int operator <= (int a, const ivec2& b)
309  {
310  int c = 1;
311  for (int i = 0; i < 2; ++i) { c = c & (a <= b[i]); }
312  return c;
313  }
314 
315  inline int operator <= (const ivec2& a, int b)
316  {
317  int c = 1;
318  for (int i = 0; i < 2; ++i) { c = c & (a[i] <= b); }
319  return c;
320  }
321 
322 
323 
324  inline int operator > (const ivec2& a, const ivec2& b)
325  {
326  int c = 1;
327  for (int i = 0; i < 2; ++i) { c = c & (a[i] > b[i]); }
328  return c;
329  }
330 
331  inline int operator > (int a, const ivec2& b)
332  {
333  int c = 1;
334  for (int i = 0; i < 2; ++i) { c = c & (a > b[i]); }
335  return c;
336  }
337 
338  inline int operator > (const ivec2& a, int b)
339  {
340  int c = 1;
341  for (int i = 0; i < 2; ++i) { c = c & (a[i] > b); }
342  return c;
343  }
344 
345 
346 
347 
348  inline int operator >= (const ivec2& a, const ivec2& b)
349  {
350  int c = 1;
351  for (int i = 0; i < 2; ++i) { c = c & (a[i] >= b[i]); }
352  return c;
353  }
354  inline int operator >= (int a, const ivec2& b)
355  {
356  int c = 1;
357  for (int i = 0; i < 2; ++i) { c = c & (a >= b[i]); }
358  return c;
359  }
360 
361  inline int operator >= (const ivec2& a, int b)
362  {
363  int c = 1;
364  for (int i = 0; i < 2; ++i) { c = c & (a[i] >= b); }
365  return c;
366  }
367 
368  inline int operator != (const ivec2& a, const ivec2& b)
369  {
370  int c = 1;
371  for (int i = 0; i < 2; ++i) { c = c & (a[i] != b[i]); }
372  return c;
373  }
374 
375  //| unary op : componentwise
376  inline ivec2 operator - (const ivec2& a)
377  {
378  ivec2 c;
379  for (int i = 0; i < 2; ++i) { c[i] = -a[i]; }
380  return c;
381  }
382 
386  struct OPH_DLL ivec3 {
387  int v[3];
388  static const int n;
389 
390  inline ivec3()
391  {
392  v[0] = v[1] = v[2] = 0;
393  };
394 
395  inline ivec3(int a)
396  {
397  v[0] = v[1] = v[2] = a;
398  }
399 
400  inline ivec3(int v_1, int v_2, int v_3)
401  {
402  v[0] = v_1; v[1] = v_2; v[2] = v_3;
403  }
404 
405  inline ivec3(const ivec3& a)
406  {
407  v[0] = a[0]; v[1] = a[1]; v[2] = a[2];
408  }
409 
410  inline ivec3& operator=(const ivec3& a)
411  {
412  v[0] = a[0]; v[1] = a[1]; v[2] = a[2];
413  return *this;
414  }
415 
416 
417  inline int& operator[] (int i) { return v[i]; }
418  inline const int& operator[] (int i) const { return v[i]; }
419  inline int& operator() (int i) { return v[i % 3]; }
420  inline const int& operator() (int i) const { return v[i % 3]; }
421  };
422  //| binary op : componentwise
423 
424  inline ivec3 operator + (const ivec3& a, const ivec3& b)
425  {
426  ivec3 c;
427  for (int i = 0; i < 3; ++i) { c[i] = a[i] + b[i]; }
428  return c;
429  }
430 
431  inline ivec3 operator + (int a, const ivec3& b)
432  {
433  ivec3 c;
434  for (int i = 0; i < 3; ++i) { c[i] = a + b[i]; }
435  return c;
436  }
437 
438  inline ivec3 operator + (const ivec3& a, int b)
439  {
440  ivec3 c;
441  for (int i = 0; i < 3; ++i) { c[i] = a[i] + b; }
442  return c;
443  }
444 
445 
446 
447  inline ivec3 operator - (const ivec3& a, const ivec3& b)
448  {
449  ivec3 c;
450  for (int i = 0; i < 3; ++i) { c[i] = a[i] - b[i]; }
451  return c;
452  }
453 
454  inline ivec3 operator - (int a, const ivec3& b)
455  {
456  ivec3 c;
457  for (int i = 0; i < 3; ++i) { c[i] = a - b[i]; }
458  return c;
459  }
460 
461  inline ivec3 operator - (const ivec3& a, int b)
462  {
463  ivec3 c;
464  for (int i = 0; i < 3; ++i) { c[i] = a[i] - b; }
465  return c;
466  }
467 
468 
469 
470  inline ivec3 operator * (const ivec3& a, const ivec3& b)
471  {
472  ivec3 c;
473  for (int i = 0; i < 3; ++i) { c[i] = a[i] * b[i]; }
474  return c;
475  }
476 
477  inline ivec3 operator * (int a, const ivec3& b)
478  {
479  ivec3 c;
480  for (int i = 0; i < 3; ++i) { c[i] = a * b[i]; }
481  return c;
482  }
483 
484  inline ivec3 operator * (const ivec3& a, int b)
485  {
486  ivec3 c;
487  for (int i = 0; i < 3; ++i) { c[i] = a[i] * b; }
488  return c;
489  }
490 
491  //
492  //
493  //inline ivec3 operator / (const ivec3& a, const ivec3& b)
494  //{
495  // ivec3 c;
496  // for(int i = 0; i < 3;++i) { c[i] = a[i] / b[i]; }
497  // return c;
498  //}
499  //
500  //inline ivec3 operator / (int a, const ivec3& b)
501  //{
502  // ivec3 c;
503  // for(int i = 0; i < 3;++i) { c[i] = a / b[i]; }
504  // return c;
505  //}
506  //
507  //inline ivec3 operator / (const ivec3& a, int b)
508  //{
509  // ivec3 c;
510  // for(int i = 0; i < 3;++i) { c[i] = a[i] / b; }
511  // return c;
512  //}
513 
514 
515 
516  //| cumulative op : componentwise
517 
518 
519  inline ivec3 operator += (ivec3& a, const ivec3& b)
520  {
521  return a = (a + b);
522  }
523 
524  inline ivec3 operator += (ivec3& a, int b)
525  {
526  return a = (a + b);
527  }
528 
529 
530 
531  inline ivec3 operator -= (ivec3& a, const ivec3& b)
532  {
533  return a = (a - b);
534  }
535 
536  inline ivec3 operator -= (ivec3& a, int b)
537  {
538  return a = (a - b);
539  }
540 
541 
542 
543  inline ivec3 operator *= (ivec3& a, const ivec3& b)
544  {
545  return a = (a * b);
546  }
547 
548  inline ivec3 operator *= (ivec3& a, int b)
549  {
550  return a = (a * b);
551  }
552 
553 
554  //
555  //inline ivec3 operator /= (ivec3& a, const ivec3& b)
556  //{
557  // return a = (a / b);
558  //}
559  //
560  //inline ivec3 operator /= (ivec3& a, int b)
561  //{
562  // return a = (a / b);
563  //}
564 
565 
566 
567  //| logical op : componentwise
568 
569 
570  inline int operator == (const ivec3& a, const ivec3& b)
571  {
572  int c = 1;
573  for (int i = 0; i < 3; ++i) { c = c & (a[i] == b[i]); }
574  return c;
575  }
576 
577  inline int operator == (int a, const ivec3& b)
578  {
579  int c = 1;
580  for (int i = 0; i < 3; ++i) { c = c & (a == b[i]); }
581  return c;
582  }
583 
584  inline int operator == (const ivec3& a, int b)
585  {
586  int c = 1;
587  for (int i = 0; i < 3; ++i) { c = c & (a[i] == b); }
588  return c;
589  }
590 
591 
592 
593  inline int operator < (const ivec3& a, const ivec3& b)
594  {
595  int c = 1;
596  for (int i = 0; i < 3; ++i) { c = c & (a[i] < b[i]); }
597  return c;
598  }
599 
600  inline int operator < (int a, const ivec3& b)
601  {
602  int c = 1;
603  for (int i = 0; i < 3; ++i) { c = c & (a < b[i]); }
604  return c;
605  }
606 
607  inline int operator < (const ivec3& a, int b)
608  {
609  int c = 1;
610  for (int i = 0; i < 3; ++i) { c = c & (a[i] < b); }
611  return c;
612  }
613 
614 
615 
616  inline int operator <= (const ivec3& a, const ivec3& b)
617  {
618  int c = 1;
619  for (int i = 0; i < 3; ++i) { c = c & (a[i] <= b[i]); }
620  return c;
621  }
622 
623  inline int operator <= (int a, const ivec3& b)
624  {
625  int c = 1;
626  for (int i = 0; i < 3; ++i) { c = c & (a <= b[i]); }
627  return c;
628  }
629 
630  inline int operator <= (const ivec3& a, int b)
631  {
632  int c = 1;
633  for (int i = 0; i < 3; ++i) { c = c & (a[i] <= b); }
634  return c;
635  }
636 
637 
638 
639  inline int operator > (const ivec3& a, const ivec3& b)
640  {
641  int c = 1;
642  for (int i = 0; i < 3; ++i) { c = c & (a[i] > b[i]); }
643  return c;
644  }
645 
646  inline int operator > (int a, const ivec3& b)
647  {
648  int c = 1;
649  for (int i = 0; i < 3; ++i) { c = c & (a > b[i]); }
650  return c;
651  }
652 
653  inline int operator > (const ivec3& a, int b)
654  {
655  int c = 1;
656  for (int i = 0; i < 3; ++i) { c = c & (a[i] > b); }
657  return c;
658  }
659 
660 
661 
662  inline int operator >= (const ivec3& a, const ivec3& b)
663  {
664  int c = 1;
665  for (int i = 0; i < 3; ++i) { c = c & (a[i] >= b[i]); }
666  return c;
667  }
668 
669  inline int operator >= (int a, const ivec3& b)
670  {
671  int c = 1;
672  for (int i = 0; i < 3; ++i) { c = c & (a >= b[i]); }
673  return c;
674  }
675 
676  inline int operator >= (const ivec3& a, int b)
677  {
678  int c = 1;
679  for (int i = 0; i < 3; ++i) { c = c & (a[i] >= b); }
680  return c;
681  }
682 
683  inline int operator != (const ivec3& a, const ivec3& b)
684  {
685  int c = 1;
686  for (int i = 0; i < 3; ++i) { c = c & (a[i] != b[i]); }
687  return c;
688  }
689 
690  //| unary op : componentwise
691  inline ivec3 operator - (const ivec3& a)
692  {
693  ivec3 c;
694  for (int i = 0; i < 3; ++i) { c[i] = -a[i]; }
695  return c;
696  }
697 
701  struct OPH_DLL ivec4 {
702  int v[4];
703  static const int n;
704 
705  inline ivec4()
706  {
707  v[0] = v[1] = v[2] = v[3] = 0;
708  };
709 
710  inline ivec4(int a)
711  {
712  v[0] = a; v[1] = a; v[2] = a; v[3] = a;
713  }
714 
715  inline ivec4(int v_1, int v_2, int v_3, int v_4)
716  {
717  v[0] = v_1; v[1] = v_2; v[2] = v_3; v[3] = v_4;
718  }
719 
720  inline ivec4(const ivec4& a)
721  {
722  v[0] = a[0]; v[1] = a[1]; v[2] = a[2]; v[3] = a[3];
723  }
724 
725  inline ivec4& operator=(const ivec4& a)
726  {
727  v[0] = a[0]; v[1] = a[1]; v[2] = a[2]; v[3] = a[3];
728  return *this;
729  }
730 
731 
732  inline int& operator[] (int i) { return v[i]; }
733  inline const int& operator[] (int i) const { return v[i]; }
734  inline int& operator() (int i) { return v[i % 4]; }
735  inline const int& operator() (int i) const { return v[i % 4]; }
736  };
737 
738 
739 
740 
741  //| binary op : componentwise
742 
743 
744  inline ivec4 operator + (const ivec4& a, const ivec4& b)
745  {
746  ivec4 c;
747  for (int i = 0; i < 4; ++i) { c[i] = a[i] + b[i]; }
748  return c;
749  }
750 
751  inline ivec4 operator + (int a, const ivec4& b)
752  {
753  ivec4 c;
754  for (int i = 0; i < 4; ++i) { c[i] = a + b[i]; }
755  return c;
756  }
757 
758  inline ivec4 operator + (const ivec4& a, int b)
759  {
760  ivec4 c;
761  for (int i = 0; i < 4; ++i) { c[i] = a[i] + b; }
762  return c;
763  }
764 
765 
766 
767  inline ivec4 operator - (const ivec4& a, const ivec4& b)
768  {
769  ivec4 c;
770  for (int i = 0; i < 4; ++i) { c[i] = a[i] - b[i]; }
771  return c;
772  }
773 
774  inline ivec4 operator - (int a, const ivec4& b)
775  {
776  ivec4 c;
777  for (int i = 0; i < 4; ++i) { c[i] = a - b[i]; }
778  return c;
779  }
780 
781  inline ivec4 operator - (const ivec4& a, int b)
782  {
783  ivec4 c;
784  for (int i = 0; i < 4; ++i) { c[i] = a[i] - b; }
785  return c;
786  }
787 
788 
789 
790  inline ivec4 operator * (const ivec4& a, const ivec4& b)
791  {
792  ivec4 c;
793  for (int i = 0; i < 4; ++i) { c[i] = a[i] * b[i]; }
794  return c;
795  }
796 
797  inline ivec4 operator * (int a, const ivec4& b)
798  {
799  ivec4 c;
800  for (int i = 0; i < 4; ++i) { c[i] = a * b[i]; }
801  return c;
802  }
803 
804  inline ivec4 operator * (const ivec4& a, int b)
805  {
806  ivec4 c;
807  for (int i = 0; i < 4; ++i) { c[i] = a[i] * b; }
808  return c;
809  }
810 
811 
812  //
813  //inline ivec4 operator / (const ivec4& a, const ivec4& b)
814  //{
815  // ivec4 c;
816  // for(int i = 0; i < 4;++i) { c[i] = a[i] / b[i]; }
817  // return c;
818  //}
819  //
820  //inline ivec4 operator / (int a, const ivec4& b)
821  //{
822  // ivec4 c;
823  // for(int i = 0; i < 4;++i) { c[i] = a / b[i]; }
824  // return c;
825  //}
826  //
827  //inline ivec4 operator / (const ivec4& a, int b)
828  //{
829  // ivec4 c;
830  // for(int i = 0; i < 4;++i) { c[i] = a[i] / b; }
831  // return c;
832  //}
833 
834 
835 
836  //| cumulative op : componentwise
837 
838 
839  inline ivec4 operator += (ivec4& a, const ivec4& b)
840  {
841  return a = (a + b);
842  }
843 
844  inline ivec4 operator += (ivec4& a, int b)
845  {
846  return a = (a + b);
847  }
848 
849 
850 
851  inline ivec4 operator -= (ivec4& a, const ivec4& b)
852  {
853  return a = (a - b);
854  }
855 
856  inline ivec4 operator -= (ivec4& a, int b)
857  {
858  return a = (a - b);
859  }
860 
861 
862 
863  inline ivec4 operator *= (ivec4& a, const ivec4& b)
864  {
865  return a = (a * b);
866  }
867 
868  inline ivec4 operator *= (ivec4& a, int b)
869  {
870  return a = (a * b);
871  }
872 
873 
874 
875  //inline ivec4 operator /= (ivec4& a, const ivec4& b)
876  //{
877  // return a = (a / b);
878  //}
879  //
880  //inline ivec4 operator /= (ivec4& a, int b)
881  //{
882  // return a = (a / b);
883  //}
884 
885 
886 
887  //| logical op : componentwise
888 
889 
890  inline int operator == (const ivec4& a, const ivec4& b)
891  {
892  int c = 1;
893  for (int i = 0; i < 4; ++i) { c = c & (a[i] == b[i]); }
894  return c;
895  }
896 
897  inline int operator == (int a, const ivec4& b)
898  {
899  int c = 1;
900  for (int i = 0; i < 4; ++i) { c = c & (a == b[i]); }
901  return c;
902  }
903 
904  inline int operator == (const ivec4& a, int b)
905  {
906  int c = 1;
907  for (int i = 0; i < 4; ++i) { c = c & (a[i] == b); }
908  return c;
909  }
910 
911 
912 
913  inline int operator < (const ivec4& a, const ivec4& b)
914  {
915  int c = 1;
916  for (int i = 0; i < 4; ++i) { c = c & (a[i] < b[i]); }
917  return c;
918  }
919 
920  inline int operator < (int a, const ivec4& b)
921  {
922  int c = 1;
923  for (int i = 0; i < 4; ++i) { c = c & (a < b[i]); }
924  return c;
925  }
926 
927  inline int operator < (const ivec4& a, int b)
928  {
929  int c = 1;
930  for (int i = 0; i < 4; ++i) { c = c & (a[i] < b); }
931  return c;
932  }
933 
934 
935 
936  inline int operator <= (const ivec4& a, const ivec4& b)
937  {
938  int c = 1;
939  for (int i = 0; i < 4; ++i) { c = c & (a[i] <= b[i]); }
940  return c;
941  }
942 
943  inline int operator <= (int a, const ivec4& b)
944  {
945  int c = 1;
946  for (int i = 0; i < 4; ++i) { c = c & (a <= b[i]); }
947  return c;
948  }
949 
950  inline int operator <= (const ivec4& a, int b)
951  {
952  int c = 1;
953  for (int i = 0; i < 4; ++i) { c = c & (a[i] <= b); }
954  return c;
955  }
956 
957 
958 
959  inline int operator > (const ivec4& a, const ivec4& b)
960  {
961  int c = 1;
962  for (int i = 0; i < 4; ++i) { c = c & (a[i] > b[i]); }
963  return c;
964  }
965 
966  inline int operator > (int a, const ivec4& b)
967  {
968  int c = 1;
969  for (int i = 0; i < 4; ++i) { c = c & (a > b[i]); }
970  return c;
971  }
972 
973  inline int operator > (const ivec4& a, int b)
974  {
975  int c = 1;
976  for (int i = 0; i < 4; ++i) { c = c & (a[i] > b); }
977  return c;
978  }
979 
980 
981 
982  inline int operator >= (const ivec4& a, const ivec4& b)
983  {
984  int c = 1;
985  for (int i = 0; i < 4; ++i) { c = c & (a[i] >= b[i]); }
986  return c;
987  }
988 
989  inline int operator != (const ivec4& a, const ivec4& b)
990  {
991  int c = 1;
992  for (int i = 0; i < 4; ++i) { c = c & (a[i] != b[i]); }
993  return c;
994  }
995 
996  inline int operator >= (int a, const ivec4& b)
997  {
998  int c = 1;
999  for (int i = 0; i < 4; ++i) { c = c & (a >= b[i]); }
1000  return c;
1001  }
1002 
1003  inline int operator >= (const ivec4& a, int b)
1004  {
1005  int c = 1;
1006  for (int i = 0; i < 4; ++i) { c = c & (a[i] >= b); }
1007  return c;
1008  }
1009 
1010 
1011 
1012  //| unary op : componentwise
1013  inline ivec4 operator - (const ivec4& a)
1014  {
1015  ivec4 c;
1016  for (int i = 0; i < 4; ++i) { c[i] = -a[i]; }
1017  return c;
1018  }
1019 
1020 }; //namespace oph
1021 
1022 #endif // !__ivec_h
ivec3(const ivec3 &a)
Definition: ivec.h:405
ivec2 operator+=(ivec2 &a, const ivec2 &b)
Definition: ivec.h:204
ivec2 & operator=(const ivec2 &a)
Definition: ivec.h:90
static const int n
Definition: ivec.h:703
static const int n
Definition: ivec.h:388
ivec3()
Definition: ivec.h:390
ivec4(int v_1, int v_2, int v_3, int v_4)
Definition: ivec.h:715
ivec2 operator-(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:132
ivec2(int v_1, int v_2)
Definition: ivec.h:80
ivec3(int v_1, int v_2, int v_3)
Definition: ivec.h:400
structure for 2-dimensional integer vector and its arithmetic.
Definition: ivec.h:66
int operator>=(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:348
ivec3 & operator=(const ivec3 &a)
Definition: ivec.h:410
ivec2(const ivec2 &a)
Definition: ivec.h:85
ivec2 operator+(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:109
ivec2(int a)
Definition: ivec.h:75
ivec2 operator*(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:155
int operator<=(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:301
ivec2()
Definition: ivec.h:70
structure for 4-dimensional integer vector and its arithmetic.
Definition: ivec.h:701
static const int n
Definition: ivec.h:68
ivec4(int a)
Definition: ivec.h:710
ivec2 operator-=(ivec2 &a, const ivec2 &b)
Definition: ivec.h:216
int operator>(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:324
int operator!=(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:368
ivec4()
Definition: ivec.h:705
int operator==(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:255
ivec3(int a)
Definition: ivec.h:395
structure for 3-dimensional integer vector and its arithmetic.
Definition: ivec.h:386
int operator<(const ivec2 &a, const ivec2 &b)
Definition: ivec.h:278
ivec4(const ivec4 &a)
Definition: ivec.h:720
Definition: Bitmap.h:49
ivec4 & operator=(const ivec4 &a)
Definition: ivec.h:725
ivec2 operator*=(ivec2 &a, const ivec2 &b)
Definition: ivec.h:228
#define OPH_DLL
Definition: ivec.h:57