File indexing completed on 2026-04-09 07:49:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #pragma once
0031
0032 #if defined(__CUDACC__) || defined(__CUDABE__)
0033 # define SUTIL_HOSTDEVICE __host__ __device__
0034 # define SUTIL_INLINE __forceinline__
0035 # define CONST_STATIC_INIT( ... )
0036 #else
0037 # define SUTIL_HOSTDEVICE
0038 # define SUTIL_INLINE inline
0039 # define CONST_STATIC_INIT( ... ) = __VA_ARGS__
0040 #endif
0041
0042 #include <vector_functions.h>
0043 #include <vector_types.h>
0044
0045 #include <cmath>
0046 #include <cstdlib>
0047
0048
0049
0050 #ifndef M_PIf
0051 #define M_PIf 3.14159265358979323846f
0052 #endif
0053 #ifndef M_1_PIf
0054 #define M_1_PIf 0.318309886183790671538f
0055 #endif
0056
0057
0058 #if !defined(__CUDACC__)
0059
0060 SUTIL_INLINE SUTIL_HOSTDEVICE int max(int a, int b)
0061 {
0062 return a > b ? a : b;
0063 }
0064
0065 SUTIL_INLINE SUTIL_HOSTDEVICE int min(int a, int b)
0066 {
0067 return a < b ? a : b;
0068 }
0069
0070 SUTIL_INLINE SUTIL_HOSTDEVICE long long max(long long a, long long b)
0071 {
0072 return a > b ? a : b;
0073 }
0074
0075 SUTIL_INLINE SUTIL_HOSTDEVICE long long min(long long a, long long b)
0076 {
0077 return a < b ? a : b;
0078 }
0079
0080 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int max(unsigned int a, unsigned int b)
0081 {
0082 return a > b ? a : b;
0083 }
0084
0085 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int min(unsigned int a, unsigned int b)
0086 {
0087 return a < b ? a : b;
0088 }
0089
0090 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long max(unsigned long long a, unsigned long long b)
0091 {
0092 return a > b ? a : b;
0093 }
0094
0095 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long min(unsigned long long a, unsigned long long b)
0096 {
0097 return a < b ? a : b;
0098 }
0099
0100
0101
0102 SUTIL_INLINE SUTIL_HOSTDEVICE float lerp(const float a, const float b, const float t)
0103 {
0104 return a + t*(b-a);
0105 }
0106
0107
0108 SUTIL_INLINE SUTIL_HOSTDEVICE float bilerp(const float x00, const float x10, const float x01, const float x11,
0109 const float u, const float v)
0110 {
0111 return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0112 }
0113
0114 template <typename IntegerType>
0115 SUTIL_INLINE SUTIL_HOSTDEVICE IntegerType roundUp(IntegerType x, IntegerType y)
0116 {
0117 return ( ( x + y - 1 ) / y ) * y;
0118 }
0119
0120 #endif
0121
0122
0123 SUTIL_INLINE SUTIL_HOSTDEVICE float clamp(const float f, const float a, const float b)
0124 {
0125 return fmaxf(a, fminf(f, b));
0126 }
0127
0128
0129
0130
0131
0132
0133
0134
0135 SUTIL_INLINE SUTIL_HOSTDEVICE float2 make_float2(const float s)
0136 {
0137 return make_float2(s, s);
0138 }
0139 SUTIL_INLINE SUTIL_HOSTDEVICE float2 make_float2(const int2& a)
0140 {
0141 return make_float2(float(a.x), float(a.y));
0142 }
0143 SUTIL_INLINE SUTIL_HOSTDEVICE float2 make_float2(const uint2& a)
0144 {
0145 return make_float2(float(a.x), float(a.y));
0146 }
0147
0148
0149
0150 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator-(const float2& a)
0151 {
0152 return make_float2(-a.x, -a.y);
0153 }
0154
0155
0156
0157
0158 SUTIL_INLINE SUTIL_HOSTDEVICE float2 fminf(const float2& a, const float2& b)
0159 {
0160 return make_float2(fminf(a.x,b.x), fminf(a.y,b.y));
0161 }
0162 SUTIL_INLINE SUTIL_HOSTDEVICE float fminf(const float2& a)
0163 {
0164 return fminf(a.x, a.y);
0165 }
0166
0167
0168
0169
0170
0171 SUTIL_INLINE SUTIL_HOSTDEVICE float2 fmaxf(const float2& a, const float2& b)
0172 {
0173 return make_float2(fmaxf(a.x,b.x), fmaxf(a.y,b.y));
0174 }
0175 SUTIL_INLINE SUTIL_HOSTDEVICE float fmaxf(const float2& a)
0176 {
0177 return fmaxf(a.x, a.y);
0178 }
0179
0180
0181
0182
0183
0184 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator+(const float2& a, const float2& b)
0185 {
0186 return make_float2(a.x + b.x, a.y + b.y);
0187 }
0188 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator+(const float2& a, const float b)
0189 {
0190 return make_float2(a.x + b, a.y + b);
0191 }
0192 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator+(const float a, const float2& b)
0193 {
0194 return make_float2(a + b.x, a + b.y);
0195 }
0196 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(float2& a, const float2& b)
0197 {
0198 a.x += b.x; a.y += b.y;
0199 }
0200
0201
0202
0203
0204
0205 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator-(const float2& a, const float2& b)
0206 {
0207 return make_float2(a.x - b.x, a.y - b.y);
0208 }
0209 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator-(const float2& a, const float b)
0210 {
0211 return make_float2(a.x - b, a.y - b);
0212 }
0213 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator-(const float a, const float2& b)
0214 {
0215 return make_float2(a - b.x, a - b.y);
0216 }
0217 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(float2& a, const float2& b)
0218 {
0219 a.x -= b.x; a.y -= b.y;
0220 }
0221
0222
0223
0224
0225
0226 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator*(const float2& a, const float2& b)
0227 {
0228 return make_float2(a.x * b.x, a.y * b.y);
0229 }
0230 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator*(const float2& a, const float s)
0231 {
0232 return make_float2(a.x * s, a.y * s);
0233 }
0234 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator*(const float s, const float2& a)
0235 {
0236 return make_float2(a.x * s, a.y * s);
0237 }
0238 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float2& a, const float2& s)
0239 {
0240 a.x *= s.x; a.y *= s.y;
0241 }
0242 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float2& a, const float s)
0243 {
0244 a.x *= s; a.y *= s;
0245 }
0246
0247
0248
0249
0250
0251 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator/(const float2& a, const float2& b)
0252 {
0253 return make_float2(a.x / b.x, a.y / b.y);
0254 }
0255 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator/(const float2& a, const float s)
0256 {
0257 float inv = 1.0f / s;
0258 return a * inv;
0259 }
0260 SUTIL_INLINE SUTIL_HOSTDEVICE float2 operator/(const float s, const float2& a)
0261 {
0262 return make_float2( s/a.x, s/a.y );
0263 }
0264 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(float2& a, const float s)
0265 {
0266 float inv = 1.0f / s;
0267 a *= inv;
0268 }
0269
0270
0271
0272 SUTIL_INLINE SUTIL_HOSTDEVICE float2 lerp(const float2& a, const float2& b, const float t)
0273 {
0274 return a + t*(b-a);
0275 }
0276
0277
0278 SUTIL_INLINE SUTIL_HOSTDEVICE float2 bilerp(const float2& x00, const float2& x10, const float2& x01, const float2& x11,
0279 const float u, const float v)
0280 {
0281 return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0282 }
0283
0284
0285
0286
0287 SUTIL_INLINE SUTIL_HOSTDEVICE float2 clamp(const float2& v, const float a, const float b)
0288 {
0289 return make_float2(clamp(v.x, a, b), clamp(v.y, a, b));
0290 }
0291
0292 SUTIL_INLINE SUTIL_HOSTDEVICE float2 clamp(const float2& v, const float2& a, const float2& b)
0293 {
0294 return make_float2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
0295 }
0296
0297
0298
0299 SUTIL_INLINE SUTIL_HOSTDEVICE float dot(const float2& a, const float2& b)
0300 {
0301 return a.x * b.x + a.y * b.y;
0302 }
0303
0304
0305 SUTIL_INLINE SUTIL_HOSTDEVICE float length(const float2& v)
0306 {
0307 return sqrtf(dot(v, v));
0308 }
0309
0310
0311 SUTIL_INLINE SUTIL_HOSTDEVICE float2 normalize(const float2& v)
0312 {
0313 float invLen = 1.0f / sqrtf(dot(v, v));
0314 return v * invLen;
0315 }
0316
0317
0318 SUTIL_INLINE SUTIL_HOSTDEVICE float2 floor(const float2& v)
0319 {
0320 return make_float2(::floorf(v.x), ::floorf(v.y));
0321 }
0322
0323
0324 SUTIL_INLINE SUTIL_HOSTDEVICE float2 reflect(const float2& i, const float2& n)
0325 {
0326 return i - 2.0f * n * dot(n,i);
0327 }
0328
0329
0330
0331
0332
0333 SUTIL_INLINE SUTIL_HOSTDEVICE float2 faceforward(const float2& n, const float2& i, const float2& nref)
0334 {
0335 return n * copysignf( 1.0f, dot(i, nref) );
0336 }
0337
0338
0339 SUTIL_INLINE SUTIL_HOSTDEVICE float2 expf(const float2& v)
0340 {
0341 return make_float2(::expf(v.x), ::expf(v.y));
0342 }
0343
0344
0345 SUTIL_INLINE SUTIL_HOSTDEVICE float getByIndex(const float2& v, int i)
0346 {
0347 return ((float*)(&v))[i];
0348 }
0349
0350
0351 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(float2& v, int i, float x)
0352 {
0353 ((float*)(&v))[i] = x;
0354 }
0355
0356
0357
0358
0359
0360
0361
0362
0363 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const float s)
0364 {
0365 return make_float3(s, s, s);
0366 }
0367 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const float2& a)
0368 {
0369 return make_float3(a.x, a.y, 0.0f);
0370 }
0371 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const int3& a)
0372 {
0373 return make_float3(float(a.x), float(a.y), float(a.z));
0374 }
0375 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const uint3& a)
0376 {
0377 return make_float3(float(a.x), float(a.y), float(a.z));
0378 }
0379
0380
0381
0382 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator-(const float3& a)
0383 {
0384 return make_float3(-a.x, -a.y, -a.z);
0385 }
0386
0387
0388
0389
0390 SUTIL_INLINE SUTIL_HOSTDEVICE float3 fminf(const float3& a, const float3& b)
0391 {
0392 return make_float3(fminf(a.x,b.x), fminf(a.y,b.y), fminf(a.z,b.z));
0393 }
0394 SUTIL_INLINE SUTIL_HOSTDEVICE float fminf(const float3& a)
0395 {
0396 return fminf(fminf(a.x, a.y), a.z);
0397 }
0398
0399
0400
0401
0402
0403 SUTIL_INLINE SUTIL_HOSTDEVICE float3 fmaxf(const float3& a, const float3& b)
0404 {
0405 return make_float3(fmaxf(a.x,b.x), fmaxf(a.y,b.y), fmaxf(a.z,b.z));
0406 }
0407 SUTIL_INLINE SUTIL_HOSTDEVICE float fmaxf(const float3& a)
0408 {
0409 return fmaxf(fmaxf(a.x, a.y), a.z);
0410 }
0411
0412
0413
0414
0415
0416 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator+(const float3& a, const float3& b)
0417 {
0418 return make_float3(a.x + b.x, a.y + b.y, a.z + b.z);
0419 }
0420 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator+(const float3& a, const float b)
0421 {
0422 return make_float3(a.x + b, a.y + b, a.z + b);
0423 }
0424 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator+(const float a, const float3& b)
0425 {
0426 return make_float3(a + b.x, a + b.y, a + b.z);
0427 }
0428 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(float3& a, const float3& b)
0429 {
0430 a.x += b.x; a.y += b.y; a.z += b.z;
0431 }
0432
0433
0434
0435
0436
0437 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator-(const float3& a, const float3& b)
0438 {
0439 return make_float3(a.x - b.x, a.y - b.y, a.z - b.z);
0440 }
0441 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator-(const float3& a, const float b)
0442 {
0443 return make_float3(a.x - b, a.y - b, a.z - b);
0444 }
0445 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator-(const float a, const float3& b)
0446 {
0447 return make_float3(a - b.x, a - b.y, a - b.z);
0448 }
0449 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(float3& a, const float3& b)
0450 {
0451 a.x -= b.x; a.y -= b.y; a.z -= b.z;
0452 }
0453
0454
0455
0456
0457
0458 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator*(const float3& a, const float3& b)
0459 {
0460 return make_float3(a.x * b.x, a.y * b.y, a.z * b.z);
0461 }
0462 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator*(const float3& a, const float s)
0463 {
0464 return make_float3(a.x * s, a.y * s, a.z * s);
0465 }
0466 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator*(const float s, const float3& a)
0467 {
0468 return make_float3(a.x * s, a.y * s, a.z * s);
0469 }
0470 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float3& a, const float3& s)
0471 {
0472 a.x *= s.x; a.y *= s.y; a.z *= s.z;
0473 }
0474 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float3& a, const float s)
0475 {
0476 a.x *= s; a.y *= s; a.z *= s;
0477 }
0478
0479
0480
0481
0482
0483 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator/(const float3& a, const float3& b)
0484 {
0485 return make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
0486 }
0487 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator/(const float3& a, const float s)
0488 {
0489 float inv = 1.0f / s;
0490 return a * inv;
0491 }
0492 SUTIL_INLINE SUTIL_HOSTDEVICE float3 operator/(const float s, const float3& a)
0493 {
0494 return make_float3( s/a.x, s/a.y, s/a.z );
0495 }
0496 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(float3& a, const float s)
0497 {
0498 float inv = 1.0f / s;
0499 a *= inv;
0500 }
0501
0502
0503
0504 SUTIL_INLINE SUTIL_HOSTDEVICE float3 lerp(const float3& a, const float3& b, const float t)
0505 {
0506 return a + t*(b-a);
0507 }
0508
0509
0510 SUTIL_INLINE SUTIL_HOSTDEVICE float3 bilerp(const float3& x00, const float3& x10, const float3& x01, const float3& x11,
0511 const float u, const float v)
0512 {
0513 return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0514 }
0515
0516
0517
0518
0519 SUTIL_INLINE SUTIL_HOSTDEVICE float3 clamp(const float3& v, const float a, const float b)
0520 {
0521 return make_float3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
0522 }
0523
0524 SUTIL_INLINE SUTIL_HOSTDEVICE float3 clamp(const float3& v, const float3& a, const float3& b)
0525 {
0526 return make_float3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
0527 }
0528
0529
0530
0531 SUTIL_INLINE SUTIL_HOSTDEVICE float dot(const float3& a, const float3& b)
0532 {
0533 return a.x * b.x + a.y * b.y + a.z * b.z;
0534 }
0535
0536
0537 SUTIL_INLINE SUTIL_HOSTDEVICE float3 cross(const float3& a, const float3& b)
0538 {
0539 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);
0540 }
0541
0542
0543 SUTIL_INLINE SUTIL_HOSTDEVICE float length(const float3& v)
0544 {
0545 return sqrtf(dot(v, v));
0546 }
0547
0548
0549 SUTIL_INLINE SUTIL_HOSTDEVICE float3 normalize(const float3& v)
0550 {
0551 float invLen = 1.0f / sqrtf(dot(v, v));
0552 return v * invLen;
0553 }
0554
0555
0556 SUTIL_INLINE SUTIL_HOSTDEVICE float3 floor(const float3& v)
0557 {
0558 return make_float3(::floorf(v.x), ::floorf(v.y), ::floorf(v.z));
0559 }
0560
0561
0562 SUTIL_INLINE SUTIL_HOSTDEVICE float3 reflect(const float3& i, const float3& n)
0563 {
0564 return i - 2.0f * n * dot(n,i);
0565 }
0566
0567
0568
0569
0570
0571 SUTIL_INLINE SUTIL_HOSTDEVICE float3 faceforward(const float3& n, const float3& i, const float3& nref)
0572 {
0573 return n * copysignf( 1.0f, dot(i, nref) );
0574 }
0575
0576
0577 SUTIL_INLINE SUTIL_HOSTDEVICE float3 expf(const float3& v)
0578 {
0579 return make_float3(::expf(v.x), ::expf(v.y), ::expf(v.z));
0580 }
0581
0582
0583 SUTIL_INLINE SUTIL_HOSTDEVICE float getByIndex(const float3& v, int i)
0584 {
0585 return ((float*)(&v))[i];
0586 }
0587
0588
0589 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(float3& v, int i, float x)
0590 {
0591 ((float*)(&v))[i] = x;
0592 }
0593
0594
0595
0596
0597
0598
0599
0600 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float s)
0601 {
0602 return make_float4(s, s, s, s);
0603 }
0604 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float3& a)
0605 {
0606 return make_float4(a.x, a.y, a.z, 0.0f);
0607 }
0608 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const int4& a)
0609 {
0610 return make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
0611 }
0612 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const uint4& a)
0613 {
0614 return make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
0615 }
0616
0617
0618
0619 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator-(const float4& a)
0620 {
0621 return make_float4(-a.x, -a.y, -a.z, -a.w);
0622 }
0623
0624
0625
0626
0627 SUTIL_INLINE SUTIL_HOSTDEVICE float4 fminf(const float4& a, const float4& b)
0628 {
0629 return make_float4(fminf(a.x,b.x), fminf(a.y,b.y), fminf(a.z,b.z), fminf(a.w,b.w));
0630 }
0631 SUTIL_INLINE SUTIL_HOSTDEVICE float fminf(const float4& a)
0632 {
0633 return fminf(fminf(a.x, a.y), fminf(a.z, a.w));
0634 }
0635
0636
0637
0638
0639
0640 SUTIL_INLINE SUTIL_HOSTDEVICE float4 fmaxf(const float4& a, const float4& b)
0641 {
0642 return make_float4(fmaxf(a.x,b.x), fmaxf(a.y,b.y), fmaxf(a.z,b.z), fmaxf(a.w,b.w));
0643 }
0644 SUTIL_INLINE SUTIL_HOSTDEVICE float fmaxf(const float4& a)
0645 {
0646 return fmaxf(fmaxf(a.x, a.y), fmaxf(a.z, a.w));
0647 }
0648
0649
0650
0651
0652
0653 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator+(const float4& a, const float4& b)
0654 {
0655 return make_float4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
0656 }
0657 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator+(const float4& a, const float b)
0658 {
0659 return make_float4(a.x + b, a.y + b, a.z + b, a.w + b);
0660 }
0661 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator+(const float a, const float4& b)
0662 {
0663 return make_float4(a + b.x, a + b.y, a + b.z, a + b.w);
0664 }
0665 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(float4& a, const float4& b)
0666 {
0667 a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
0668 }
0669
0670
0671
0672
0673
0674 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator-(const float4& a, const float4& b)
0675 {
0676 return make_float4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
0677 }
0678 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator-(const float4& a, const float b)
0679 {
0680 return make_float4(a.x - b, a.y - b, a.z - b, a.w - b);
0681 }
0682 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator-(const float a, const float4& b)
0683 {
0684 return make_float4(a - b.x, a - b.y, a - b.z, a - b.w);
0685 }
0686 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(float4& a, const float4& b)
0687 {
0688 a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
0689 }
0690
0691
0692
0693
0694
0695 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator*(const float4& a, const float4& s)
0696 {
0697 return make_float4(a.x * s.x, a.y * s.y, a.z * s.z, a.w * s.w);
0698 }
0699 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator*(const float4& a, const float s)
0700 {
0701 return make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
0702 }
0703 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator*(const float s, const float4& a)
0704 {
0705 return make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
0706 }
0707 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float4& a, const float4& s)
0708 {
0709 a.x *= s.x; a.y *= s.y; a.z *= s.z; a.w *= s.w;
0710 }
0711 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(float4& a, const float s)
0712 {
0713 a.x *= s; a.y *= s; a.z *= s; a.w *= s;
0714 }
0715
0716
0717
0718
0719
0720 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator/(const float4& a, const float4& b)
0721 {
0722 return make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
0723 }
0724 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator/(const float4& a, const float s)
0725 {
0726 float inv = 1.0f / s;
0727 return a * inv;
0728 }
0729 SUTIL_INLINE SUTIL_HOSTDEVICE float4 operator/(const float s, const float4& a)
0730 {
0731 return make_float4( s/a.x, s/a.y, s/a.z, s/a.w );
0732 }
0733 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(float4& a, const float s)
0734 {
0735 float inv = 1.0f / s;
0736 a *= inv;
0737 }
0738
0739
0740
0741 SUTIL_INLINE SUTIL_HOSTDEVICE float4 lerp(const float4& a, const float4& b, const float t)
0742 {
0743 return a + t*(b-a);
0744 }
0745
0746
0747 SUTIL_INLINE SUTIL_HOSTDEVICE float4 bilerp(const float4& x00, const float4& x10, const float4& x01, const float4& x11,
0748 const float u, const float v)
0749 {
0750 return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0751 }
0752
0753
0754
0755
0756 SUTIL_INLINE SUTIL_HOSTDEVICE float4 clamp(const float4& v, const float a, const float b)
0757 {
0758 return make_float4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
0759 }
0760
0761 SUTIL_INLINE SUTIL_HOSTDEVICE float4 clamp(const float4& v, const float4& a, const float4& b)
0762 {
0763 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));
0764 }
0765
0766
0767
0768 SUTIL_INLINE SUTIL_HOSTDEVICE float dot(const float4& a, const float4& b)
0769 {
0770 return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
0771 }
0772
0773
0774 SUTIL_INLINE SUTIL_HOSTDEVICE float length(const float4& r)
0775 {
0776 return sqrtf(dot(r, r));
0777 }
0778
0779
0780 SUTIL_INLINE SUTIL_HOSTDEVICE float4 normalize(const float4& v)
0781 {
0782 float invLen = 1.0f / sqrtf(dot(v, v));
0783 return v * invLen;
0784 }
0785
0786
0787 SUTIL_INLINE SUTIL_HOSTDEVICE float4 floor(const float4& v)
0788 {
0789 return make_float4(::floorf(v.x), ::floorf(v.y), ::floorf(v.z), ::floorf(v.w));
0790 }
0791
0792
0793 SUTIL_INLINE SUTIL_HOSTDEVICE float4 reflect(const float4& i, const float4& n)
0794 {
0795 return i - 2.0f * n * dot(n,i);
0796 }
0797
0798
0799
0800
0801
0802
0803
0804 SUTIL_INLINE SUTIL_HOSTDEVICE float4 faceforward(const float4& n, const float4& i, const float4& nref)
0805 {
0806 return n * copysignf( 1.0f, dot(i, nref) );
0807 }
0808
0809
0810 SUTIL_INLINE SUTIL_HOSTDEVICE float4 expf(const float4& v)
0811 {
0812 return make_float4(::expf(v.x), ::expf(v.y), ::expf(v.z), ::expf(v.w));
0813 }
0814
0815
0816 SUTIL_INLINE SUTIL_HOSTDEVICE float getByIndex(const float4& v, int i)
0817 {
0818 return ((float*)(&v))[i];
0819 }
0820
0821
0822 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(float4& v, int i, float x)
0823 {
0824 ((float*)(&v))[i] = x;
0825 }
0826
0827
0828
0829
0830
0831
0832 SUTIL_INLINE SUTIL_HOSTDEVICE int clamp(const int f, const int a, const int b)
0833 {
0834 return max(a, min(f, b));
0835 }
0836
0837
0838 SUTIL_INLINE SUTIL_HOSTDEVICE int getByIndex(const int1& v, int i)
0839 {
0840 return ((int*)(&v))[i];
0841 }
0842
0843
0844 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(int1& v, int i, int x)
0845 {
0846 ((int*)(&v))[i] = x;
0847 }
0848
0849
0850
0851
0852
0853
0854
0855
0856 SUTIL_INLINE SUTIL_HOSTDEVICE int2 make_int2(const int s)
0857 {
0858 return make_int2(s, s);
0859 }
0860 SUTIL_INLINE SUTIL_HOSTDEVICE int2 make_int2(const float2& a)
0861 {
0862 return make_int2(int(a.x), int(a.y));
0863 }
0864
0865
0866
0867 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator-(const int2& a)
0868 {
0869 return make_int2(-a.x, -a.y);
0870 }
0871
0872
0873 SUTIL_INLINE SUTIL_HOSTDEVICE int2 min(const int2& a, const int2& b)
0874 {
0875 return make_int2(min(a.x,b.x), min(a.y,b.y));
0876 }
0877
0878
0879 SUTIL_INLINE SUTIL_HOSTDEVICE int2 max(const int2& a, const int2& b)
0880 {
0881 return make_int2(max(a.x,b.x), max(a.y,b.y));
0882 }
0883
0884
0885
0886
0887 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator+(const int2& a, const int2& b)
0888 {
0889 return make_int2(a.x + b.x, a.y + b.y);
0890 }
0891 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(int2& a, const int2& b)
0892 {
0893 a.x += b.x; a.y += b.y;
0894 }
0895
0896
0897
0898
0899
0900 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator-(const int2& a, const int2& b)
0901 {
0902 return make_int2(a.x - b.x, a.y - b.y);
0903 }
0904 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator-(const int2& a, const int b)
0905 {
0906 return make_int2(a.x - b, a.y - b);
0907 }
0908 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(int2& a, const int2& b)
0909 {
0910 a.x -= b.x; a.y -= b.y;
0911 }
0912
0913
0914
0915
0916
0917 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator*(const int2& a, const int2& b)
0918 {
0919 return make_int2(a.x * b.x, a.y * b.y);
0920 }
0921 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator*(const int2& a, const int s)
0922 {
0923 return make_int2(a.x * s, a.y * s);
0924 }
0925 SUTIL_INLINE SUTIL_HOSTDEVICE int2 operator*(const int s, const int2& a)
0926 {
0927 return make_int2(a.x * s, a.y * s);
0928 }
0929 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(int2& a, const int s)
0930 {
0931 a.x *= s; a.y *= s;
0932 }
0933
0934
0935
0936
0937
0938 SUTIL_INLINE SUTIL_HOSTDEVICE int2 clamp(const int2& v, const int a, const int b)
0939 {
0940 return make_int2(clamp(v.x, a, b), clamp(v.y, a, b));
0941 }
0942
0943 SUTIL_INLINE SUTIL_HOSTDEVICE int2 clamp(const int2& v, const int2& a, const int2& b)
0944 {
0945 return make_int2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
0946 }
0947
0948
0949
0950
0951
0952 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const int2& a, const int2& b)
0953 {
0954 return a.x == b.x && a.y == b.y;
0955 }
0956
0957 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const int2& a, const int2& b)
0958 {
0959 return a.x != b.x || a.y != b.y;
0960 }
0961
0962
0963
0964 SUTIL_INLINE SUTIL_HOSTDEVICE int getByIndex(const int2& v, int i)
0965 {
0966 return ((int*)(&v))[i];
0967 }
0968
0969
0970 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(int2& v, int i, int x)
0971 {
0972 ((int*)(&v))[i] = x;
0973 }
0974
0975
0976
0977
0978
0979
0980
0981
0982 SUTIL_INLINE SUTIL_HOSTDEVICE int3 make_int3(const int s)
0983 {
0984 return make_int3(s, s, s);
0985 }
0986 SUTIL_INLINE SUTIL_HOSTDEVICE int3 make_int3(const float3& a)
0987 {
0988 return make_int3(int(a.x), int(a.y), int(a.z));
0989 }
0990
0991
0992
0993 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator-(const int3& a)
0994 {
0995 return make_int3(-a.x, -a.y, -a.z);
0996 }
0997
0998
0999 SUTIL_INLINE SUTIL_HOSTDEVICE int3 min(const int3& a, const int3& b)
1000 {
1001 return make_int3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
1002 }
1003
1004
1005 SUTIL_INLINE SUTIL_HOSTDEVICE int3 max(const int3& a, const int3& b)
1006 {
1007 return make_int3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
1008 }
1009
1010
1011
1012
1013 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator+(const int3& a, const int3& b)
1014 {
1015 return make_int3(a.x + b.x, a.y + b.y, a.z + b.z);
1016 }
1017 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(int3& a, const int3& b)
1018 {
1019 a.x += b.x; a.y += b.y; a.z += b.z;
1020 }
1021
1022
1023
1024
1025
1026 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator-(const int3& a, const int3& b)
1027 {
1028 return make_int3(a.x - b.x, a.y - b.y, a.z - b.z);
1029 }
1030
1031 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(int3& a, const int3& b)
1032 {
1033 a.x -= b.x; a.y -= b.y; a.z -= b.z;
1034 }
1035
1036
1037
1038
1039
1040 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator*(const int3& a, const int3& b)
1041 {
1042 return make_int3(a.x * b.x, a.y * b.y, a.z * b.z);
1043 }
1044 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator*(const int3& a, const int s)
1045 {
1046 return make_int3(a.x * s, a.y * s, a.z * s);
1047 }
1048 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator*(const int s, const int3& a)
1049 {
1050 return make_int3(a.x * s, a.y * s, a.z * s);
1051 }
1052 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(int3& a, const int s)
1053 {
1054 a.x *= s; a.y *= s; a.z *= s;
1055 }
1056
1057
1058
1059
1060
1061 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator/(const int3& a, const int3& b)
1062 {
1063 return make_int3(a.x / b.x, a.y / b.y, a.z / b.z);
1064 }
1065 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator/(const int3& a, const int s)
1066 {
1067 return make_int3(a.x / s, a.y / s, a.z / s);
1068 }
1069 SUTIL_INLINE SUTIL_HOSTDEVICE int3 operator/(const int s, const int3& a)
1070 {
1071 return make_int3(s /a.x, s / a.y, s / a.z);
1072 }
1073 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(int3& a, const int s)
1074 {
1075 a.x /= s; a.y /= s; a.z /= s;
1076 }
1077
1078
1079
1080
1081
1082 SUTIL_INLINE SUTIL_HOSTDEVICE int3 clamp(const int3& v, const int a, const int b)
1083 {
1084 return make_int3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1085 }
1086
1087 SUTIL_INLINE SUTIL_HOSTDEVICE int3 clamp(const int3& v, const int3& a, const int3& b)
1088 {
1089 return make_int3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1090 }
1091
1092
1093
1094
1095
1096 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const int3& a, const int3& b)
1097 {
1098 return a.x == b.x && a.y == b.y && a.z == b.z;
1099 }
1100
1101 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const int3& a, const int3& b)
1102 {
1103 return a.x != b.x || a.y != b.y || a.z != b.z;
1104 }
1105
1106
1107
1108 SUTIL_INLINE SUTIL_HOSTDEVICE int getByIndex(const int3& v, int i)
1109 {
1110 return ((int*)(&v))[i];
1111 }
1112
1113
1114 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(int3& v, int i, int x)
1115 {
1116 ((int*)(&v))[i] = x;
1117 }
1118
1119
1120
1121
1122
1123
1124
1125
1126 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int s)
1127 {
1128 return make_int4(s, s, s, s);
1129 }
1130 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const float4& a)
1131 {
1132 return make_int4((int)a.x, (int)a.y, (int)a.z, (int)a.w);
1133 }
1134
1135
1136
1137 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator-(const int4& a)
1138 {
1139 return make_int4(-a.x, -a.y, -a.z, -a.w);
1140 }
1141
1142
1143 SUTIL_INLINE SUTIL_HOSTDEVICE int4 min(const int4& a, const int4& b)
1144 {
1145 return make_int4(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z), min(a.w,b.w));
1146 }
1147
1148
1149 SUTIL_INLINE SUTIL_HOSTDEVICE int4 max(const int4& a, const int4& b)
1150 {
1151 return make_int4(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z), max(a.w,b.w));
1152 }
1153
1154
1155
1156
1157 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator+(const int4& a, const int4& b)
1158 {
1159 return make_int4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
1160 }
1161 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(int4& a, const int4& b)
1162 {
1163 a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
1164 }
1165
1166
1167
1168
1169
1170 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator-(const int4& a, const int4& b)
1171 {
1172 return make_int4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
1173 }
1174
1175 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(int4& a, const int4& b)
1176 {
1177 a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
1178 }
1179
1180
1181
1182
1183
1184 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator*(const int4& a, const int4& b)
1185 {
1186 return make_int4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
1187 }
1188 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator*(const int4& a, const int s)
1189 {
1190 return make_int4(a.x * s, a.y * s, a.z * s, a.w * s);
1191 }
1192 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator*(const int s, const int4& a)
1193 {
1194 return make_int4(a.x * s, a.y * s, a.z * s, a.w * s);
1195 }
1196 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(int4& a, const int s)
1197 {
1198 a.x *= s; a.y *= s; a.z *= s; a.w *= s;
1199 }
1200
1201
1202
1203
1204
1205 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator/(const int4& a, const int4& b)
1206 {
1207 return make_int4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
1208 }
1209 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator/(const int4& a, const int s)
1210 {
1211 return make_int4(a.x / s, a.y / s, a.z / s, a.w / s);
1212 }
1213 SUTIL_INLINE SUTIL_HOSTDEVICE int4 operator/(const int s, const int4& a)
1214 {
1215 return make_int4(s / a.x, s / a.y, s / a.z, s / a.w);
1216 }
1217 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(int4& a, const int s)
1218 {
1219 a.x /= s; a.y /= s; a.z /= s; a.w /= s;
1220 }
1221
1222
1223
1224
1225
1226 SUTIL_INLINE SUTIL_HOSTDEVICE int4 clamp(const int4& v, const int a, const int b)
1227 {
1228 return make_int4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
1229 }
1230
1231 SUTIL_INLINE SUTIL_HOSTDEVICE int4 clamp(const int4& v, const int4& a, const int4& b)
1232 {
1233 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));
1234 }
1235
1236
1237
1238
1239
1240 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const int4& a, const int4& b)
1241 {
1242 return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
1243 }
1244
1245 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const int4& a, const int4& b)
1246 {
1247 return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
1248 }
1249
1250
1251
1252 SUTIL_INLINE SUTIL_HOSTDEVICE int getByIndex(const int4& v, int i)
1253 {
1254 return ((int*)(&v))[i];
1255 }
1256
1257
1258 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(int4& v, int i, int x)
1259 {
1260 ((int*)(&v))[i] = x;
1261 }
1262
1263
1264
1265
1266
1267
1268 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int clamp(const unsigned int f, const unsigned int a, const unsigned int b)
1269 {
1270 return max(a, min(f, b));
1271 }
1272
1273
1274 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int getByIndex(const uint1& v, unsigned int i)
1275 {
1276 return ((unsigned int*)(&v))[i];
1277 }
1278
1279
1280 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(uint1& v, int i, unsigned int x)
1281 {
1282 ((unsigned int*)(&v))[i] = x;
1283 }
1284
1285
1286
1287
1288
1289
1290
1291
1292 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 make_uint2(const unsigned int s)
1293 {
1294 return make_uint2(s, s);
1295 }
1296 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 make_uint2(const float2& a)
1297 {
1298 return make_uint2((unsigned int)a.x, (unsigned int)a.y);
1299 }
1300
1301
1302
1303 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 min(const uint2& a, const uint2& b)
1304 {
1305 return make_uint2(min(a.x,b.x), min(a.y,b.y));
1306 }
1307
1308
1309 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 max(const uint2& a, const uint2& b)
1310 {
1311 return make_uint2(max(a.x,b.x), max(a.y,b.y));
1312 }
1313
1314
1315
1316
1317 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator+(const uint2& a, const uint2& b)
1318 {
1319 return make_uint2(a.x + b.x, a.y + b.y);
1320 }
1321 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(uint2& a, const uint2& b)
1322 {
1323 a.x += b.x; a.y += b.y;
1324 }
1325
1326
1327
1328
1329
1330 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator-(const uint2& a, const uint2& b)
1331 {
1332 return make_uint2(a.x - b.x, a.y - b.y);
1333 }
1334 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator-(const uint2& a, const unsigned int b)
1335 {
1336 return make_uint2(a.x - b, a.y - b);
1337 }
1338 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(uint2& a, const uint2& b)
1339 {
1340 a.x -= b.x; a.y -= b.y;
1341 }
1342
1343
1344
1345
1346
1347 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator*(const uint2& a, const uint2& b)
1348 {
1349 return make_uint2(a.x * b.x, a.y * b.y);
1350 }
1351 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator*(const uint2& a, const unsigned int s)
1352 {
1353 return make_uint2(a.x * s, a.y * s);
1354 }
1355 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 operator*(const unsigned int s, const uint2& a)
1356 {
1357 return make_uint2(a.x * s, a.y * s);
1358 }
1359 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(uint2& a, const unsigned int s)
1360 {
1361 a.x *= s; a.y *= s;
1362 }
1363
1364
1365
1366
1367
1368 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 clamp(const uint2& v, const unsigned int a, const unsigned int b)
1369 {
1370 return make_uint2(clamp(v.x, a, b), clamp(v.y, a, b));
1371 }
1372
1373 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 clamp(const uint2& v, const uint2& a, const uint2& b)
1374 {
1375 return make_uint2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
1376 }
1377
1378
1379
1380
1381
1382 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const uint2& a, const uint2& b)
1383 {
1384 return a.x == b.x && a.y == b.y;
1385 }
1386
1387 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const uint2& a, const uint2& b)
1388 {
1389 return a.x != b.x || a.y != b.y;
1390 }
1391
1392
1393
1394 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int getByIndex(const uint2& v, unsigned int i)
1395 {
1396 return ((unsigned int*)(&v))[i];
1397 }
1398
1399
1400 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(uint2& v, int i, unsigned int x)
1401 {
1402 ((unsigned int*)(&v))[i] = x;
1403 }
1404
1405
1406
1407
1408
1409
1410
1411
1412 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 make_uint3(const unsigned int s)
1413 {
1414 return make_uint3(s, s, s);
1415 }
1416 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 make_uint3(const float3& a)
1417 {
1418 return make_uint3((unsigned int)a.x, (unsigned int)a.y, (unsigned int)a.z);
1419 }
1420
1421
1422
1423 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 min(const uint3& a, const uint3& b)
1424 {
1425 return make_uint3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
1426 }
1427
1428
1429 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 max(const uint3& a, const uint3& b)
1430 {
1431 return make_uint3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
1432 }
1433
1434
1435
1436
1437 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator+(const uint3& a, const uint3& b)
1438 {
1439 return make_uint3(a.x + b.x, a.y + b.y, a.z + b.z);
1440 }
1441 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(uint3& a, const uint3& b)
1442 {
1443 a.x += b.x; a.y += b.y; a.z += b.z;
1444 }
1445
1446
1447
1448
1449
1450 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator-(const uint3& a, const uint3& b)
1451 {
1452 return make_uint3(a.x - b.x, a.y - b.y, a.z - b.z);
1453 }
1454
1455 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(uint3& a, const uint3& b)
1456 {
1457 a.x -= b.x; a.y -= b.y; a.z -= b.z;
1458 }
1459
1460
1461
1462
1463
1464 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator*(const uint3& a, const uint3& b)
1465 {
1466 return make_uint3(a.x * b.x, a.y * b.y, a.z * b.z);
1467 }
1468 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator*(const uint3& a, const unsigned int s)
1469 {
1470 return make_uint3(a.x * s, a.y * s, a.z * s);
1471 }
1472 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator*(const unsigned int s, const uint3& a)
1473 {
1474 return make_uint3(a.x * s, a.y * s, a.z * s);
1475 }
1476 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(uint3& a, const unsigned int s)
1477 {
1478 a.x *= s; a.y *= s; a.z *= s;
1479 }
1480
1481
1482
1483
1484
1485 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator/(const uint3& a, const uint3& b)
1486 {
1487 return make_uint3(a.x / b.x, a.y / b.y, a.z / b.z);
1488 }
1489 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator/(const uint3& a, const unsigned int s)
1490 {
1491 return make_uint3(a.x / s, a.y / s, a.z / s);
1492 }
1493 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 operator/(const unsigned int s, const uint3& a)
1494 {
1495 return make_uint3(s / a.x, s / a.y, s / a.z);
1496 }
1497 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(uint3& a, const unsigned int s)
1498 {
1499 a.x /= s; a.y /= s; a.z /= s;
1500 }
1501
1502
1503
1504
1505
1506 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 clamp(const uint3& v, const unsigned int a, const unsigned int b)
1507 {
1508 return make_uint3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1509 }
1510
1511 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 clamp(const uint3& v, const uint3& a, const uint3& b)
1512 {
1513 return make_uint3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1514 }
1515
1516
1517
1518
1519
1520 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const uint3& a, const uint3& b)
1521 {
1522 return a.x == b.x && a.y == b.y && a.z == b.z;
1523 }
1524
1525 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const uint3& a, const uint3& b)
1526 {
1527 return a.x != b.x || a.y != b.y || a.z != b.z;
1528 }
1529
1530
1531
1532
1533 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int getByIndex(const uint3& v, unsigned int i)
1534 {
1535 return ((unsigned int*)(&v))[i];
1536 }
1537
1538
1539
1540 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(uint3& v, int i, unsigned int x)
1541 {
1542 ((unsigned int*)(&v))[i] = x;
1543 }
1544
1545
1546
1547
1548
1549
1550
1551
1552 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const unsigned int s)
1553 {
1554 return make_uint4(s, s, s, s);
1555 }
1556 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const float4& a)
1557 {
1558 return make_uint4((unsigned int)a.x, (unsigned int)a.y, (unsigned int)a.z, (unsigned int)a.w);
1559 }
1560
1561
1562
1563
1564
1565 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 min(const uint4& a, const uint4& b)
1566 {
1567 return make_uint4(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z), min(a.w,b.w));
1568 }
1569
1570
1571
1572
1573
1574 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 max(const uint4& a, const uint4& b)
1575 {
1576 return make_uint4(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z), max(a.w,b.w));
1577 }
1578
1579
1580
1581
1582
1583 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator+(const uint4& a, const uint4& b)
1584 {
1585 return make_uint4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
1586 }
1587 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(uint4& a, const uint4& b)
1588 {
1589 a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
1590 }
1591
1592
1593
1594
1595
1596 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator-(const uint4& a, const uint4& b)
1597 {
1598 return make_uint4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
1599 }
1600
1601 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(uint4& a, const uint4& b)
1602 {
1603 a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
1604 }
1605
1606
1607
1608
1609
1610 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator*(const uint4& a, const uint4& b)
1611 {
1612 return make_uint4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
1613 }
1614 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator*(const uint4& a, const unsigned int s)
1615 {
1616 return make_uint4(a.x * s, a.y * s, a.z * s, a.w * s);
1617 }
1618 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator*(const unsigned int s, const uint4& a)
1619 {
1620 return make_uint4(a.x * s, a.y * s, a.z * s, a.w * s);
1621 }
1622 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(uint4& a, const unsigned int s)
1623 {
1624 a.x *= s; a.y *= s; a.z *= s; a.w *= s;
1625 }
1626
1627
1628
1629
1630
1631 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator/(const uint4& a, const uint4& b)
1632 {
1633 return make_uint4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
1634 }
1635 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator/(const uint4& a, const unsigned int s)
1636 {
1637 return make_uint4(a.x / s, a.y / s, a.z / s, a.w / s);
1638 }
1639 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 operator/(const unsigned int s, const uint4& a)
1640 {
1641 return make_uint4(s / a.x, s / a.y, s / a.z, s / a.w);
1642 }
1643 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(uint4& a, const unsigned int s)
1644 {
1645 a.x /= s; a.y /= s; a.z /= s; a.w /= s;
1646 }
1647
1648
1649
1650
1651
1652 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 clamp(const uint4& v, const unsigned int a, const unsigned int b)
1653 {
1654 return make_uint4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
1655 }
1656
1657 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 clamp(const uint4& v, const uint4& a, const uint4& b)
1658 {
1659 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));
1660 }
1661
1662
1663
1664
1665
1666 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const uint4& a, const uint4& b)
1667 {
1668 return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
1669 }
1670
1671 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const uint4& a, const uint4& b)
1672 {
1673 return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
1674 }
1675
1676
1677
1678
1679 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned int getByIndex(const uint4& v, unsigned int i)
1680 {
1681 return ((unsigned int*)(&v))[i];
1682 }
1683
1684
1685
1686 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(uint4& v, int i, unsigned int x)
1687 {
1688 ((unsigned int*)(&v))[i] = x;
1689 }
1690
1691
1692
1693
1694
1695 SUTIL_INLINE SUTIL_HOSTDEVICE long long clamp(const long long f, const long long a, const long long b)
1696 {
1697 return max(a, min(f, b));
1698 }
1699
1700
1701 SUTIL_INLINE SUTIL_HOSTDEVICE long long getByIndex(const longlong1& v, int i)
1702 {
1703 return ((long long*)(&v))[i];
1704 }
1705
1706
1707 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(longlong1& v, int i, long long x)
1708 {
1709 ((long long*)(&v))[i] = x;
1710 }
1711
1712
1713
1714
1715
1716
1717
1718
1719 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 make_longlong2(const long long s)
1720 {
1721 return make_longlong2(s, s);
1722 }
1723 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 make_longlong2(const float2& a)
1724 {
1725 return make_longlong2(int(a.x), int(a.y));
1726 }
1727
1728
1729
1730 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator-(const longlong2& a)
1731 {
1732 return make_longlong2(-a.x, -a.y);
1733 }
1734
1735
1736 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 min(const longlong2& a, const longlong2& b)
1737 {
1738 return make_longlong2(min(a.x, b.x), min(a.y, b.y));
1739 }
1740
1741
1742 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 max(const longlong2& a, const longlong2& b)
1743 {
1744 return make_longlong2(max(a.x, b.x), max(a.y, b.y));
1745 }
1746
1747
1748
1749
1750 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator+(const longlong2& a, const longlong2& b)
1751 {
1752 return make_longlong2(a.x + b.x, a.y + b.y);
1753 }
1754 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(longlong2& a, const longlong2& b)
1755 {
1756 a.x += b.x; a.y += b.y;
1757 }
1758
1759
1760
1761
1762
1763 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator-(const longlong2& a, const longlong2& b)
1764 {
1765 return make_longlong2(a.x - b.x, a.y - b.y);
1766 }
1767 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator-(const longlong2& a, const long long b)
1768 {
1769 return make_longlong2(a.x - b, a.y - b);
1770 }
1771 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(longlong2& a, const longlong2& b)
1772 {
1773 a.x -= b.x; a.y -= b.y;
1774 }
1775
1776
1777
1778
1779
1780 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator*(const longlong2& a, const longlong2& b)
1781 {
1782 return make_longlong2(a.x * b.x, a.y * b.y);
1783 }
1784 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator*(const longlong2& a, const long long s)
1785 {
1786 return make_longlong2(a.x * s, a.y * s);
1787 }
1788 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 operator*(const long long s, const longlong2& a)
1789 {
1790 return make_longlong2(a.x * s, a.y * s);
1791 }
1792 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(longlong2& a, const long long s)
1793 {
1794 a.x *= s; a.y *= s;
1795 }
1796
1797
1798
1799
1800
1801 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 clamp(const longlong2& v, const long long a, const long long b)
1802 {
1803 return make_longlong2(clamp(v.x, a, b), clamp(v.y, a, b));
1804 }
1805
1806 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 clamp(const longlong2& v, const longlong2& a, const longlong2& b)
1807 {
1808 return make_longlong2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
1809 }
1810
1811
1812
1813
1814
1815 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const longlong2& a, const longlong2& b)
1816 {
1817 return a.x == b.x && a.y == b.y;
1818 }
1819
1820 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const longlong2& a, const longlong2& b)
1821 {
1822 return a.x != b.x || a.y != b.y;
1823 }
1824
1825
1826
1827 SUTIL_INLINE SUTIL_HOSTDEVICE long long getByIndex(const longlong2& v, int i)
1828 {
1829 return ((long long*)(&v))[i];
1830 }
1831
1832
1833 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(longlong2& v, int i, long long x)
1834 {
1835 ((long long*)(&v))[i] = x;
1836 }
1837
1838
1839
1840
1841
1842
1843
1844
1845 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 make_longlong3(const long long s)
1846 {
1847 return make_longlong3(s, s, s);
1848 }
1849 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 make_longlong3(const float3& a)
1850 {
1851 return make_longlong3( (long long)a.x, (long long)a.y, (long long)a.z);
1852 }
1853
1854
1855
1856 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator-(const longlong3& a)
1857 {
1858 return make_longlong3(-a.x, -a.y, -a.z);
1859 }
1860
1861
1862 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 min(const longlong3& a, const longlong3& b)
1863 {
1864 return make_longlong3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
1865 }
1866
1867
1868 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 max(const longlong3& a, const longlong3& b)
1869 {
1870 return make_longlong3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
1871 }
1872
1873
1874
1875
1876 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator+(const longlong3& a, const longlong3& b)
1877 {
1878 return make_longlong3(a.x + b.x, a.y + b.y, a.z + b.z);
1879 }
1880 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(longlong3& a, const longlong3& b)
1881 {
1882 a.x += b.x; a.y += b.y; a.z += b.z;
1883 }
1884
1885
1886
1887
1888
1889 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator-(const longlong3& a, const longlong3& b)
1890 {
1891 return make_longlong3(a.x - b.x, a.y - b.y, a.z - b.z);
1892 }
1893
1894 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(longlong3& a, const longlong3& b)
1895 {
1896 a.x -= b.x; a.y -= b.y; a.z -= b.z;
1897 }
1898
1899
1900
1901
1902
1903 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator*(const longlong3& a, const longlong3& b)
1904 {
1905 return make_longlong3(a.x * b.x, a.y * b.y, a.z * b.z);
1906 }
1907 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator*(const longlong3& a, const long long s)
1908 {
1909 return make_longlong3(a.x * s, a.y * s, a.z * s);
1910 }
1911 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator*(const long long s, const longlong3& a)
1912 {
1913 return make_longlong3(a.x * s, a.y * s, a.z * s);
1914 }
1915 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(longlong3& a, const long long s)
1916 {
1917 a.x *= s; a.y *= s; a.z *= s;
1918 }
1919
1920
1921
1922
1923
1924 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator/(const longlong3& a, const longlong3& b)
1925 {
1926 return make_longlong3(a.x / b.x, a.y / b.y, a.z / b.z);
1927 }
1928 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator/(const longlong3& a, const long long s)
1929 {
1930 return make_longlong3(a.x / s, a.y / s, a.z / s);
1931 }
1932 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 operator/(const long long s, const longlong3& a)
1933 {
1934 return make_longlong3(s /a.x, s / a.y, s / a.z);
1935 }
1936 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(longlong3& a, const long long s)
1937 {
1938 a.x /= s; a.y /= s; a.z /= s;
1939 }
1940
1941
1942
1943
1944
1945 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 clamp(const longlong3& v, const long long a, const long long b)
1946 {
1947 return make_longlong3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
1948 }
1949
1950 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 clamp(const longlong3& v, const longlong3& a, const longlong3& b)
1951 {
1952 return make_longlong3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
1953 }
1954
1955
1956
1957
1958
1959 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const longlong3& a, const longlong3& b)
1960 {
1961 return a.x == b.x && a.y == b.y && a.z == b.z;
1962 }
1963
1964 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const longlong3& a, const longlong3& b)
1965 {
1966 return a.x != b.x || a.y != b.y || a.z != b.z;
1967 }
1968
1969
1970
1971 SUTIL_INLINE SUTIL_HOSTDEVICE long long getByIndex(const longlong3& v, int i)
1972 {
1973 return ((long long*)(&v))[i];
1974 }
1975
1976
1977 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(longlong3& v, int i, int x)
1978 {
1979 ((long long*)(&v))[i] = x;
1980 }
1981
1982
1983
1984
1985
1986
1987
1988
1989 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const long long s)
1990 {
1991 return make_longlong4(s, s, s, s);
1992 }
1993 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const float4& a)
1994 {
1995 return make_longlong4((long long)a.x, (long long)a.y, (long long)a.z, (long long)a.w);
1996 }
1997
1998
1999
2000 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator-(const longlong4& a)
2001 {
2002 return make_longlong4(-a.x, -a.y, -a.z, -a.w);
2003 }
2004
2005
2006 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 min(const longlong4& a, const longlong4& b)
2007 {
2008 return make_longlong4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
2009 }
2010
2011
2012 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 max(const longlong4& a, const longlong4& b)
2013 {
2014 return make_longlong4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
2015 }
2016
2017
2018
2019
2020 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator+(const longlong4& a, const longlong4& b)
2021 {
2022 return make_longlong4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
2023 }
2024 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(longlong4& a, const longlong4& b)
2025 {
2026 a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
2027 }
2028
2029
2030
2031
2032
2033 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator-(const longlong4& a, const longlong4& b)
2034 {
2035 return make_longlong4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
2036 }
2037
2038 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(longlong4& a, const longlong4& b)
2039 {
2040 a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
2041 }
2042
2043
2044
2045
2046
2047 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator*(const longlong4& a, const longlong4& b)
2048 {
2049 return make_longlong4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
2050 }
2051 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator*(const longlong4& a, const long long s)
2052 {
2053 return make_longlong4(a.x * s, a.y * s, a.z * s, a.w * s);
2054 }
2055 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator*(const long long s, const longlong4& a)
2056 {
2057 return make_longlong4(a.x * s, a.y * s, a.z * s, a.w * s);
2058 }
2059 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(longlong4& a, const long long s)
2060 {
2061 a.x *= s; a.y *= s; a.z *= s; a.w *= s;
2062 }
2063
2064
2065
2066
2067
2068 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator/(const longlong4& a, const longlong4& b)
2069 {
2070 return make_longlong4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
2071 }
2072 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator/(const longlong4& a, const long long s)
2073 {
2074 return make_longlong4(a.x / s, a.y / s, a.z / s, a.w / s);
2075 }
2076 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 operator/(const long long s, const longlong4& a)
2077 {
2078 return make_longlong4(s / a.x, s / a.y, s / a.z, s / a.w);
2079 }
2080 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(longlong4& a, const long long s)
2081 {
2082 a.x /= s; a.y /= s; a.z /= s; a.w /= s;
2083 }
2084
2085
2086
2087
2088
2089 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 clamp(const longlong4& v, const long long a, const long long b)
2090 {
2091 return make_longlong4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
2092 }
2093
2094 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 clamp(const longlong4& v, const longlong4& a, const longlong4& b)
2095 {
2096 return make_longlong4(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));
2097 }
2098
2099
2100
2101
2102
2103 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const longlong4& a, const longlong4& b)
2104 {
2105 return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
2106 }
2107
2108 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const longlong4& a, const longlong4& b)
2109 {
2110 return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
2111 }
2112
2113
2114
2115 SUTIL_INLINE SUTIL_HOSTDEVICE long long getByIndex(const longlong4& v, int i)
2116 {
2117 return ((long long*)(&v))[i];
2118 }
2119
2120
2121 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(longlong4& v, int i, long long x)
2122 {
2123 ((long long*)(&v))[i] = x;
2124 }
2125
2126
2127
2128
2129
2130 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long clamp(const unsigned long long f, const unsigned long long a, const unsigned long long b)
2131 {
2132 return max(a, min(f, b));
2133 }
2134
2135
2136 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long getByIndex(const ulonglong1& v, unsigned int i)
2137 {
2138 return ((unsigned long long*)(&v))[i];
2139 }
2140
2141
2142 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(ulonglong1& v, int i, unsigned long long x)
2143 {
2144 ((unsigned long long*)(&v))[i] = x;
2145 }
2146
2147
2148
2149
2150
2151
2152
2153
2154 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 make_ulonglong2(const unsigned long long s)
2155 {
2156 return make_ulonglong2(s, s);
2157 }
2158 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 make_ulonglong2(const float2& a)
2159 {
2160 return make_ulonglong2((unsigned long long)a.x, (unsigned long long)a.y);
2161 }
2162
2163
2164
2165 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 min(const ulonglong2& a, const ulonglong2& b)
2166 {
2167 return make_ulonglong2(min(a.x, b.x), min(a.y, b.y));
2168 }
2169
2170
2171 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 max(const ulonglong2& a, const ulonglong2& b)
2172 {
2173 return make_ulonglong2(max(a.x, b.x), max(a.y, b.y));
2174 }
2175
2176
2177
2178
2179 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator+(const ulonglong2& a, const ulonglong2& b)
2180 {
2181 return make_ulonglong2(a.x + b.x, a.y + b.y);
2182 }
2183 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(ulonglong2& a, const ulonglong2& b)
2184 {
2185 a.x += b.x; a.y += b.y;
2186 }
2187
2188
2189
2190
2191
2192 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator-(const ulonglong2& a, const ulonglong2& b)
2193 {
2194 return make_ulonglong2(a.x - b.x, a.y - b.y);
2195 }
2196 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator-(const ulonglong2& a, const unsigned long long b)
2197 {
2198 return make_ulonglong2(a.x - b, a.y - b);
2199 }
2200 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(ulonglong2& a, const ulonglong2& b)
2201 {
2202 a.x -= b.x; a.y -= b.y;
2203 }
2204
2205
2206
2207
2208
2209 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator*(const ulonglong2& a, const ulonglong2& b)
2210 {
2211 return make_ulonglong2(a.x * b.x, a.y * b.y);
2212 }
2213 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator*(const ulonglong2& a, const unsigned long long s)
2214 {
2215 return make_ulonglong2(a.x * s, a.y * s);
2216 }
2217 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 operator*(const unsigned long long s, const ulonglong2& a)
2218 {
2219 return make_ulonglong2(a.x * s, a.y * s);
2220 }
2221 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(ulonglong2& a, const unsigned long long s)
2222 {
2223 a.x *= s; a.y *= s;
2224 }
2225
2226
2227
2228
2229
2230 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 clamp(const ulonglong2& v, const unsigned long long a, const unsigned long long b)
2231 {
2232 return make_ulonglong2(clamp(v.x, a, b), clamp(v.y, a, b));
2233 }
2234
2235 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 clamp(const ulonglong2& v, const ulonglong2& a, const ulonglong2& b)
2236 {
2237 return make_ulonglong2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
2238 }
2239
2240
2241
2242
2243
2244 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const ulonglong2& a, const ulonglong2& b)
2245 {
2246 return a.x == b.x && a.y == b.y;
2247 }
2248
2249 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const ulonglong2& a, const ulonglong2& b)
2250 {
2251 return a.x != b.x || a.y != b.y;
2252 }
2253
2254
2255
2256 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long getByIndex(const ulonglong2& v, unsigned int i)
2257 {
2258 return ((unsigned long long*)(&v))[i];
2259 }
2260
2261
2262 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(ulonglong2& v, int i, unsigned long long x)
2263 {
2264 ((unsigned long long*)(&v))[i] = x;
2265 }
2266
2267
2268
2269
2270
2271
2272
2273
2274 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 make_ulonglong3(const unsigned long long s)
2275 {
2276 return make_ulonglong3(s, s, s);
2277 }
2278 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 make_ulonglong3(const float3& a)
2279 {
2280 return make_ulonglong3((unsigned long long)a.x, (unsigned long long)a.y, (unsigned long long)a.z);
2281 }
2282
2283
2284
2285 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 min(const ulonglong3& a, const ulonglong3& b)
2286 {
2287 return make_ulonglong3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
2288 }
2289
2290
2291 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 max(const ulonglong3& a, const ulonglong3& b)
2292 {
2293 return make_ulonglong3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
2294 }
2295
2296
2297
2298
2299 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator+(const ulonglong3& a, const ulonglong3& b)
2300 {
2301 return make_ulonglong3(a.x + b.x, a.y + b.y, a.z + b.z);
2302 }
2303 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(ulonglong3& a, const ulonglong3& b)
2304 {
2305 a.x += b.x; a.y += b.y; a.z += b.z;
2306 }
2307
2308
2309
2310
2311
2312 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator-(const ulonglong3& a, const ulonglong3& b)
2313 {
2314 return make_ulonglong3(a.x - b.x, a.y - b.y, a.z - b.z);
2315 }
2316
2317 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(ulonglong3& a, const ulonglong3& b)
2318 {
2319 a.x -= b.x; a.y -= b.y; a.z -= b.z;
2320 }
2321
2322
2323
2324
2325
2326 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator*(const ulonglong3& a, const ulonglong3& b)
2327 {
2328 return make_ulonglong3(a.x * b.x, a.y * b.y, a.z * b.z);
2329 }
2330 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator*(const ulonglong3& a, const unsigned long long s)
2331 {
2332 return make_ulonglong3(a.x * s, a.y * s, a.z * s);
2333 }
2334 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator*(const unsigned long long s, const ulonglong3& a)
2335 {
2336 return make_ulonglong3(a.x * s, a.y * s, a.z * s);
2337 }
2338 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(ulonglong3& a, const unsigned long long s)
2339 {
2340 a.x *= s; a.y *= s; a.z *= s;
2341 }
2342
2343
2344
2345
2346
2347 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator/(const ulonglong3& a, const ulonglong3& b)
2348 {
2349 return make_ulonglong3(a.x / b.x, a.y / b.y, a.z / b.z);
2350 }
2351 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator/(const ulonglong3& a, const unsigned long long s)
2352 {
2353 return make_ulonglong3(a.x / s, a.y / s, a.z / s);
2354 }
2355 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 operator/(const unsigned long long s, const ulonglong3& a)
2356 {
2357 return make_ulonglong3(s / a.x, s / a.y, s / a.z);
2358 }
2359 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(ulonglong3& a, const unsigned long long s)
2360 {
2361 a.x /= s; a.y /= s; a.z /= s;
2362 }
2363
2364
2365
2366
2367
2368 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 clamp(const ulonglong3& v, const unsigned long long a, const unsigned long long b)
2369 {
2370 return make_ulonglong3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
2371 }
2372
2373 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 clamp(const ulonglong3& v, const ulonglong3& a, const ulonglong3& b)
2374 {
2375 return make_ulonglong3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
2376 }
2377
2378
2379
2380
2381
2382 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const ulonglong3& a, const ulonglong3& b)
2383 {
2384 return a.x == b.x && a.y == b.y && a.z == b.z;
2385 }
2386
2387 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const ulonglong3& a, const ulonglong3& b)
2388 {
2389 return a.x != b.x || a.y != b.y || a.z != b.z;
2390 }
2391
2392
2393
2394
2395 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long getByIndex(const ulonglong3& v, unsigned int i)
2396 {
2397 return ((unsigned long long*)(&v))[i];
2398 }
2399
2400
2401
2402 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(ulonglong3& v, int i, unsigned long long x)
2403 {
2404 ((unsigned long long*)(&v))[i] = x;
2405 }
2406
2407
2408
2409
2410
2411
2412
2413
2414 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const unsigned long long s)
2415 {
2416 return make_ulonglong4(s, s, s, s);
2417 }
2418 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const float4& a)
2419 {
2420 return make_ulonglong4((unsigned long long)a.x, (unsigned long long)a.y, (unsigned long long)a.z, (unsigned long long)a.w);
2421 }
2422
2423
2424
2425
2426
2427 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 min(const ulonglong4& a, const ulonglong4& b)
2428 {
2429 return make_ulonglong4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
2430 }
2431
2432
2433
2434
2435
2436 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 max(const ulonglong4& a, const ulonglong4& b)
2437 {
2438 return make_ulonglong4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
2439 }
2440
2441
2442
2443
2444
2445 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator+(const ulonglong4& a, const ulonglong4& b)
2446 {
2447 return make_ulonglong4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
2448 }
2449 SUTIL_INLINE SUTIL_HOSTDEVICE void operator+=(ulonglong4& a, const ulonglong4& b)
2450 {
2451 a.x += b.x; a.y += b.y; a.z += b.z; a.w += b.w;
2452 }
2453
2454
2455
2456
2457
2458 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator-(const ulonglong4& a, const ulonglong4& b)
2459 {
2460 return make_ulonglong4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
2461 }
2462
2463 SUTIL_INLINE SUTIL_HOSTDEVICE void operator-=(ulonglong4& a, const ulonglong4& b)
2464 {
2465 a.x -= b.x; a.y -= b.y; a.z -= b.z; a.w -= b.w;
2466 }
2467
2468
2469
2470
2471
2472 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator*(const ulonglong4& a, const ulonglong4& b)
2473 {
2474 return make_ulonglong4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
2475 }
2476 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator*(const ulonglong4& a, const unsigned long long s)
2477 {
2478 return make_ulonglong4(a.x * s, a.y * s, a.z * s, a.w * s);
2479 }
2480 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator*(const unsigned long long s, const ulonglong4& a)
2481 {
2482 return make_ulonglong4(a.x * s, a.y * s, a.z * s, a.w * s);
2483 }
2484 SUTIL_INLINE SUTIL_HOSTDEVICE void operator*=(ulonglong4& a, const unsigned long long s)
2485 {
2486 a.x *= s; a.y *= s; a.z *= s; a.w *= s;
2487 }
2488
2489
2490
2491
2492
2493 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator/(const ulonglong4& a, const ulonglong4& b)
2494 {
2495 return make_ulonglong4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
2496 }
2497 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator/(const ulonglong4& a, const unsigned long long s)
2498 {
2499 return make_ulonglong4(a.x / s, a.y / s, a.z / s, a.w / s);
2500 }
2501 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 operator/(const unsigned long long s, const ulonglong4& a)
2502 {
2503 return make_ulonglong4(s / a.x, s / a.y, s / a.z, s / a.w);
2504 }
2505 SUTIL_INLINE SUTIL_HOSTDEVICE void operator/=(ulonglong4& a, const unsigned long long s)
2506 {
2507 a.x /= s; a.y /= s; a.z /= s; a.w /= s;
2508 }
2509
2510
2511
2512
2513
2514 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 clamp(const ulonglong4& v, const unsigned long long a, const unsigned long long b)
2515 {
2516 return make_ulonglong4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
2517 }
2518
2519 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 clamp(const ulonglong4& v, const ulonglong4& a, const ulonglong4& b)
2520 {
2521 return make_ulonglong4(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));
2522 }
2523
2524
2525
2526
2527
2528 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator==(const ulonglong4& a, const ulonglong4& b)
2529 {
2530 return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
2531 }
2532
2533 SUTIL_INLINE SUTIL_HOSTDEVICE bool operator!=(const ulonglong4& a, const ulonglong4& b)
2534 {
2535 return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
2536 }
2537
2538
2539
2540
2541 SUTIL_INLINE SUTIL_HOSTDEVICE unsigned long long getByIndex(const ulonglong4& v, unsigned int i)
2542 {
2543 return ((unsigned long long*)(&v))[i];
2544 }
2545
2546
2547
2548 SUTIL_INLINE SUTIL_HOSTDEVICE void setByIndex(ulonglong4& v, int i, unsigned long long x)
2549 {
2550 ((unsigned long long*)(&v))[i] = x;
2551 }
2552
2553
2554
2555
2556
2557
2558
2559 SUTIL_INLINE SUTIL_HOSTDEVICE int2 make_int2(const int3& v0) { return make_int2( v0.x, v0.y ); }
2560 SUTIL_INLINE SUTIL_HOSTDEVICE int2 make_int2(const int4& v0) { return make_int2( v0.x, v0.y ); }
2561 SUTIL_INLINE SUTIL_HOSTDEVICE int3 make_int3(const int4& v0) { return make_int3( v0.x, v0.y, v0.z ); }
2562 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 make_uint2(const uint3& v0) { return make_uint2( v0.x, v0.y ); }
2563 SUTIL_INLINE SUTIL_HOSTDEVICE uint2 make_uint2(const uint4& v0) { return make_uint2( v0.x, v0.y ); }
2564 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 make_uint3(const uint4& v0) { return make_uint3( v0.x, v0.y, v0.z ); }
2565 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 make_longlong2(const longlong3& v0) { return make_longlong2( v0.x, v0.y ); }
2566 SUTIL_INLINE SUTIL_HOSTDEVICE longlong2 make_longlong2(const longlong4& v0) { return make_longlong2( v0.x, v0.y ); }
2567 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 make_longlong3(const longlong4& v0) { return make_longlong3( v0.x, v0.y, v0.z ); }
2568 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 make_ulonglong2(const ulonglong3& v0) { return make_ulonglong2( v0.x, v0.y ); }
2569 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong2 make_ulonglong2(const ulonglong4& v0) { return make_ulonglong2( v0.x, v0.y ); }
2570 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 make_ulonglong3(const ulonglong4& v0) { return make_ulonglong3( v0.x, v0.y, v0.z ); }
2571 SUTIL_INLINE SUTIL_HOSTDEVICE float2 make_float2(const float3& v0) { return make_float2( v0.x, v0.y ); }
2572 SUTIL_INLINE SUTIL_HOSTDEVICE float2 make_float2(const float4& v0) { return make_float2( v0.x, v0.y ); }
2573 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const float4& v0) { return make_float3( v0.x, v0.y, v0.z ); }
2574
2575
2576
2577
2578
2579 SUTIL_INLINE SUTIL_HOSTDEVICE int3 make_int3(const int v0, const int2& v1) { return make_int3( v0, v1.x, v1.y ); }
2580 SUTIL_INLINE SUTIL_HOSTDEVICE int3 make_int3(const int2& v0, const int v1) { return make_int3( v0.x, v0.y, v1 ); }
2581 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int v0, const int v1, const int2& v2) { return make_int4( v0, v1, v2.x, v2.y ); }
2582 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int v0, const int2& v1, const int v2) { return make_int4( v0, v1.x, v1.y, v2 ); }
2583 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int2& v0, const int v1, const int v2) { return make_int4( v0.x, v0.y, v1, v2 ); }
2584 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int v0, const int3& v1) { return make_int4( v0, v1.x, v1.y, v1.z ); }
2585 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int3& v0, const int v1) { return make_int4( v0.x, v0.y, v0.z, v1 ); }
2586 SUTIL_INLINE SUTIL_HOSTDEVICE int4 make_int4(const int2& v0, const int2& v1) { return make_int4( v0.x, v0.y, v1.x, v1.y ); }
2587 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 make_uint3(const unsigned int v0, const uint2& v1) { return make_uint3( v0, v1.x, v1.y ); }
2588 SUTIL_INLINE SUTIL_HOSTDEVICE uint3 make_uint3(const uint2& v0, const unsigned int v1) { return make_uint3( v0.x, v0.y, v1 ); }
2589 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const unsigned int v1, const uint2& v2) { return make_uint4( v0, v1, v2.x, v2.y ); }
2590 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const uint2& v1, const unsigned int v2) { return make_uint4( v0, v1.x, v1.y, v2 ); }
2591 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const uint2& v0, const unsigned int v1, const unsigned int v2) { return make_uint4( v0.x, v0.y, v1, v2 ); }
2592 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const uint3& v1) { return make_uint4( v0, v1.x, v1.y, v1.z ); }
2593 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const uint3& v0, const unsigned int v1) { return make_uint4( v0.x, v0.y, v0.z, v1 ); }
2594 SUTIL_INLINE SUTIL_HOSTDEVICE uint4 make_uint4(const uint2& v0, const uint2& v1) { return make_uint4( v0.x, v0.y, v1.x, v1.y ); }
2595 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 make_longlong3(const long long v0, const longlong2& v1) { return make_longlong3(v0, v1.x, v1.y); }
2596 SUTIL_INLINE SUTIL_HOSTDEVICE longlong3 make_longlong3(const longlong2& v0, const long long v1) { return make_longlong3(v0.x, v0.y, v1); }
2597 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const long long v0, const long long v1, const longlong2& v2) { return make_longlong4(v0, v1, v2.x, v2.y); }
2598 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const long long v0, const longlong2& v1, const long long v2) { return make_longlong4(v0, v1.x, v1.y, v2); }
2599 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const longlong2& v0, const long long v1, const long long v2) { return make_longlong4(v0.x, v0.y, v1, v2); }
2600 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const long long v0, const longlong3& v1) { return make_longlong4(v0, v1.x, v1.y, v1.z); }
2601 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const longlong3& v0, const long long v1) { return make_longlong4(v0.x, v0.y, v0.z, v1); }
2602 SUTIL_INLINE SUTIL_HOSTDEVICE longlong4 make_longlong4(const longlong2& v0, const longlong2& v1) { return make_longlong4(v0.x, v0.y, v1.x, v1.y); }
2603 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 make_ulonglong3(const unsigned long long v0, const ulonglong2& v1) { return make_ulonglong3(v0, v1.x, v1.y); }
2604 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong3 make_ulonglong3(const ulonglong2& v0, const unsigned long long v1) { return make_ulonglong3(v0.x, v0.y, v1); }
2605 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const unsigned long long v0, const unsigned long long v1, const ulonglong2& v2) { return make_ulonglong4(v0, v1, v2.x, v2.y); }
2606 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const unsigned long long v0, const ulonglong2& v1, const unsigned long long v2) { return make_ulonglong4(v0, v1.x, v1.y, v2); }
2607 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const ulonglong2& v0, const unsigned long long v1, const unsigned long long v2) { return make_ulonglong4(v0.x, v0.y, v1, v2); }
2608 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const unsigned long long v0, const ulonglong3& v1) { return make_ulonglong4(v0, v1.x, v1.y, v1.z); }
2609 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const ulonglong3& v0, const unsigned long long v1) { return make_ulonglong4(v0.x, v0.y, v0.z, v1); }
2610 SUTIL_INLINE SUTIL_HOSTDEVICE ulonglong4 make_ulonglong4(const ulonglong2& v0, const ulonglong2& v1) { return make_ulonglong4(v0.x, v0.y, v1.x, v1.y); }
2611 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const float2& v0, const float v1) { return make_float3(v0.x, v0.y, v1); }
2612 SUTIL_INLINE SUTIL_HOSTDEVICE float3 make_float3(const float v0, const float2& v1) { return make_float3( v0, v1.x, v1.y ); }
2613 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float v0, const float v1, const float2& v2) { return make_float4( v0, v1, v2.x, v2.y ); }
2614 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float v0, const float2& v1, const float v2) { return make_float4( v0, v1.x, v1.y, v2 ); }
2615 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float2& v0, const float v1, const float v2) { return make_float4( v0.x, v0.y, v1, v2 ); }
2616 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float v0, const float3& v1) { return make_float4( v0, v1.x, v1.y, v1.z ); }
2617 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float3& v0, const float v1) { return make_float4( v0.x, v0.y, v0.z, v1 ); }
2618 SUTIL_INLINE SUTIL_HOSTDEVICE float4 make_float4(const float2& v0, const float2& v1) { return make_float4( v0.x, v0.y, v1.x, v1.y ); }
2619
2620
2621
2622
2623
2624
2625 #if defined(__CUDACC__) || defined(__CUDABE__)
2626 #else
2627
2628 #include <iostream>
2629 #include <iomanip>
2630
2631 inline std::ostream& operator<<(std::ostream& os, const float3& v)
2632 {
2633 int w = 6 ;
2634 os
2635 << "("
2636 << std::setw(w) << std::fixed << std::setprecision(3) << v.x
2637 << ","
2638 << std::setw(w) << std::fixed << std::setprecision(3) << v.y
2639 << ","
2640 << std::setw(w) << std::fixed << std::setprecision(3) << v.z
2641 << ") "
2642 ;
2643 return os;
2644 }
2645
2646 inline std::ostream& operator<<(std::ostream& os, const float4& v)
2647 {
2648 int w = 6 ;
2649 os
2650 << "("
2651 << std::setw(w) << std::fixed << std::setprecision(3) << v.x
2652 << ","
2653 << std::setw(w) << std::fixed << std::setprecision(3) << v.y
2654 << ","
2655 << std::setw(w) << std::fixed << std::setprecision(3) << v.z
2656 << ","
2657 << std::setw(w) << std::fixed << std::setprecision(3) << v.w
2658 << ") "
2659 ;
2660 return os;
2661 }
2662
2663
2664 #endif
2665