COVISE Core
cutil_math.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8/*
9 * Copyright 1993-2010 NVIDIA Corporation. All rights reserved.
10 *
11 * Please refer to the NVIDIA end user license agreement (EULA) associated
12 * with this source code for terms and conditions that govern your use of
13 * this software. Any use, reproduction, disclosure, or distribution of
14 * this software and related documentation outside the terms of the EULA
15 * is strictly prohibited.
16 *
17 */
18
19/*
20 This file implements common mathematical operations on vector types
21 (float3, float4 etc.) since these are not provided as standard by CUDA.
22
23 The syntax is modelled on the Cg standard library.
24
25 This is part of the CUTIL library and is not supported by NVIDIA.
26
27 Thanks to Linh Hah for additions and fixes.
28*/
29
30#ifndef CUTIL_MATH_H
31#define CUTIL_MATH_H
32
33#include <cuda_runtime.h>
34
35typedef unsigned int uint;
36typedef unsigned short ushort;
37
38#ifndef __CUDACC__
39#include <math.h>
40
42// host implementations of CUDA functions
44
45inline float fminf(float a, float b)
46{
47 return a < b ? a : b;
48}
49
50inline float fmaxf(float a, float b)
51{
52 return a > b ? a : b;
53}
54
55inline int max(int a, int b)
56{
57 return a > b ? a : b;
58}
59
60inline int min(int a, int b)
61{
62 return a < b ? a : b;
63}
64
65inline float rsqrtf(float x)
66{
67 return 1.0f / sqrtf(x);
68}
69#endif
70
72// constructors
74
75inline __host__ __device__ float2 make_float2(float s)
76{
77 return make_float2(s, s);
78}
79inline __host__ __device__ float2 make_float2(float3 a)
80{
81 return make_float2(a.x, a.y);
82}
83inline __host__ __device__ float2 make_float2(int2 a)
84{
85 return make_float2(float(a.x), float(a.y));
86}
87inline __host__ __device__ float2 make_float2(uint2 a)
88{
89 return make_float2(float(a.x), float(a.y));
90}
91
92inline __host__ __device__ int2 make_int2(int s)
93{
94 return make_int2(s, s);
95}
96inline __host__ __device__ int2 make_int2(int3 a)
97{
98 return make_int2(a.x, a.y);
99}
100inline __host__ __device__ int2 make_int2(uint2 a)
101{
102 return make_int2(int(a.x), int(a.y));
103}
104inline __host__ __device__ int2 make_int2(float2 a)
105{
106 return make_int2(int(a.x), int(a.y));
107}
108
109inline __host__ __device__ uint2 make_uint2(uint s)
110{
111 return make_uint2(s, s);
112}
113inline __host__ __device__ uint2 make_uint2(uint3 a)
114{
115 return make_uint2(a.x, a.y);
116}
117inline __host__ __device__ uint2 make_uint2(int2 a)
118{
119 return make_uint2(uint(a.x), uint(a.y));
120}
121
122inline __host__ __device__ float3 make_float3(float s)
123{
124 return make_float3(s, s, s);
125}
126inline __host__ __device__ float3 make_float3(float2 a)
127{
128 return make_float3(a.x, a.y, 0.0f);
129}
130inline __host__ __device__ float3 make_float3(float2 a, float s)
131{
132 return make_float3(a.x, a.y, s);
133}
134inline __host__ __device__ float3 make_float3(float4 a)
135{
136 return make_float3(a.x, a.y, a.z);
137}
138inline __host__ __device__ float3 make_float3(int3 a)
139{
140 return make_float3(float(a.x), float(a.y), float(a.z));
141}
142inline __host__ __device__ float3 make_float3(uint3 a)
143{
144 return make_float3(float(a.x), float(a.y), float(a.z));
145}
146
147inline __host__ __device__ int3 make_int3(int s)
148{
149 return make_int3(s, s, s);
150}
151inline __host__ __device__ int3 make_int3(int2 a)
152{
153 return make_int3(a.x, a.y, 0);
154}
155inline __host__ __device__ int3 make_int3(int2 a, int s)
156{
157 return make_int3(a.x, a.y, s);
158}
159inline __host__ __device__ int3 make_int3(uint3 a)
160{
161 return make_int3(int(a.x), int(a.y), int(a.z));
162}
163inline __host__ __device__ int3 make_int3(float3 a)
164{
165 return make_int3(int(a.x), int(a.y), int(a.z));
166}
167
168inline __host__ __device__ uint3 make_uint3(uint s)
169{
170 return make_uint3(s, s, s);
171}
172inline __host__ __device__ uint3 make_uint3(uint2 a)
173{
174 return make_uint3(a.x, a.y, 0);
175}
176inline __host__ __device__ uint3 make_uint3(uint2 a, uint s)
177{
178 return make_uint3(a.x, a.y, s);
179}
180inline __host__ __device__ uint3 make_uint3(uint4 a)
181{
182 return make_uint3(a.x, a.y, a.z);
183}
184inline __host__ __device__ uint3 make_uint3(int3 a)
185{
186 return make_uint3(uint(a.x), uint(a.y), uint(a.z));
187}
188
189inline __host__ __device__ float4 make_float4(float s)
190{
191 return make_float4(s, s, s, s);
192}
193inline __host__ __device__ float4 make_float4(float3 a)
194{
195 return make_float4(a.x, a.y, a.z, 0.0f);
196}
197inline __host__ __device__ float4 make_float4(float3 a, float w)
198{
199 return make_float4(a.x, a.y, a.z, w);
200}
201inline __host__ __device__ float4 make_float4(int4 a)
202{
203 return make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
204}
205inline __host__ __device__ float4 make_float4(uint4 a)
206{
207 return make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
208}
209
210inline __host__ __device__ int4 make_int4(int s)
211{
212 return make_int4(s, s, s, s);
213}
214inline __host__ __device__ int4 make_int4(int3 a)
215{
216 return make_int4(a.x, a.y, a.z, 0);
217}
218inline __host__ __device__ int4 make_int4(int3 a, int w)
219{
220 return make_int4(a.x, a.y, a.z, w);
221}
222inline __host__ __device__ int4 make_int4(uint4 a)
223{
224 return make_int4(int(a.x), int(a.y), int(a.z), int(a.w));
225}
226inline __host__ __device__ int4 make_int4(float4 a)
227{
228 return make_int4(int(a.x), int(a.y), int(a.z), int(a.w));
229}
230
231inline __host__ __device__ uint4 make_uint4(uint s)
232{
233 return make_uint4(s, s, s, s);
234}
235inline __host__ __device__ uint4 make_uint4(uint3 a)
236{
237 return make_uint4(a.x, a.y, a.z, 0);
238}
239inline __host__ __device__ uint4 make_uint4(uint3 a, uint w)
240{
241 return make_uint4(a.x, a.y, a.z, w);
242}
243inline __host__ __device__ uint4 make_uint4(int4 a)
244{
245 return make_uint4(uint(a.x), uint(a.y), uint(a.z), uint(a.w));
246}
247
249// negate
251
252inline __host__ __device__ float2 operator-(float2 &a)
253{
254 return make_float2(-a.x, -a.y);
255}
256inline __host__ __device__ int2 operator-(int2 &a)
257{
258 return make_int2(-a.x, -a.y);
259}
260inline __host__ __device__ float3 operator-(float3 &a)
261{
262 return make_float3(-a.x, -a.y, -a.z);
263}
264inline __host__ __device__ int3 operator-(int3 &a)
265{
266 return make_int3(-a.x, -a.y, -a.z);
267}
268inline __host__ __device__ float4 operator-(float4 &a)
269{
270 return make_float4(-a.x, -a.y, -a.z, -a.w);
271}
272inline __host__ __device__ int4 operator-(int4 &a)
273{
274 return make_int4(-a.x, -a.y, -a.z, -a.w);
275}
276
278// addition
280
281inline __host__ __device__ float2 operator+(float2 a, float2 b)
282{
283 return make_float2(a.x + b.x, a.y + b.y);
284}
285inline __host__ __device__ void operator+=(float2 &a, float2 b)
286{
287 a.x += b.x;
288 a.y += b.y;
289}
290inline __host__ __device__ float2 operator+(float2 a, float b)
291{
292 return make_float2(a.x + b, a.y + b);
293}
294inline __host__ __device__ float2 operator+(float b, float2 a)
295{
296 return make_float2(a.x + b, a.y + b);
297}
298inline __host__ __device__ void operator+=(float2 &a, float b)
299{
300 a.x += b;
301 a.y += b;
302}
303
304inline __host__ __device__ int2 operator+(int2 a, int2 b)
305{
306 return make_int2(a.x + b.x, a.y + b.y);
307}
308inline __host__ __device__ void operator+=(int2 &a, int2 b)
309{
310 a.x += b.x;
311 a.y += b.y;
312}
313inline __host__ __device__ int2 operator+(int2 a, int b)
314{
315 return make_int2(a.x + b, a.y + b);
316}
317inline __host__ __device__ int2 operator+(int b, int2 a)
318{
319 return make_int2(a.x + b, a.y + b);
320}
321inline __host__ __device__ void operator+=(int2 &a, int b)
322{
323 a.x += b;
324 a.y += b;
325}
326
327inline __host__ __device__ uint2 operator+(uint2 a, uint2 b)
328{
329 return make_uint2(a.x + b.x, a.y + b.y);
330}
331inline __host__ __device__ void operator+=(uint2 &a, uint2 b)
332{
333 a.x += b.x;
334 a.y += b.y;
335}
336inline __host__ __device__ uint2 operator+(uint2 a, uint b)
337{
338 return make_uint2(a.x + b, a.y + b);
339}
340inline __host__ __device__ uint2 operator+(uint b, uint2 a)
341{
342 return make_uint2(a.x + b, a.y + b);
343}
344inline __host__ __device__ void operator+=(uint2 &a, uint b)
345{
346 a.x += b;
347 a.y += b;
348}
349
350inline __host__ __device__ float3 operator+(float3 a, float3 b)
351{
352 return make_float3(a.x + b.x, a.y + b.y, a.z + b.z);
353}
354inline __host__ __device__ void operator+=(float3 &a, float3 b)
355{
356 a.x += b.x;
357 a.y += b.y;
358 a.z += b.z;
359}
360inline __host__ __device__ float3 operator+(float3 a, float b)
361{
362 return make_float3(a.x + b, a.y + b, a.z + b);
363}
364inline __host__ __device__ void operator+=(float3 &a, float b)
365{
366 a.x += b;
367 a.y += b;
368 a.z += b;
369}
370
371inline __host__ __device__ int3 operator+(int3 a, int3 b)
372{
373 return make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
374}
375inline __host__ __device__ void operator+=(int3 &a, int3 b)
376{
377 a.x += b.x;
378 a.y += b.y;
379 a.z += b.z;
380}
381inline __host__ __device__ int3 operator+(int3 a, int b)
382{
383 return make_int3(a.x + b, a.y + b, a.z + b);
384}
385inline __host__ __device__ void operator+=(int3 &a, int b)
386{
387 a.x += b;
388 a.y += b;
389 a.z += b;
390}
391
392inline __host__ __device__ uint3 operator+(uint3 a, uint3 b)
393{
394 return make_uint3(a.x + b.x, a.y + b.y, a.z + b.z);
395}
396inline __host__ __device__ void operator+=(uint3 &a, uint3 b)
397{
398 a.x += b.x;
399 a.y += b.y;
400 a.z += b.z;
401}
402inline __host__ __device__ uint3 operator+(uint3 a, uint b)
403{
404 return make_uint3(a.x + b, a.y + b, a.z + b);
405}
406inline __host__ __device__ void operator+=(uint3 &a, uint b)
407{
408 a.x += b;
409 a.y += b;
410 a.z += b;
411}
412
413inline __host__ __device__ int3 operator+(int b, int3 a)
414{
415 return make_int3(a.x + b, a.y + b, a.z + b);
416}
417inline __host__ __device__ uint3 operator+(uint b, uint3 a)
418{
419 return make_uint3(a.x + b, a.y + b, a.z + b);
420}
421inline __host__ __device__ float3 operator+(float b, float3 a)
422{
423 return make_float3(a.x + b, a.y + b, a.z + b);
424}
425
426inline __host__ __device__ float4 operator+(float4 a, float4 b)
427{
428 return make_float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
429}
430inline __host__ __device__ void operator+=(float4 &a, float4 b)
431{
432 a.x += b.x;
433 a.y += b.y;
434 a.z += b.z;
435 a.w += b.w;
436}
437inline __host__ __device__ float4 operator+(float4 a, float b)
438{
439 return make_float4(a.x + b, a.y + b, a.z + b, a.w + b);
440}
441inline __host__ __device__ float4 operator+(float b, float4 a)
442{
443 return make_float4(a.x + b, a.y + b, a.z + b, a.w + b);
444}
445inline __host__ __device__ void operator+=(float4 &a, float b)
446{
447 a.x += b;
448 a.y += b;
449 a.z += b;
450 a.w += b;
451}
452
453inline __host__ __device__ int4 operator+(int4 a, int4 b)
454{
455 return make_int4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
456}
457inline __host__ __device__ void operator+=(int4 &a, int4 b)
458{
459 a.x += b.x;
460 a.y += b.y;
461 a.z += b.z;
462 a.w += b.w;
463}
464inline __host__ __device__ int4 operator+(int4 a, int b)
465{
466 return make_int4(a.x + b, a.y + b, a.z + b, a.w + b);
467}
468inline __host__ __device__ int4 operator+(int b, int4 a)
469{
470 return make_int4(a.x + b, a.y + b, a.z + b, a.w + b);
471}
472inline __host__ __device__ void operator+=(int4 &a, int b)
473{
474 a.x += b;
475 a.y += b;
476 a.z += b;
477 a.w += b;
478}
479
480inline __host__ __device__ uint4 operator+(uint4 a, uint4 b)
481{
482 return make_uint4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
483}
484inline __host__ __device__ void operator+=(uint4 &a, uint4 b)
485{
486 a.x += b.x;
487 a.y += b.y;
488 a.z += b.z;
489 a.w += b.w;
490}
491inline __host__ __device__ uint4 operator+(uint4 a, uint b)
492{
493 return make_uint4(a.x + b, a.y + b, a.z + b, a.w + b);
494}
495inline __host__ __device__ uint4 operator+(uint b, uint4 a)
496{
497 return make_uint4(a.x + b, a.y + b, a.z + b, a.w + b);
498}
499inline __host__ __device__ void operator+=(uint4 &a, uint b)
500{
501 a.x += b;
502 a.y += b;
503 a.z += b;
504 a.w += b;
505}
506
508// subtract
510
511inline __host__ __device__ float2 operator-(float2 a, float2 b)
512{
513 return make_float2(a.x - b.x, a.y - b.y);
514}
515inline __host__ __device__ void operator-=(float2 &a, float2 b)
516{
517 a.x -= b.x;
518 a.y -= b.y;
519}
520inline __host__ __device__ float2 operator-(float2 a, float b)
521{
522 return make_float2(a.x - b, a.y - b);
523}
524inline __host__ __device__ float2 operator-(float b, float2 a)
525{
526 return make_float2(b - a.x, b - a.y);
527}
528inline __host__ __device__ void operator-=(float2 &a, float b)
529{
530 a.x -= b;
531 a.y -= b;
532}
533
534inline __host__ __device__ int2 operator-(int2 a, int2 b)
535{
536 return make_int2(a.x - b.x, a.y - b.y);
537}
538inline __host__ __device__ void operator-=(int2 &a, int2 b)
539{
540 a.x -= b.x;
541 a.y -= b.y;
542}
543inline __host__ __device__ int2 operator-(int2 a, int b)
544{
545 return make_int2(a.x - b, a.y - b);
546}
547inline __host__ __device__ int2 operator-(int b, int2 a)
548{
549 return make_int2(b - a.x, b - a.y);
550}
551inline __host__ __device__ void operator-=(int2 &a, int b)
552{
553 a.x -= b;
554 a.y -= b;
555}
556
557inline __host__ __device__ uint2 operator-(uint2 a, uint2 b)
558{
559 return make_uint2(a.x - b.x, a.y - b.y);
560}
561inline __host__ __device__ void operator-=(uint2 &a, uint2 b)
562{
563 a.x -= b.x;
564 a.y -= b.y;
565}
566inline __host__ __device__ uint2 operator-(uint2 a, uint b)
567{
568 return make_uint2(a.x - b, a.y - b);
569}
570inline __host__ __device__ uint2 operator-(uint b, uint2 a)
571{
572 return make_uint2(b - a.x, b - a.y);
573}
574inline __host__ __device__ void operator-=(uint2 &a, uint b)
575{
576 a.x -= b;
577 a.y -= b;
578}
579
580inline __host__ __device__ float3 operator-(float3 a, float3 b)
581{
582 return make_float3(a.x - b.x, a.y - b.y, a.z - b.z);
583}
584inline __host__ __device__ void operator-=(float3 &a, float3 b)
585{
586 a.x -= b.x;
587 a.y -= b.y;
588 a.z -= b.z;
589}
590inline __host__ __device__ float3 operator-(float3 a, float b)
591{
592 return make_float3(a.x - b, a.y - b, a.z - b);
593}
594inline __host__ __device__ float3 operator-(float b, float3 a)
595{
596 return make_float3(b - a.x, b - a.y, b - a.z);
597}
598inline __host__ __device__ void operator-=(float3 &a, float b)
599{
600 a.x -= b;
601 a.y -= b;
602 a.z -= b;
603}
604
605inline __host__ __device__ int3 operator-(int3 a, int3 b)
606{
607 return make_int3(a.x - b.x, a.y - b.y, a.z - b.z);
608}
609inline __host__ __device__ void operator-=(int3 &a, int3 b)
610{
611 a.x -= b.x;
612 a.y -= b.y;
613 a.z -= b.z;
614}
615inline __host__ __device__ int3 operator-(int3 a, int b)
616{
617 return make_int3(a.x - b, a.y - b, a.z - b);
618}
619inline __host__ __device__ int3 operator-(int b, int3 a)
620{
621 return make_int3(b - a.x, b - a.y, b - a.z);
622}
623inline __host__ __device__ void operator-=(int3 &a, int b)
624{
625 a.x -= b;
626 a.y -= b;
627 a.z -= b;
628}
629
630inline __host__ __device__ uint3 operator-(uint3 a, uint3 b)
631{
632 return make_uint3(a.x - b.x, a.y - b.y, a.z - b.z);
633}
634inline __host__ __device__ void operator-=(uint3 &a, uint3 b)
635{
636 a.x -= b.x;
637 a.y -= b.y;
638 a.z -= b.z;
639}
640inline __host__ __device__ uint3 operator-(uint3 a, uint b)
641{
642 return make_uint3(a.x - b, a.y - b, a.z - b);
643}
644inline __host__ __device__ uint3 operator-(uint b, uint3 a)
645{
646 return make_uint3(b - a.x, b - a.y, b - a.z);
647}
648inline __host__ __device__ void operator-=(uint3 &a, uint b)
649{
650 a.x -= b;
651 a.y -= b;
652 a.z -= b;
653}
654
655inline __host__ __device__ float4 operator-(float4 a, float4 b)
656{
657 return make_float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
658}
659inline __host__ __device__ void operator-=(float4 &a, float4 b)
660{
661 a.x -= b.x;
662 a.y -= b.y;
663 a.z -= b.z;
664 a.w -= b.w;
665}
666inline __host__ __device__ float4 operator-(float4 a, float b)
667{
668 return make_float4(a.x - b, a.y - b, a.z - b, a.w - b);
669}
670inline __host__ __device__ void operator-=(float4 &a, float b)
671{
672 a.x -= b;
673 a.y -= b;
674 a.z -= b;
675 a.w -= b;
676}
677
678inline __host__ __device__ int4 operator-(int4 a, int4 b)
679{
680 return make_int4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
681}
682inline __host__ __device__ void operator-=(int4 &a, int4 b)
683{
684 a.x -= b.x;
685 a.y -= b.y;
686 a.z -= b.z;
687 a.w -= b.w;
688}
689inline __host__ __device__ int4 operator-(int4 a, int b)
690{
691 return make_int4(a.x - b, a.y - b, a.z - b, a.w - b);
692}
693inline __host__ __device__ int4 operator-(int b, int4 a)
694{
695 return make_int4(b - a.x, b - a.y, b - a.z, b - a.w);
696}
697inline __host__ __device__ void operator-=(int4 &a, int b)
698{
699 a.x -= b;
700 a.y -= b;
701 a.z -= b;
702 a.w -= b;
703}
704
705inline __host__ __device__ uint4 operator-(uint4 a, uint4 b)
706{
707 return make_uint4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
708}
709inline __host__ __device__ void operator-=(uint4 &a, uint4 b)
710{
711 a.x -= b.x;
712 a.y -= b.y;
713 a.z -= b.z;
714 a.w -= b.w;
715}
716inline __host__ __device__ uint4 operator-(uint4 a, uint b)
717{
718 return make_uint4(a.x - b, a.y - b, a.z - b, a.w - b);
719}
720inline __host__ __device__ uint4 operator-(uint b, uint4 a)
721{
722 return make_uint4(b - a.x, b - a.y, b - a.z, b - a.w);
723}
724inline __host__ __device__ void operator-=(uint4 &a, uint b)
725{
726 a.x -= b;
727 a.y -= b;
728 a.z -= b;
729 a.w -= b;
730}
731
733// multiply
735
736inline __host__ __device__ float2 operator*(float2 a, float2 b)
737{
738 return make_float2(a.x * b.x, a.y * b.y);
739}
740inline __host__ __device__ void operator*=(float2 &a, float2 b)
741{
742 a.x *= b.x;
743 a.y *= b.y;
744}
745inline __host__ __device__ float2 operator*(float2 a, float b)
746{
747 return make_float2(a.x * b, a.y * b);
748}
749inline __host__ __device__ float2 operator*(float b, float2 a)
750{
751 return make_float2(b * a.x, b * a.y);
752}
753inline __host__ __device__ void operator*=(float2 &a, float b)
754{
755 a.x *= b;
756 a.y *= b;
757}
758
759inline __host__ __device__ int2 operator*(int2 a, int2 b)
760{
761 return make_int2(a.x * b.x, a.y * b.y);
762}
763inline __host__ __device__ void operator*=(int2 &a, int2 b)
764{
765 a.x *= b.x;
766 a.y *= b.y;
767}
768inline __host__ __device__ int2 operator*(int2 a, int b)
769{
770 return make_int2(a.x * b, a.y * b);
771}
772inline __host__ __device__ int2 operator*(int b, int2 a)
773{
774 return make_int2(b * a.x, b * a.y);
775}
776inline __host__ __device__ void operator*=(int2 &a, int b)
777{
778 a.x *= b;
779 a.y *= b;
780}
781
782inline __host__ __device__ uint2 operator*(uint2 a, uint2 b)
783{
784 return make_uint2(a.x * b.x, a.y * b.y);
785}
786inline __host__ __device__ void operator*=(uint2 &a, uint2 b)
787{
788 a.x *= b.x;
789 a.y *= b.y;
790}
791inline __host__ __device__ uint2 operator*(uint2 a, uint b)
792{
793 return make_uint2(a.x * b, a.y * b);
794}
795inline __host__ __device__ uint2 operator*(uint b, uint2 a)
796{
797 return make_uint2(b * a.x, b * a.y);
798}
799inline __host__ __device__ void operator*=(uint2 &a, uint b)
800{
801 a.x *= b;
802 a.y *= b;
803}
804
805inline __host__ __device__ float3 operator*(float3 a, float3 b)
806{
807 return make_float3(a.x * b.x, a.y * b.y, a.z * b.z);
808}
809inline __host__ __device__ void operator*=(float3 &a, float3 b)
810{
811 a.x *= b.x;
812 a.y *= b.y;
813 a.z *= b.z;
814}
815inline __host__ __device__ float3 operator*(float3 a, float b)
816{
817 return make_float3(a.x * b, a.y * b, a.z * b);
818}
819inline __host__ __device__ float3 operator*(float b, float3 a)
820{
821 return make_float3(b * a.x, b * a.y, b * a.z);
822}
823inline __host__ __device__ void operator*=(float3 &a, float b)
824{
825 a.x *= b;
826 a.y *= b;
827 a.z *= b;
828}
829
830inline __host__ __device__ int3 operator*(int3 a, int3 b)
831{
832 return make_int3(a.x * b.x, a.y * b.y, a.z * b.z);
833}
834inline __host__ __device__ void operator*=(int3 &a, int3 b)
835{
836 a.x *= b.x;
837 a.y *= b.y;
838 a.z *= b.z;
839}
840inline __host__ __device__ int3 operator*(int3 a, int b)
841{
842 return make_int3(a.x * b, a.y * b, a.z * b);
843}
844inline __host__ __device__ int3 operator*(int b, int3 a)
845{
846 return make_int3(b * a.x, b * a.y, b * a.z);
847}
848inline __host__ __device__ void operator*=(int3 &a, int b)
849{
850 a.x *= b;
851 a.y *= b;
852 a.z *= b;
853}
854
855inline __host__ __device__ uint3 operator*(uint3 a, uint3 b)
856{
857 return make_uint3(a.x * b.x, a.y * b.y, a.z * b.z);
858}
859inline __host__ __device__ void operator*=(uint3 &a, uint3 b)
860{
861 a.x *= b.x;
862 a.y *= b.y;
863 a.z *= b.z;
864}
865inline __host__ __device__ uint3 operator*(uint3 a, uint b)
866{
867 return make_uint3(a.x * b, a.y * b, a.z * b);
868}
869inline __host__ __device__ uint3 operator*(uint b, uint3 a)
870{
871 return make_uint3(b * a.x, b * a.y, b * a.z);
872}
873inline __host__ __device__ void operator*=(uint3 &a, uint b)
874{
875 a.x *= b;
876 a.y *= b;
877 a.z *= b;
878}
879
880inline __host__ __device__ float4 operator*(float4 a, float4 b)
881{
882 return make_float4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
883}
884inline __host__ __device__ void operator*=(float4 &a, float4 b)
885{
886 a.x *= b.x;
887 a.y *= b.y;
888 a.z *= b.z;
889 a.w *= b.w;
890}
891inline __host__ __device__ float4 operator*(float4 a, float b)
892{
893 return make_float4(a.x * b, a.y * b, a.z * b, a.w * b);
894}
895inline __host__ __device__ float4 operator*(float b, float4 a)
896{
897 return make_float4(b * a.x, b * a.y, b * a.z, b * a.w);
898}
899inline __host__ __device__ void operator*=(float4 &a, float b)
900{
901 a.x *= b;
902 a.y *= b;
903 a.z *= b;
904 a.w *= b;
905}
906
907inline __host__ __device__ int4 operator*(int4 a, int4 b)
908{
909 return make_int4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
910}
911inline __host__ __device__ void operator*=(int4 &a, int4 b)
912{
913 a.x *= b.x;
914 a.y *= b.y;
915 a.z *= b.z;
916 a.w *= b.w;
917}
918inline __host__ __device__ int4 operator*(int4 a, int b)
919{
920 return make_int4(a.x * b, a.y * b, a.z * b, a.w * b);
921}
922inline __host__ __device__ int4 operator*(int b, int4 a)
923{
924 return make_int4(b * a.x, b * a.y, b * a.z, b * a.w);
925}
926inline __host__ __device__ void operator*=(int4 &a, int b)
927{
928 a.x *= b;
929 a.y *= b;
930 a.z *= b;
931 a.w *= b;
932}
933
934inline __host__ __device__ uint4 operator*(uint4 a, uint4 b)
935{
936 return make_uint4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
937}
938inline __host__ __device__ void operator*=(uint4 &a, uint4 b)
939{
940 a.x *= b.x;
941 a.y *= b.y;
942 a.z *= b.z;
943 a.w *= b.w;
944}
945inline __host__ __device__ uint4 operator*(uint4 a, uint b)
946{
947 return make_uint4(a.x * b, a.y * b, a.z * b, a.w * b);
948}
949inline __host__ __device__ uint4 operator*(uint b, uint4 a)
950{
951 return make_uint4(b * a.x, b * a.y, b * a.z, b * a.w);
952}
953inline __host__ __device__ void operator*=(uint4 &a, uint b)
954{
955 a.x *= b;
956 a.y *= b;
957 a.z *= b;
958 a.w *= b;
959}
960
962// divide
964
965inline __host__ __device__ float2 operator/(float2 a, float2 b)
966{
967 return make_float2(a.x / b.x, a.y / b.y);
968}
969inline __host__ __device__ void operator/=(float2 &a, float2 b)
970{
971 a.x /= b.x;
972 a.y /= b.y;
973}
974inline __host__ __device__ float2 operator/(float2 a, float b)
975{
976 return make_float2(a.x / b, a.y / b);
977}
978inline __host__ __device__ void operator/=(float2 &a, float b)
979{
980 a.x /= b;
981 a.y /= b;
982}
983inline __host__ __device__ float2 operator/(float b, float2 a)
984{
985 return make_float2(b / a.x, b / a.y);
986}
987
988inline __host__ __device__ float3 operator/(float3 a, float3 b)
989{
990 return make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
991}
992inline __host__ __device__ void operator/=(float3 &a, float3 b)
993{
994 a.x /= b.x;
995 a.y /= b.y;
996 a.z /= b.z;
997}
998inline __host__ __device__ float3 operator/(float3 a, float b)
999{
1000 return make_float3(a.x / b, a.y / b, a.z / b);
1001}
1002inline __host__ __device__ void operator/=(float3 &a, float b)
1003{
1004 a.x /= b;
1005 a.y /= b;
1006 a.z /= b;
1007}
1008inline __host__ __device__ float3 operator/(float b, float3 a)
1009{
1010 return make_float3(b / a.x, b / a.y, b / a.z);
1011}
1012
1013inline __host__ __device__ float4 operator/(float4 a, float4 b)
1014{
1015 return make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
1016}
1017inline __host__ __device__ void operator/=(float4 &a, float4 b)
1018{
1019 a.x /= b.x;
1020 a.y /= b.y;
1021 a.z /= b.z;
1022 a.w /= b.w;
1023}
1024inline __host__ __device__ float4 operator/(float4 a, float b)
1025{
1026 return make_float4(a.x / b, a.y / b, a.z / b, a.w / b);
1027}
1028inline __host__ __device__ void operator/=(float4 &a, float b)
1029{
1030 a.x /= b;
1031 a.y /= b;
1032 a.z /= b;
1033 a.w /= b;
1034}
1035inline __host__ __device__ float4 operator/(float b, float4 a)
1036{
1037 return make_float4(b / a.x, b / a.y, b / a.z, b / a.w);
1038}
1039
1041// min
1043
1044inline __host__ __device__ float2 fminf(float2 a, float2 b)
1045{
1046 return make_float2(fminf(a.x, b.x), fminf(a.y, b.y));
1047}
1048inline __host__ __device__ float3 fminf(float3 a, float3 b)
1049{
1050 return make_float3(fminf(a.x, b.x), fminf(a.y, b.y), fminf(a.z, b.z));
1051}
1052inline __host__ __device__ float4 fminf(float4 a, float4 b)
1053{
1054 return make_float4(fminf(a.x, b.x), fminf(a.y, b.y), fminf(a.z, b.z), fminf(a.w, b.w));
1055}
1056
1057inline __host__ __device__ int2 min(int2 a, int2 b)
1058{
1059 return make_int2(min(a.x, b.x), min(a.y, b.y));
1060}
1061inline __host__ __device__ int3 min(int3 a, int3 b)
1062{
1063 return make_int3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
1064}
1065inline __host__ __device__ int4 min(int4 a, int4 b)
1066{
1067 return make_int4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
1068}
1069
1070inline __host__ __device__ uint2 min(uint2 a, uint2 b)
1071{
1072 return make_uint2(min(a.x, b.x), min(a.y, b.y));
1073}
1074inline __host__ __device__ uint3 min(uint3 a, uint3 b)
1075{
1076 return make_uint3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
1077}
1078inline __host__ __device__ uint4 min(uint4 a, uint4 b)
1079{
1080 return make_uint4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
1081}
1082
1084// max
1086
1087inline __host__ __device__ float2 fmaxf(float2 a, float2 b)
1088{
1089 return make_float2(fmaxf(a.x, b.x), fmaxf(a.y, b.y));
1090}
1091inline __host__ __device__ float3 fmaxf(float3 a, float3 b)
1092{
1093 return make_float3(fmaxf(a.x, b.x), fmaxf(a.y, b.y), fmaxf(a.z, b.z));
1094}
1095inline __host__ __device__ float4 fmaxf(float4 a, float4 b)
1096{
1097 return make_float4(fmaxf(a.x, b.x), fmaxf(a.y, b.y), fmaxf(a.z, b.z), fmaxf(a.w, b.w));
1098}
1099
1100inline __host__ __device__ int2 max(int2 a, int2 b)
1101{
1102 return make_int2(max(a.x, b.x), max(a.y, b.y));
1103}
1104inline __host__ __device__ int3 max(int3 a, int3 b)
1105{
1106 return make_int3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
1107}
1108inline __host__ __device__ int4 max(int4 a, int4 b)
1109{
1110 return make_int4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
1111}
1112
1113inline __host__ __device__ uint2 max(uint2 a, uint2 b)
1114{
1115 return make_uint2(max(a.x, b.x), max(a.y, b.y));
1116}
1117inline __host__ __device__ uint3 max(uint3 a, uint3 b)
1118{
1119 return make_uint3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
1120}
1121inline __host__ __device__ uint4 max(uint4 a, uint4 b)
1122{
1123 return make_uint4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
1124}
1125
1127// lerp
1128// - linear interpolation between a and b, based on value t in [0, 1] range
1130
1131inline __device__ __host__ float lerp(float a, float b, float t)
1132{
1133 return a + t * (b - a);
1134}
1135inline __device__ __host__ float2 lerp(float2 a, float2 b, float t)
1136{
1137 return a + t * (b - a);
1138}
1139inline __device__ __host__ float3 lerp(float3 a, float3 b, float t)
1140{
1141 return a + t * (b - a);
1142}
1143inline __device__ __host__ float4 lerp(float4 a, float4 b, float t)
1144{
1145 return a + t * (b - a);
1146}
1147
1149// clamp
1150// - clamp the value v to be in the range [a, b]
1152
1153inline __device__ __host__ float clamp(float f, float a, float b)
1154{
1155 return fmaxf(a, fminf(f, b));
1156}
1157inline __device__ __host__ int clamp(int f, int a, int b)
1158{
1159 return max(a, min(f, b));
1160}
1161inline __device__ __host__ uint clamp(uint f, uint a, uint b)
1162{
1163 return max(a, min(f, b));
1164}
1165
1166inline __device__ __host__ float2 clamp(float2 v, float a, float b)
1167{
1168 return make_float2(clamp(v.x, a, b), clamp(v.y, a, b));
1169}
1170inline __device__ __host__ float2 clamp(float2 v, float2 a, float2 b)
1171{
1172 return make_float2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
1173}
1174inline __device__ __host__ float3 clamp(float3 v, float a, float b)
1175{
1176 return make_float3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1177}
1178inline __device__ __host__ float3 clamp(float3 v, float3 a, float3 b)
1179{
1180 return make_float3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1181}
1182inline __device__ __host__ float4 clamp(float4 v, float a, float b)
1183{
1184 return make_float4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
1185}
1186inline __device__ __host__ float4 clamp(float4 v, float4 a, float4 b)
1187{
1188 return make_float4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w));
1189}
1190
1191inline __device__ __host__ int2 clamp(int2 v, int a, int b)
1192{
1193 return make_int2(clamp(v.x, a, b), clamp(v.y, a, b));
1194}
1195inline __device__ __host__ int2 clamp(int2 v, int2 a, int2 b)
1196{
1197 return make_int2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
1198}
1199inline __device__ __host__ int3 clamp(int3 v, int a, int b)
1200{
1201 return make_int3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1202}
1203inline __device__ __host__ int3 clamp(int3 v, int3 a, int3 b)
1204{
1205 return make_int3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1206}
1207inline __device__ __host__ int4 clamp(int4 v, int a, int b)
1208{
1209 return make_int4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
1210}
1211inline __device__ __host__ int4 clamp(int4 v, int4 a, int4 b)
1212{
1213 return make_int4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w));
1214}
1215
1216inline __device__ __host__ uint2 clamp(uint2 v, uint a, uint b)
1217{
1218 return make_uint2(clamp(v.x, a, b), clamp(v.y, a, b));
1219}
1220inline __device__ __host__ uint2 clamp(uint2 v, uint2 a, uint2 b)
1221{
1222 return make_uint2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
1223}
1224inline __device__ __host__ uint3 clamp(uint3 v, uint a, uint b)
1225{
1226 return make_uint3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1227}
1228inline __device__ __host__ uint3 clamp(uint3 v, uint3 a, uint3 b)
1229{
1230 return make_uint3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1231}
1232inline __device__ __host__ uint4 clamp(uint4 v, uint a, uint b)
1233{
1234 return make_uint4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
1235}
1236inline __device__ __host__ uint4 clamp(uint4 v, uint4 a, uint4 b)
1237{
1238 return make_uint4(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z), clamp(v.w, a.w, b.w));
1239}
1240
1242// dot product
1244
1245inline __host__ __device__ float dot(float2 a, float2 b)
1246{
1247 return a.x * b.x + a.y * b.y;
1248}
1249inline __host__ __device__ float dot(float3 a, float3 b)
1250{
1251 return a.x * b.x + a.y * b.y + a.z * b.z;
1252}
1253inline __host__ __device__ float dot(float4 a, float4 b)
1254{
1255 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
1256}
1257
1258inline __host__ __device__ int dot(int2 a, int2 b)
1259{
1260 return a.x * b.x + a.y * b.y;
1261}
1262inline __host__ __device__ int dot(int3 a, int3 b)
1263{
1264 return a.x * b.x + a.y * b.y + a.z * b.z;
1265}
1266inline __host__ __device__ int dot(int4 a, int4 b)
1267{
1268 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
1269}
1270
1271inline __host__ __device__ uint dot(uint2 a, uint2 b)
1272{
1273 return a.x * b.x + a.y * b.y;
1274}
1275inline __host__ __device__ uint dot(uint3 a, uint3 b)
1276{
1277 return a.x * b.x + a.y * b.y + a.z * b.z;
1278}
1279inline __host__ __device__ uint dot(uint4 a, uint4 b)
1280{
1281 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
1282}
1283
1285// length
1287
1288inline __host__ __device__ float length(float2 v)
1289{
1290 return sqrtf(dot(v, v));
1291}
1292inline __host__ __device__ float length(float3 v)
1293{
1294 return sqrtf(dot(v, v));
1295}
1296inline __host__ __device__ float length(float4 v)
1297{
1298 return sqrtf(dot(v, v));
1299}
1300
1302// normalize
1304
1305inline __host__ __device__ float2 normalize(float2 v)
1306{
1307 float invLen = rsqrtf(dot(v, v));
1308 return v * invLen;
1309}
1310inline __host__ __device__ float3 normalize(float3 v)
1311{
1312 float invLen = rsqrtf(dot(v, v));
1313 return v * invLen;
1314}
1315inline __host__ __device__ float4 normalize(float4 v)
1316{
1317 float invLen = rsqrtf(dot(v, v));
1318 return v * invLen;
1319}
1320
1322// floor
1324
1325inline __host__ __device__ float2 floorf(float2 v)
1326{
1327 return make_float2(floorf(v.x), floorf(v.y));
1328}
1329inline __host__ __device__ float3 floorf(float3 v)
1330{
1331 return make_float3(floorf(v.x), floorf(v.y), floorf(v.z));
1332}
1333inline __host__ __device__ float4 floorf(float4 v)
1334{
1335 return make_float4(floorf(v.x), floorf(v.y), floorf(v.z), floorf(v.w));
1336}
1337
1339// frac - returns the fractional portion of a scalar or each vector component
1341
1342inline __host__ __device__ float fracf(float v)
1343{
1344 return v - floorf(v);
1345}
1346inline __host__ __device__ float2 fracf(float2 v)
1347{
1348 return make_float2(fracf(v.x), fracf(v.y));
1349}
1350inline __host__ __device__ float3 fracf(float3 v)
1351{
1352 return make_float3(fracf(v.x), fracf(v.y), fracf(v.z));
1353}
1354inline __host__ __device__ float4 fracf(float4 v)
1355{
1356 return make_float4(fracf(v.x), fracf(v.y), fracf(v.z), fracf(v.w));
1357}
1358
1360// fmod
1362
1363inline __host__ __device__ float2 fmodf(float2 a, float2 b)
1364{
1365 return make_float2(fmodf(a.x, b.x), fmodf(a.y, b.y));
1366}
1367inline __host__ __device__ float3 fmodf(float3 a, float3 b)
1368{
1369 return make_float3(fmodf(a.x, b.x), fmodf(a.y, b.y), fmodf(a.z, b.z));
1370}
1371inline __host__ __device__ float4 fmodf(float4 a, float4 b)
1372{
1373 return make_float4(fmodf(a.x, b.x), fmodf(a.y, b.y), fmodf(a.z, b.z), fmodf(a.w, b.w));
1374}
1375
1377// absolute value
1379
1380inline __host__ __device__ float2 fabs(float2 v)
1381{
1382 return make_float2(fabs(v.x), fabs(v.y));
1383}
1384inline __host__ __device__ float3 fabs(float3 v)
1385{
1386 return make_float3(fabs(v.x), fabs(v.y), fabs(v.z));
1387}
1388inline __host__ __device__ float4 fabs(float4 v)
1389{
1390 return make_float4(fabs(v.x), fabs(v.y), fabs(v.z), fabs(v.w));
1391}
1392
1393inline __host__ __device__ int2 abs(int2 v)
1394{
1395 return make_int2(abs(v.x), abs(v.y));
1396}
1397inline __host__ __device__ int3 abs(int3 v)
1398{
1399 return make_int3(abs(v.x), abs(v.y), abs(v.z));
1400}
1401inline __host__ __device__ int4 abs(int4 v)
1402{
1403 return make_int4(abs(v.x), abs(v.y), abs(v.z), abs(v.w));
1404}
1405
1407// reflect
1408// - returns reflection of incident ray I around surface normal N
1409// - N should be normalized, reflected vector's length is equal to length of I
1411
1412inline __host__ __device__ float3 reflect(float3 i, float3 n)
1413{
1414 return i - 2.0f * n * dot(n, i);
1415}
1416
1418// cross product
1420
1421inline __host__ __device__ float3 cross(float3 a, float3 b)
1422{
1423 return make_float3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
1424}
1425
1427// smoothstep
1428// - returns 0 if x < a
1429// - returns 1 if x > b
1430// - otherwise returns smooth interpolation between 0 and 1 based on x
1432
1433inline __device__ __host__ float smoothstep(float a, float b, float x)
1434{
1435 float y = clamp((x - a) / (b - a), 0.0f, 1.0f);
1436 return (y * y * (3.0f - (2.0f * y)));
1437}
1438inline __device__ __host__ float2 smoothstep(float2 a, float2 b, float2 x)
1439{
1440 float2 y = clamp((x - a) / (b - a), 0.0f, 1.0f);
1441 return (y * y * (make_float2(3.0f) - (make_float2(2.0f) * y)));
1442}
1443inline __device__ __host__ float3 smoothstep(float3 a, float3 b, float3 x)
1444{
1445 float3 y = clamp((x - a) / (b - a), 0.0f, 1.0f);
1446 return (y * y * (make_float3(3.0f) - (make_float3(2.0f) * y)));
1447}
1448inline __device__ __host__ float4 smoothstep(float4 a, float4 b, float4 x)
1449{
1450 float4 y = clamp((x - a) / (b - a), 0.0f, 1.0f);
1451 return (y * y * (make_float4(3.0f) - (make_float4(2.0f) * y)));
1452}
1453
1454#endif
GLdouble n
Definition: khronos-glext.h:8447
GLenum clamp
Definition: khronos-glext.h:6907
const GLdouble * v
Definition: khronos-glext.h:6442
GLint GLint GLint GLint GLint GLint y
Definition: khronos-glext.h:6346
GLdouble GLdouble t
Definition: khronos-glext.h:6449
GLfloat f
Definition: khronos-glext.h:8258
GLboolean GLboolean GLboolean b
Definition: khronos-glext.h:6895
GLboolean GLboolean GLboolean GLboolean a
Definition: khronos-glext.h:6895
GLdouble s
Definition: khronos-glext.h:6441
GLubyte GLubyte GLubyte GLubyte w
Definition: khronos-glext.h:6793
GLint GLint GLint GLint GLint x
Definition: khronos-glext.h:6346
__host__ __device__ float2 normalize(float2 v)
Definition: cutil_math.h:1305
float rsqrtf(float x)
Definition: cutil_math.h:65
__host__ __device__ int4 make_int4(int s)
Definition: cutil_math.h:210
__device__ __host__ float lerp(float a, float b, float t)
Definition: cutil_math.h:1131
__host__ __device__ uint2 make_uint2(uint s)
Definition: cutil_math.h:109
__host__ __device__ float2 operator/(float2 a, float2 b)
Definition: cutil_math.h:965
float fmaxf(float a, float b)
Definition: cutil_math.h:50
__host__ __device__ float3 cross(float3 a, float3 b)
Definition: cutil_math.h:1421
__host__ __device__ float length(float2 v)
Definition: cutil_math.h:1288
__host__ __device__ void operator-=(float2 &a, float2 b)
Definition: cutil_math.h:515
__host__ __device__ int2 make_int2(int s)
Definition: cutil_math.h:92
__device__ __host__ float smoothstep(float a, float b, float x)
Definition: cutil_math.h:1433
__host__ __device__ float2 fmodf(float2 a, float2 b)
Definition: cutil_math.h:1363
__device__ __host__ float clamp(float f, float a, float b)
Definition: cutil_math.h:1153
float fminf(float a, float b)
Definition: cutil_math.h:45
__host__ __device__ float2 operator*(float2 a, float2 b)
Definition: cutil_math.h:736
__host__ __device__ float4 make_float4(float s)
Definition: cutil_math.h:189
__host__ __device__ void operator/=(float2 &a, float2 b)
Definition: cutil_math.h:969
__host__ __device__ uint4 make_uint4(uint s)
Definition: cutil_math.h:231
__host__ __device__ float2 operator-(float2 &a)
Definition: cutil_math.h:252
unsigned int uint
Definition: cutil_math.h:35
__host__ __device__ int3 make_int3(int s)
Definition: cutil_math.h:147
__host__ __device__ float dot(float2 a, float2 b)
Definition: cutil_math.h:1245
__host__ __device__ float fracf(float v)
Definition: cutil_math.h:1342
__host__ __device__ float2 operator+(float2 a, float2 b)
Definition: cutil_math.h:281
__host__ __device__ float2 fabs(float2 v)
Definition: cutil_math.h:1380
unsigned short ushort
Definition: cutil_math.h:36
int min(int a, int b)
Definition: cutil_math.h:60
__host__ __device__ void operator*=(float2 &a, float2 b)
Definition: cutil_math.h:740
__host__ __device__ uint3 make_uint3(uint s)
Definition: cutil_math.h:168
__host__ __device__ float2 floorf(float2 v)
Definition: cutil_math.h:1325
__host__ __device__ float2 make_float2(float s)
Definition: cutil_math.h:75
__host__ __device__ int2 abs(int2 v)
Definition: cutil_math.h:1393
int max(int a, int b)
Definition: cutil_math.h:55
__host__ __device__ void operator+=(float2 &a, float2 b)
Definition: cutil_math.h:285
__host__ __device__ float3 reflect(float3 i, float3 n)
Definition: cutil_math.h:1412
__host__ __device__ float3 make_float3(float s)
Definition: cutil_math.h:122