Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-21 07:54:31

0001 // SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
0002 // SPDX-License-Identifier: BSD-3-Clause
0003 //
0004 
0005 #pragma once
0006 
0007 #include <OptiXToolkit/ShaderUtil/Preprocessor.h>
0008 
0009 #include <vector_functions.h>
0010 #include <vector_types.h>
0011 
0012 #if !defined(__CUDACC_RTC__)
0013 #include <cmath>
0014 #include <cstdlib>
0015 #endif
0016 
0017 /* scalar functions used in vector functions */
0018 #ifndef M_PIf
0019 #define M_PIf       3.14159265358979323846f
0020 #endif
0021 #ifndef M_PI_2f
0022 #define M_PI_2f     1.57079632679489661923f
0023 #endif
0024 #ifndef M_1_PIf
0025 #define M_1_PIf     0.318309886183790671538f
0026 #endif
0027 
0028 // Operators are defined in the global namespace so that
0029 // argument-dependent lookup will find them.
0030 //
0031 // Functions are declared in namespace otk.
0032 
0033 namespace otk {
0034 
0035 #if defined( __CUDACC__ )
0036 using ::max;
0037 using ::min;
0038 #else
0039 #undef max
0040 #undef min
0041 
0042 OTK_INLINE OTK_HOSTDEVICE int max(int a, int b)
0043 {
0044     return a > b ? a : b;
0045 }
0046 
0047 OTK_INLINE OTK_HOSTDEVICE int min(int a, int b)
0048 {
0049     return a < b ? a : b;
0050 }
0051 
0052 OTK_INLINE OTK_HOSTDEVICE long long max(long long a, long long b)
0053 {
0054     return a > b ? a : b;
0055 }
0056 
0057 OTK_INLINE OTK_HOSTDEVICE long long min(long long a, long long b)
0058 {
0059     return a < b ? a : b;
0060 }
0061 
0062 OTK_INLINE OTK_HOSTDEVICE unsigned int max(unsigned int a, unsigned int b)
0063 {
0064     return a > b ? a : b;
0065 }
0066 
0067 OTK_INLINE OTK_HOSTDEVICE unsigned int min(unsigned int a, unsigned int b)
0068 {
0069     return a < b ? a : b;
0070 }
0071 
0072 OTK_INLINE OTK_HOSTDEVICE unsigned long long max(unsigned long long a, unsigned long long b)
0073 {
0074     return a > b ? a : b;
0075 }
0076 
0077 OTK_INLINE OTK_HOSTDEVICE unsigned long long min(unsigned long long a, unsigned long long b)
0078 {
0079     return a < b ? a : b;
0080 }
0081 
0082 
0083 /** lerp */
0084 OTK_INLINE OTK_HOSTDEVICE float lerp(const float a, const float b, const float t)
0085 {
0086   return a + t*(b-a);
0087 }
0088 
0089 /** bilerp */
0090 OTK_INLINE OTK_HOSTDEVICE float bilerp(const float x00, const float x10, const float x01, const float x11,
0091                                          const float u, const float v)
0092 {
0093   return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0094 }
0095 
0096 template <typename IntegerType>
0097 OTK_INLINE OTK_HOSTDEVICE IntegerType roundUp(IntegerType x, IntegerType y)
0098 {
0099     return ( ( x + y - 1 ) / y ) * y;
0100 }
0101 
0102 #endif
0103 
0104 /** clamp */
0105 OTK_INLINE OTK_HOSTDEVICE float clamp( const float f, const float a, const float b )
0106 {
0107     return ::fmaxf( a, fminf( f, b ) );
0108 }
0109 
0110 } // namespace otk
0111 
0112 /* float2 operators */
0113 /******************************************************************************/
0114 
0115 /** negate */
0116 OTK_INLINE OTK_HOSTDEVICE float2 operator-(const float2& a)
0117 {
0118   return ::make_float2(-a.x, -a.y);
0119 }
0120 
0121 /** add
0122 * @{
0123 */
0124 OTK_INLINE OTK_HOSTDEVICE float2 operator+(const float2& a, const float2& b)
0125 {
0126   return ::make_float2(a.x + b.x, a.y + b.y);
0127 }
0128 OTK_INLINE OTK_HOSTDEVICE float2 operator+(const float2& a, const float b)
0129 {
0130   return ::make_float2(a.x + b, a.y + b);
0131 }
0132 OTK_INLINE OTK_HOSTDEVICE float2 operator+(const float a, const float2& b)
0133 {
0134   return ::make_float2(a + b.x, a + b.y);
0135 }
0136 OTK_INLINE OTK_HOSTDEVICE float2& operator+=(float2& a, const float2& b)
0137 {
0138   a = a + b;
0139   return a;
0140 }
0141 OTK_INLINE OTK_HOSTDEVICE float2& operator+=(float2& a, const float b)
0142 {
0143   a = a + b;
0144   return a;
0145 }
0146 /** @} */
0147 
0148 /** subtract
0149 * @{
0150 */
0151 OTK_INLINE OTK_HOSTDEVICE float2 operator-(const float2& a, const float2& b)
0152 {
0153   return ::make_float2(a.x - b.x, a.y - b.y);
0154 }
0155 OTK_INLINE OTK_HOSTDEVICE float2 operator-(const float2& a, const float b)
0156 {
0157   return ::make_float2(a.x - b, a.y - b);
0158 }
0159 OTK_INLINE OTK_HOSTDEVICE float2 operator-(const float a, const float2& b)
0160 {
0161   return ::make_float2(a - b.x, a - b.y);
0162 }
0163 OTK_INLINE OTK_HOSTDEVICE float2& operator-=(float2& a, const float2& b)
0164 {
0165   a = a - b;
0166   return a;
0167 }
0168 OTK_INLINE OTK_HOSTDEVICE float2& operator-=(float2& a, const float b)
0169 {
0170   a = a - b;
0171   return a;
0172 }
0173 /** @} */
0174 
0175 /** multiply
0176 * @{
0177 */
0178 OTK_INLINE OTK_HOSTDEVICE float2 operator*(const float2& a, const float2& b)
0179 {
0180   return ::make_float2(a.x * b.x, a.y * b.y);
0181 }
0182 OTK_INLINE OTK_HOSTDEVICE float2 operator*(const float2& a, const float s)
0183 {
0184   return ::make_float2(a.x * s, a.y * s);
0185 }
0186 OTK_INLINE OTK_HOSTDEVICE float2 operator*(const float s, const float2& a)
0187 {
0188   return ::make_float2(a.x * s, a.y * s);
0189 }
0190 OTK_INLINE OTK_HOSTDEVICE float2& operator*=(float2& a, const float2& s)
0191 {
0192   a = a * s;
0193   return a;
0194 }
0195 OTK_INLINE OTK_HOSTDEVICE float2& operator*=(float2& a, const float s)
0196 {
0197   a = a * s;
0198   return a;
0199 }
0200 /** @} */
0201 
0202 /** divide
0203 * @{
0204 */
0205 OTK_INLINE OTK_HOSTDEVICE float2 operator/(const float2& a, const float2& b)
0206 {
0207   return ::make_float2(a.x / b.x, a.y / b.y);
0208 }
0209 OTK_INLINE OTK_HOSTDEVICE float2 operator/(const float2& a, const float s)
0210 {
0211   float inv = 1.0f / s;
0212   return a * inv;
0213 }
0214 OTK_INLINE OTK_HOSTDEVICE float2 operator/(const float s, const float2& a)
0215 {
0216   return ::make_float2( s/a.x, s/a.y );
0217 }
0218 OTK_INLINE OTK_HOSTDEVICE float2& operator/=(float2& a, const float2& s)
0219 {
0220   a = a / s;
0221   return a;
0222 }
0223 OTK_INLINE OTK_HOSTDEVICE float2& operator/=(float2& a, const float s)
0224 {
0225   a = a / s;
0226   return a;
0227 }
0228 /** @} */
0229 
0230 /** equality
0231 * @{
0232 */
0233 OTK_INLINE OTK_HOSTDEVICE bool operator==( const float2& a, const float2& b )
0234 {
0235   return a.x == b.x && a.y == b.y;
0236 }
0237 
0238 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const float2& a, const float2& b )
0239 {
0240   return !( a == b );
0241 }
0242 /** @} */
0243 
0244 namespace otk {
0245 
0246 /* float2 functions */
0247 /******************************************************************************/
0248 
0249 /** additional constructors
0250 * @{
0251 */
0252 using ::make_float2;
0253 
0254 
0255 OTK_INLINE OTK_HOSTDEVICE float2 make_float2(const float s)
0256 {
0257   return ::make_float2(s, s);
0258 }
0259 OTK_INLINE OTK_HOSTDEVICE float2 make_float2(const int2& a)
0260 {
0261   return ::make_float2(float(a.x), float(a.y));
0262 }
0263 OTK_INLINE OTK_HOSTDEVICE float2 make_float2(const uint2& a)
0264 {
0265   return ::make_float2(float(a.x), float(a.y));
0266 }
0267 /** @} */
0268 
0269 /** min
0270 * @{
0271 */
0272 using ::fminf;
0273 
0274 OTK_INLINE OTK_HOSTDEVICE float2 fminf(const float2& a, const float2& b)
0275 {
0276   return ::make_float2(::fminf(a.x,b.x), ::fminf(a.y,b.y));
0277 }
0278 OTK_INLINE OTK_HOSTDEVICE float fminf(const float2& a)
0279 {
0280   return ::fminf(a.x, a.y);
0281 }
0282 /** @} */
0283 
0284 /** max
0285 * @{
0286 */
0287 using ::fmaxf;
0288 
0289 OTK_INLINE OTK_HOSTDEVICE float2 fmaxf(const float2& a, const float2& b)
0290 {
0291   return ::make_float2(::fmaxf(a.x,b.x), ::fmaxf(a.y,b.y));
0292 }
0293 OTK_INLINE OTK_HOSTDEVICE float fmaxf(const float2& a)
0294 {
0295   return ::fmaxf(a.x, a.y);
0296 }
0297 /** @} */
0298 
0299 /** lerp */
0300 OTK_INLINE OTK_HOSTDEVICE float2 lerp(const float2& a, const float2& b, const float t)
0301 {
0302   return a + t*(b-a);
0303 }
0304 
0305 /** bilerp */
0306 OTK_INLINE OTK_HOSTDEVICE float2 bilerp(const float2& x00, const float2& x10, const float2& x01, const float2& x11,
0307                                           const float u, const float v)
0308 {
0309   return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0310 }
0311 
0312 /** clamp
0313 * @{
0314 */
0315 OTK_INLINE OTK_HOSTDEVICE float2 clamp(const float2& v, const float a, const float b)
0316 {
0317   return ::make_float2(clamp(v.x, a, b), clamp(v.y, a, b));
0318 }
0319 
0320 OTK_INLINE OTK_HOSTDEVICE float2 clamp(const float2& v, const float2& a, const float2& b)
0321 {
0322   return ::make_float2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
0323 }
0324 /** @} */
0325 
0326 /** dot product */
0327 OTK_INLINE OTK_HOSTDEVICE float dot(const float2& a, const float2& b)
0328 {
0329   return a.x * b.x + a.y * b.y;
0330 }
0331 
0332 /** length */
0333 OTK_INLINE OTK_HOSTDEVICE float length(const float2& v)
0334 {
0335   return sqrtf(dot(v, v));
0336 }
0337 
0338 /** normalize */
0339 OTK_INLINE OTK_HOSTDEVICE float2 normalize(const float2& v)
0340 {
0341   float invLen = 1.0f / sqrtf(dot(v, v));
0342   return v * invLen;
0343 }
0344 
0345 /** floor
0346 * @{
0347 */
0348 using ::floor;
0349 
0350 OTK_INLINE OTK_HOSTDEVICE float2 floor(const float2& v)
0351 {
0352   return ::make_float2(::floorf(v.x), ::floorf(v.y));
0353 }
0354 
0355 /** @} */
0356 
0357 /** reflect */
0358 OTK_INLINE OTK_HOSTDEVICE float2 reflect(const float2& i, const float2& n)
0359 {
0360   return i - 2.0f * n * dot(n,i);
0361 }
0362 
0363 /** Faceforward
0364 * Returns N if dot(i, nref) > 0; else -N;
0365 * Typical usage is N = faceforward(N, -ray.dir, N);
0366 * Note that this is opposite of what faceforward does in Cg and GLSL */
0367 OTK_INLINE OTK_HOSTDEVICE float2 faceforward(const float2& n, const float2& i, const float2& nref)
0368 {
0369   return n * copysignf( 1.0f, dot(i, nref) );
0370 }
0371 
0372 /** exp
0373 * @{
0374 */
0375 using ::expf;
0376 
0377 OTK_INLINE OTK_HOSTDEVICE float2 expf(const float2& v)
0378 {
0379   return ::make_float2(::expf(v.x), ::expf(v.y));
0380 }
0381 /** @} */
0382 
0383 /** If used on the device, this could place the the 'v' in local memory */
0384 OTK_INLINE OTK_HOSTDEVICE float getByIndex(const float2& v, int i)
0385 {
0386   return ((float*)(&v))[i];
0387 }
0388 
0389 /** If used on the device, this could place the the 'v' in local memory */
0390 OTK_INLINE OTK_HOSTDEVICE void setByIndex(float2& v, int i, float x)
0391 {
0392   ((float*)(&v))[i] = x;
0393 }
0394 
0395 } // namespace otk
0396 
0397 /* float3 operators */
0398 /******************************************************************************/
0399 
0400 /** negate */
0401 OTK_INLINE OTK_HOSTDEVICE float3 operator-( const float3& a )
0402 {
0403   return ::make_float3( -a.x, -a.y, -a.z );
0404 }
0405 
0406 /** add
0407 * @{
0408 */
0409 OTK_INLINE OTK_HOSTDEVICE float3 operator+( const float3& a, const float3& b )
0410 {
0411   return ::make_float3( a.x + b.x, a.y + b.y, a.z + b.z );
0412 }
0413 OTK_INLINE OTK_HOSTDEVICE float3 operator+( const float3& a, const float b )
0414 {
0415   return ::make_float3( a.x + b, a.y + b, a.z + b );
0416 }
0417 OTK_INLINE OTK_HOSTDEVICE float3 operator+( const float a, const float3& b )
0418 {
0419   return ::make_float3( a + b.x, a + b.y, a + b.z );
0420 }
0421 OTK_INLINE OTK_HOSTDEVICE float3& operator+=( float3& a, const float3& b )
0422 {
0423   a = a + b;
0424   return a;
0425 }
0426 OTK_INLINE OTK_HOSTDEVICE float3& operator+=( float3& a, const float b )
0427 {
0428   a = a + b;
0429   return a;
0430 }
0431 /** @} */
0432 
0433 /** subtract
0434 * @{
0435 */
0436 OTK_INLINE OTK_HOSTDEVICE float3 operator-( const float3& a, const float3& b )
0437 {
0438   return ::make_float3( a.x - b.x, a.y - b.y, a.z - b.z );
0439 }
0440 OTK_INLINE OTK_HOSTDEVICE float3 operator-( const float3& a, const float b )
0441 {
0442   return ::make_float3( a.x - b, a.y - b, a.z - b );
0443 }
0444 OTK_INLINE OTK_HOSTDEVICE float3 operator-( const float a, const float3& b )
0445 {
0446   return ::make_float3( a - b.x, a - b.y, a - b.z );
0447 }
0448 OTK_INLINE OTK_HOSTDEVICE float3& operator-=( float3& a, const float3& b )
0449 {
0450   a = a - b;
0451   return a;
0452 }
0453 OTK_INLINE OTK_HOSTDEVICE float3& operator-=( float3& a, const float b )
0454 {
0455   a = a - b;
0456   return a;
0457 }
0458 /** @} */
0459 
0460 /** multiply
0461 * @{
0462 */
0463 OTK_INLINE OTK_HOSTDEVICE float3 operator*(const float3& a, const float3& b)
0464 {
0465   return ::make_float3(a.x * b.x, a.y * b.y, a.z * b.z);
0466 }
0467 OTK_INLINE OTK_HOSTDEVICE float3 operator*(const float3& a, const float s)
0468 {
0469   return ::make_float3(a.x * s, a.y * s, a.z * s);
0470 }
0471 OTK_INLINE OTK_HOSTDEVICE float3 operator*(const float s, const float3& a)
0472 {
0473   return ::make_float3(a.x * s, a.y * s, a.z * s);
0474 }
0475 OTK_INLINE OTK_HOSTDEVICE float3& operator*=(float3& a, const float3& s)
0476 {
0477   a = a * s;
0478   return a;
0479 }
0480 OTK_INLINE OTK_HOSTDEVICE float3& operator*=(float3& a, const float s)
0481 {
0482   a = a * s;
0483   return a;
0484 }
0485 /** @} */
0486 
0487 /** divide
0488 * @{
0489 */
0490 OTK_INLINE OTK_HOSTDEVICE float3 operator/(const float3& a, const float3& b)
0491 {
0492   return ::make_float3(a.x / b.x, a.y / b.y, a.z / b.z);
0493 }
0494 OTK_INLINE OTK_HOSTDEVICE float3 operator/(const float3& a, const float s)
0495 {
0496   return ::make_float3(a.x / s, a.y / s, a.z / s);
0497 }
0498 OTK_INLINE OTK_HOSTDEVICE float3 operator/(const float s, const float3& a)
0499 {
0500   return ::make_float3(s /a.x, s / a.y, s / a.z);
0501 }
0502 OTK_INLINE OTK_HOSTDEVICE float3& operator/=(float3& a, const float3& s)
0503 {
0504   a = a / s;
0505   return a;
0506 }
0507 OTK_INLINE OTK_HOSTDEVICE float3& operator/=(float3& a, const float s)
0508 {
0509   a = a / s;
0510   return a;
0511 }
0512 /** @} */
0513 
0514 /** equality
0515 * @{
0516 */
0517 OTK_INLINE OTK_HOSTDEVICE bool operator==( const float3& a, const float3& b )
0518 {
0519   return a.x == b.x && a.y == b.y && a.z == b.z;
0520 }
0521 
0522 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const float3& a, const float3& b )
0523 {
0524   return !( a == b );
0525 }
0526 /** @} */
0527 
0528 namespace otk {
0529 
0530 /* float3 functions */
0531 /******************************************************************************/
0532 
0533 /** additional constructors
0534 * @{
0535 */
0536 using ::make_float3;
0537 
0538 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const float s)
0539 {
0540   return ::make_float3(s, s, s);
0541 }
0542 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const float2& a)
0543 {
0544   return ::make_float3(a.x, a.y, 0.0f);
0545 }
0546 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const int3& a)
0547 {
0548   return ::make_float3(float(a.x), float(a.y), float(a.z));
0549 }
0550 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const uint3& a)
0551 {
0552   return ::make_float3(float(a.x), float(a.y), float(a.z));
0553 }
0554 /** @} */
0555 
0556 /** min
0557 * @{
0558 */
0559 OTK_INLINE OTK_HOSTDEVICE float3 fminf(const float3& a, const float3& b)
0560 {
0561   return ::make_float3(::fminf(a.x,b.x), ::fminf(a.y,b.y), ::fminf(a.z,b.z));
0562 }
0563 OTK_INLINE OTK_HOSTDEVICE float fminf(const float3& a)
0564 {
0565   return ::fminf(::fminf(a.x, a.y), a.z);
0566 }
0567 /** @} */
0568 
0569 /** max
0570 * @{
0571 */
0572 OTK_INLINE OTK_HOSTDEVICE float3 fmaxf(const float3& a, const float3& b)
0573 {
0574   return ::make_float3(::fmaxf(a.x,b.x), ::fmaxf(a.y,b.y), ::fmaxf(a.z,b.z));
0575 }
0576 OTK_INLINE OTK_HOSTDEVICE float fmaxf(const float3& a)
0577 {
0578   return ::fmaxf(::fmaxf(a.x, a.y), a.z);
0579 }
0580 /** @} */
0581 
0582 /** lerp */
0583 OTK_INLINE OTK_HOSTDEVICE float3 lerp(const float3& a, const float3& b, const float t)
0584 {
0585   return a + t*(b-a);
0586 }
0587 
0588 /** bilerp */
0589 OTK_INLINE OTK_HOSTDEVICE float3 bilerp(const float3& x00, const float3& x10, const float3& x01, const float3& x11,
0590                                           const float u, const float v)
0591 {
0592   return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0593 }
0594 
0595 /** clamp
0596 * @{
0597 */
0598 OTK_INLINE OTK_HOSTDEVICE float3 clamp(const float3& v, const float a, const float b)
0599 {
0600   return ::make_float3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
0601 }
0602 
0603 OTK_INLINE OTK_HOSTDEVICE float3 clamp(const float3& v, const float3& a, const float3& b)
0604 {
0605   return ::make_float3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
0606 }
0607 /** @} */
0608 
0609 /** dot product */
0610 OTK_INLINE OTK_HOSTDEVICE float dot(const float3& a, const float3& b)
0611 {
0612   return a.x * b.x + a.y * b.y + a.z * b.z;
0613 }
0614 
0615 /** cross product */
0616 OTK_INLINE OTK_HOSTDEVICE float3 cross(const float3& a, const float3& b)
0617 {
0618   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);
0619 }
0620 
0621 /** length */
0622 OTK_INLINE OTK_HOSTDEVICE float length(const float3& v)
0623 {
0624   return sqrtf(dot(v, v));
0625 }
0626 
0627 /** normalize */
0628 OTK_INLINE OTK_HOSTDEVICE float3 normalize(const float3& v)
0629 {
0630   float invLen = 1.0f / sqrtf(dot(v, v));
0631   return v * invLen;
0632 }
0633 
0634 /** floor */
0635 OTK_INLINE OTK_HOSTDEVICE float3 floor(const float3& v)
0636 {
0637   return ::make_float3(::floorf(v.x), ::floorf(v.y), ::floorf(v.z));
0638 }
0639 
0640 /** reflect */
0641 OTK_INLINE OTK_HOSTDEVICE float3 reflect(const float3& i, const float3& n)
0642 {
0643   return i - 2.0f * n * dot(n,i);
0644 }
0645 
0646 /** Faceforward
0647 * Returns N if dot(i, nref) > 0; else -N;
0648 * Typical usage is N = faceforward(N, -ray.dir, N);
0649 * Note that this is opposite of what faceforward does in Cg and GLSL */
0650 OTK_INLINE OTK_HOSTDEVICE float3 faceforward(const float3& n, const float3& i, const float3& nref)
0651 {
0652   return n * copysignf( 1.0f, dot(i, nref) );
0653 }
0654 
0655 /** exp */
0656 OTK_INLINE OTK_HOSTDEVICE float3 expf(const float3& v)
0657 {
0658   return ::make_float3(::expf(v.x), ::expf(v.y), ::expf(v.z));
0659 }
0660 
0661 /** If used on the device, this could place the the 'v' in local memory */
0662 OTK_INLINE OTK_HOSTDEVICE float getByIndex(const float3& v, int i)
0663 {
0664   return ((float*)(&v))[i];
0665 }
0666 
0667 /** If used on the device, this could place the the 'v' in local memory */
0668 OTK_INLINE OTK_HOSTDEVICE void setByIndex(float3& v, int i, float x)
0669 {
0670   ((float*)(&v))[i] = x;
0671 }
0672 
0673 }  // namespace otk
0674 
0675 /* float4 operators */
0676 /******************************************************************************/
0677 
0678 /** negate */
0679 OTK_INLINE OTK_HOSTDEVICE float4 operator-(const float4& a)
0680 {
0681   return ::make_float4(-a.x, -a.y, -a.z, -a.w);
0682 }
0683 
0684 /** add
0685 * @{
0686 */
0687 OTK_INLINE OTK_HOSTDEVICE float4 operator+(const float4& a, const float4& b)
0688 {
0689   return ::make_float4(a.x + b.x, a.y + b.y, a.z + b.z,  a.w + b.w);
0690 }
0691 OTK_INLINE OTK_HOSTDEVICE float4 operator+(const float4& a, const float b)
0692 {
0693   return ::make_float4(a.x + b, a.y + b, a.z + b,  a.w + b);
0694 }
0695 OTK_INLINE OTK_HOSTDEVICE float4 operator+(const float a, const float4& b)
0696 {
0697   return ::make_float4(a + b.x, a + b.y, a + b.z,  a + b.w);
0698 }
0699 OTK_INLINE OTK_HOSTDEVICE float4& operator+=(float4& a, const float4& b)
0700 {
0701   a = a + b;
0702   return a;
0703 }
0704 OTK_INLINE OTK_HOSTDEVICE float4& operator+=(float4& a, const float b)
0705 {
0706   a = a + b;
0707   return a;
0708 }
0709 /** @} */
0710 
0711 /** subtract
0712 * @{
0713 */
0714 OTK_INLINE OTK_HOSTDEVICE float4 operator-(const float4& a, const float4& b)
0715 {
0716   return ::make_float4(a.x - b.x, a.y - b.y, a.z - b.z,  a.w - b.w);
0717 }
0718 OTK_INLINE OTK_HOSTDEVICE float4 operator-(const float4& a, const float b)
0719 {
0720   return ::make_float4(a.x - b, a.y - b, a.z - b,  a.w - b);
0721 }
0722 OTK_INLINE OTK_HOSTDEVICE float4 operator-(const float a, const float4& b)
0723 {
0724   return ::make_float4(a - b.x, a - b.y, a - b.z,  a - b.w);
0725 }
0726 OTK_INLINE OTK_HOSTDEVICE float4& operator-=(float4& a, const float4& b)
0727 {
0728   a = a - b;
0729   return a;
0730 }
0731 OTK_INLINE OTK_HOSTDEVICE float4& operator-=(float4& a, const float b)
0732 {
0733   a = a - b;
0734   return a;
0735 }
0736 /** @} */
0737 
0738 /** multiply
0739 * @{
0740 */
0741 OTK_INLINE OTK_HOSTDEVICE float4 operator*(const float4& a, const float4& s)
0742 {
0743   return ::make_float4(a.x * s.x, a.y * s.y, a.z * s.z, a.w * s.w);
0744 }
0745 OTK_INLINE OTK_HOSTDEVICE float4 operator*(const float4& a, const float s)
0746 {
0747   return ::make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
0748 }
0749 OTK_INLINE OTK_HOSTDEVICE float4 operator*(const float s, const float4& a)
0750 {
0751   return ::make_float4(a.x * s, a.y * s, a.z * s, a.w * s);
0752 }
0753 OTK_INLINE OTK_HOSTDEVICE float4& operator*=(float4& a, const float4& s)
0754 {
0755   a = a * s;
0756   return a;
0757 }
0758 OTK_INLINE OTK_HOSTDEVICE float4& operator*=(float4& a, const float s)
0759 {
0760   a = a * s;
0761   return a;
0762 }
0763 /** @} */
0764 
0765 /** divide
0766 * @{
0767 */
0768 OTK_INLINE OTK_HOSTDEVICE float4 operator/(const float4& a, const float4& b)
0769 {
0770   return ::make_float4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
0771 }
0772 OTK_INLINE OTK_HOSTDEVICE float4 operator/(const float4& a, const float s)
0773 {
0774   float inv = 1.0f / s;
0775   return a * inv;
0776 }
0777 OTK_INLINE OTK_HOSTDEVICE float4 operator/(const float s, const float4& a)
0778 {
0779   return ::make_float4( s/a.x, s/a.y, s/a.z, s/a.w );
0780 }
0781 OTK_INLINE OTK_HOSTDEVICE float4& operator/=(float4& a, const float4& s)
0782 {
0783   a = a / s;
0784   return a;
0785 }
0786 OTK_INLINE OTK_HOSTDEVICE float4& operator/=(float4& a, const float s)
0787 {
0788   a = a / s;
0789   return a;
0790 }
0791 /** @} */
0792 
0793 /** equality
0794 * @{
0795 */
0796 OTK_INLINE OTK_HOSTDEVICE bool operator==( const float4& a, const float4& b )
0797 {
0798   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
0799 }
0800 
0801 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const float4& a, const float4& b )
0802 {
0803   return !( a == b );
0804 }
0805 /** @} */
0806 
0807 namespace otk {
0808 
0809 /* float4 functions */
0810 /******************************************************************************/
0811 
0812 /** additional constructors
0813 * @{
0814 */
0815 using ::make_float4;
0816 
0817 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float s)
0818 {
0819   return ::make_float4(s, s, s, s);
0820 }
0821 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float3& a)
0822 {
0823   return ::make_float4(a.x, a.y, a.z, 0.0f);
0824 }
0825 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const int4& a)
0826 {
0827   return ::make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
0828 }
0829 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const uint4& a)
0830 {
0831   return ::make_float4(float(a.x), float(a.y), float(a.z), float(a.w));
0832 }
0833 /** @} */
0834 
0835 /** min
0836 * @{
0837 */
0838 OTK_INLINE OTK_HOSTDEVICE float4 fminf(const float4& a, const float4& b)
0839 {
0840   return ::make_float4(::fminf(a.x,b.x), ::fminf(a.y,b.y), ::fminf(a.z,b.z), ::fminf(a.w,b.w));
0841 }
0842 OTK_INLINE OTK_HOSTDEVICE float fminf(const float4& a)
0843 {
0844   return ::fminf(::fminf(a.x, a.y), ::fminf(a.z, a.w));
0845 }
0846 /** @} */
0847 
0848 /** max
0849 * @{
0850 */
0851 OTK_INLINE OTK_HOSTDEVICE float4 fmaxf(const float4& a, const float4& b)
0852 {
0853   return ::make_float4(::fmaxf(a.x,b.x), ::fmaxf(a.y,b.y), ::fmaxf(a.z,b.z), ::fmaxf(a.w,b.w));
0854 }
0855 OTK_INLINE OTK_HOSTDEVICE float fmaxf(const float4& a)
0856 {
0857   return ::fmaxf(::fmaxf(a.x, a.y), ::fmaxf(a.z, a.w));
0858 }
0859 /** @} */
0860 
0861 /** lerp */
0862 OTK_INLINE OTK_HOSTDEVICE float4 lerp(const float4& a, const float4& b, const float t)
0863 {
0864   return a + t*(b-a);
0865 }
0866 
0867 /** bilerp */
0868 OTK_INLINE OTK_HOSTDEVICE float4 bilerp(const float4& x00, const float4& x10, const float4& x01, const float4& x11,
0869                                           const float u, const float v)
0870 {
0871   return lerp( lerp( x00, x10, u ), lerp( x01, x11, u ), v );
0872 }
0873 
0874 /** clamp
0875 * @{
0876 */
0877 OTK_INLINE OTK_HOSTDEVICE float4 clamp(const float4& v, const float a, const float b)
0878 {
0879   return ::make_float4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
0880 }
0881 
0882 OTK_INLINE OTK_HOSTDEVICE float4 clamp(const float4& v, const float4& a, const float4& b)
0883 {
0884   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));
0885 }
0886 /** @} */
0887 
0888 /** dot product */
0889 OTK_INLINE OTK_HOSTDEVICE float dot(const float4& a, const float4& b)
0890 {
0891   return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
0892 }
0893 
0894 /** length */
0895 OTK_INLINE OTK_HOSTDEVICE float length(const float4& r)
0896 {
0897   return sqrtf(dot(r, r));
0898 }
0899 
0900 /** normalize */
0901 OTK_INLINE OTK_HOSTDEVICE float4 normalize(const float4& v)
0902 {
0903   float invLen = 1.0f / sqrtf(dot(v, v));
0904   return v * invLen;
0905 }
0906 
0907 /** floor */
0908 OTK_INLINE OTK_HOSTDEVICE float4 floor(const float4& v)
0909 {
0910   return ::make_float4(::floorf(v.x), ::floorf(v.y), ::floorf(v.z), ::floorf(v.w));
0911 }
0912 
0913 /** reflect */
0914 OTK_INLINE OTK_HOSTDEVICE float4 reflect(const float4& i, const float4& n)
0915 {
0916   return i - 2.0f * n * dot(n,i);
0917 }
0918 
0919 /**
0920 * Faceforward
0921 * Returns N if dot(i, nref) > 0; else -N;
0922 * Typical usage is N = faceforward(N, -ray.dir, N);
0923 * Note that this is opposite of what faceforward does in Cg and GLSL
0924 */
0925 OTK_INLINE OTK_HOSTDEVICE float4 faceforward(const float4& n, const float4& i, const float4& nref)
0926 {
0927   return n * copysignf( 1.0f, dot(i, nref) );
0928 }
0929 
0930 /** exp */
0931 OTK_INLINE OTK_HOSTDEVICE float4 expf(const float4& v)
0932 {
0933   return ::make_float4(::expf(v.x), ::expf(v.y), ::expf(v.z), ::expf(v.w));
0934 }
0935 
0936 /** If used on the device, this could place the the 'v' in local memory */
0937 OTK_INLINE OTK_HOSTDEVICE float getByIndex(const float4& v, int i)
0938 {
0939   return ((float*)(&v))[i];
0940 }
0941 
0942 /** If used on the device, this could place the the 'v' in local memory */
0943 OTK_INLINE OTK_HOSTDEVICE void setByIndex(float4& v, int i, float x)
0944 {
0945   ((float*)(&v))[i] = x;
0946 }
0947 
0948 } // namespace otk
0949 
0950 /* double2 operators */
0951 /******************************************************************************/
0952 
0953 /** negate */
0954 OTK_INLINE OTK_HOSTDEVICE double2 operator-(const double2& a)
0955 {
0956   return ::make_double2(-a.x, -a.y);
0957 }
0958 
0959 /** add
0960 * @{
0961 */
0962 OTK_INLINE OTK_HOSTDEVICE double2 operator+(const double2& a, const double2& b)
0963 {
0964   return ::make_double2(a.x + b.x, a.y + b.y);
0965 }
0966 OTK_INLINE OTK_HOSTDEVICE double2 operator+(const double2& a, const double b)
0967 {
0968   return ::make_double2(a.x + b, a.y + b);
0969 }
0970 OTK_INLINE OTK_HOSTDEVICE double2 operator+(const double a, const double2& b)
0971 {
0972   return ::make_double2(a + b.x, a + b.y);
0973 }
0974 OTK_INLINE OTK_HOSTDEVICE double2& operator+=(double2& a, const double2& b)
0975 {
0976   a = a + b;
0977   return a;
0978 }
0979 OTK_INLINE OTK_HOSTDEVICE double2& operator+=(double2& a, const double b)
0980 {
0981   a = a + b;
0982   return a;
0983 }
0984 /** @} */
0985 
0986 /** subtract
0987 * @{
0988 */
0989 OTK_INLINE OTK_HOSTDEVICE double2 operator-(const double2& a, const double2& b)
0990 {
0991   return ::make_double2(a.x - b.x, a.y - b.y);
0992 }
0993 OTK_INLINE OTK_HOSTDEVICE double2 operator-(const double2& a, const double b)
0994 {
0995   return ::make_double2(a.x - b, a.y - b);
0996 }
0997 OTK_INLINE OTK_HOSTDEVICE double2 operator-(const double a, const double2& b)
0998 {
0999   return ::make_double2(a - b.x, a - b.y);
1000 }
1001 OTK_INLINE OTK_HOSTDEVICE double2& operator-=(double2& a, const double2& b)
1002 {
1003   a = a - b;
1004   return a;
1005 }
1006 OTK_INLINE OTK_HOSTDEVICE double2& operator-=(double2& a, const double b)
1007 {
1008   a = a - b;
1009   return a;
1010 }
1011 /** @} */
1012 
1013 /** multiply
1014 * @{
1015 */
1016 OTK_INLINE OTK_HOSTDEVICE double2 operator*(const double2& a, const double2& b)
1017 {
1018   return ::make_double2(a.x * b.x, a.y * b.y);
1019 }
1020 OTK_INLINE OTK_HOSTDEVICE double2 operator*(const double2& a, const double s)
1021 {
1022   return ::make_double2(a.x * s, a.y * s);
1023 }
1024 OTK_INLINE OTK_HOSTDEVICE double2 operator*(const double s, const double2& a)
1025 {
1026   return ::make_double2(a.x * s, a.y * s);
1027 }
1028 OTK_INLINE OTK_HOSTDEVICE double2& operator*=(double2& a, const double2& s)
1029 {
1030   a = a * s;
1031   return a;
1032 }
1033 OTK_INLINE OTK_HOSTDEVICE double2& operator*=(double2& a, const double s)
1034 {
1035   a = a * s;
1036   return a;
1037 }
1038 /** @} */
1039 
1040 /** divide
1041 * @{
1042 */
1043 OTK_INLINE OTK_HOSTDEVICE double2 operator/(const double2& a, const double2& b)
1044 {
1045   return ::make_double2(a.x / b.x, a.y / b.y);
1046 }
1047 OTK_INLINE OTK_HOSTDEVICE double2 operator/(const double2& a, const double s)
1048 {
1049   double inv = 1.0 / s;
1050   return a * inv;
1051 }
1052 OTK_INLINE OTK_HOSTDEVICE double2 operator/(const double s, const double2& a)
1053 {
1054   return ::make_double2( s/a.x, s/a.y );
1055 }
1056 OTK_INLINE OTK_HOSTDEVICE double2& operator/=(double2& a, const double2& s)
1057 {
1058   a = a / s;
1059   return a;
1060 }
1061 OTK_INLINE OTK_HOSTDEVICE double2& operator/=(double2& a, const double s)
1062 {
1063   a = a / s;
1064   return a;
1065 }
1066 /** @} */
1067 
1068 /** equality
1069 * @{
1070 */
1071 OTK_INLINE OTK_HOSTDEVICE bool operator==( const double2& a, const double2& b )
1072 {
1073   return a.x == b.x && a.y == b.y;
1074 }
1075 
1076 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const double2& a, const double2& b )
1077 {
1078   return !( a == b );
1079 }
1080 /** @} */
1081 
1082 namespace otk {
1083 
1084 /* double2 functions */
1085 /******************************************************************************/
1086 
1087 } // namespace otk
1088 
1089 /* double3 operators */
1090 /******************************************************************************/
1091 
1092 /** negate */
1093 OTK_INLINE OTK_HOSTDEVICE double3 operator-( const double3& a )
1094 {
1095   return ::make_double3( -a.x, -a.y, -a.z );
1096 }
1097 
1098 /** add
1099 * @{
1100 */
1101 OTK_INLINE OTK_HOSTDEVICE double3 operator+( const double3& a, const double3& b )
1102 {
1103   return ::make_double3( a.x + b.x, a.y + b.y, a.z + b.z );
1104 }
1105 OTK_INLINE OTK_HOSTDEVICE double3 operator+( const double3& a, const double b )
1106 {
1107   return ::make_double3( a.x + b, a.y + b, a.z + b );
1108 }
1109 OTK_INLINE OTK_HOSTDEVICE double3 operator+( const double a, const double3& b )
1110 {
1111   return ::make_double3( a + b.x, a + b.y, a + b.z );
1112 }
1113 OTK_INLINE OTK_HOSTDEVICE double3& operator+=( double3& a, const double3& b )
1114 {
1115   a = a + b;
1116   return a;
1117 }
1118 OTK_INLINE OTK_HOSTDEVICE double3& operator+=( double3& a, const double b )
1119 {
1120   a = a + b;
1121   return a;
1122 }
1123 /** @} */
1124 
1125 /** subtract
1126 * @{
1127 */
1128 OTK_INLINE OTK_HOSTDEVICE double3 operator-( const double3& a, const double3& b )
1129 {
1130   return ::make_double3( a.x - b.x, a.y - b.y, a.z - b.z );
1131 }
1132 OTK_INLINE OTK_HOSTDEVICE double3 operator-( const double3& a, const double b )
1133 {
1134   return ::make_double3( a.x - b, a.y - b, a.z - b );
1135 }
1136 OTK_INLINE OTK_HOSTDEVICE double3 operator-( const double a, const double3& b )
1137 {
1138   return ::make_double3( a - b.x, a - b.y, a - b.z );
1139 }
1140 OTK_INLINE OTK_HOSTDEVICE double3& operator-=( double3& a, const double3& b )
1141 {
1142   a = a - b;
1143   return a;
1144 }
1145 OTK_INLINE OTK_HOSTDEVICE double3& operator-=( double3& a, const double b )
1146 {
1147   a = a - b;
1148   return a;
1149 }
1150 /** @} */
1151 
1152 /** multiply
1153 * @{
1154 */
1155 OTK_INLINE OTK_HOSTDEVICE double3 operator*(const double3& a, const double3& b)
1156 {
1157   return ::make_double3(a.x * b.x, a.y * b.y, a.z * b.z);
1158 }
1159 OTK_INLINE OTK_HOSTDEVICE double3 operator*(const double3& a, const double s)
1160 {
1161   return ::make_double3(a.x * s, a.y * s, a.z * s);
1162 }
1163 OTK_INLINE OTK_HOSTDEVICE double3 operator*(const double s, const double3& a)
1164 {
1165   return ::make_double3(a.x * s, a.y * s, a.z * s);
1166 }
1167 OTK_INLINE OTK_HOSTDEVICE double3& operator*=(double3& a, const double3& s)
1168 {
1169   a = a * s;
1170   return a;
1171 }
1172 OTK_INLINE OTK_HOSTDEVICE double3& operator*=(double3& a, const double s)
1173 {
1174   a = a * s;
1175   return a;
1176 }
1177 /** @} */
1178 
1179 /** divide
1180 * @{
1181 */
1182 OTK_INLINE OTK_HOSTDEVICE double3 operator/(const double3& a, const double3& b)
1183 {
1184   return ::make_double3(a.x / b.x, a.y / b.y, a.z / b.z);
1185 }
1186 OTK_INLINE OTK_HOSTDEVICE double3 operator/(const double3& a, const double s)
1187 {
1188   return ::make_double3(a.x / s, a.y / s, a.z / s);
1189 }
1190 OTK_INLINE OTK_HOSTDEVICE double3 operator/(const double s, const double3& a)
1191 {
1192   return ::make_double3(s /a.x, s / a.y, s / a.z);
1193 }
1194 OTK_INLINE OTK_HOSTDEVICE double3& operator/=(double3& a, const double3& s)
1195 {
1196   a = a / s;
1197   return a;
1198 }
1199 OTK_INLINE OTK_HOSTDEVICE double3& operator/=(double3& a, const double s)
1200 {
1201   a = a / s;
1202   return a;
1203 }
1204 /** @} */
1205 
1206 /** equality
1207 * @{
1208 */
1209 OTK_INLINE OTK_HOSTDEVICE bool operator==( const double3& a, const double3& b )
1210 {
1211   return a.x == b.x && a.y == b.y && a.z == b.z;
1212 }
1213 
1214 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const double3& a, const double3& b )
1215 {
1216   return !( a == b );
1217 }
1218 /** @} */
1219 
1220 namespace otk {
1221 
1222 /* double3 functions */
1223 /******************************************************************************/
1224 
1225 } // namespace otk
1226 
1227 #if CUDART_VERSION >= 13000
1228 /* double4_16a operators */
1229 /******************************************************************************/
1230 
1231 /** negate */
1232 OTK_INLINE OTK_HOSTDEVICE double4_16a operator-( const double4_16a& a )
1233 {
1234   return make_double4_16a( -a.x, -a.y, -a.z, -a.w );
1235 }
1236 
1237 /** add
1238 * @{
1239 */
1240 OTK_INLINE OTK_HOSTDEVICE double4_16a operator+( const double4_16a& a, const double4_16a& b )
1241 {
1242   return make_double4_16a( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );
1243 }
1244 OTK_INLINE OTK_HOSTDEVICE double4_16a operator+( const double4_16a& a, const double b )
1245 {
1246   return make_double4_16a( a.x + b, a.y + b, a.z + b, a.w + b );
1247 }
1248 OTK_INLINE OTK_HOSTDEVICE double4_16a operator+( const double a, const double4_16a& b )
1249 {
1250   return make_double4_16a( a + b.x, a + b.y, a + b.z, a + b.w );
1251 }
1252 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator+=( double4_16a& a, const double4_16a& b )
1253 {
1254   a = a + b;
1255   return a;
1256 }
1257 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator+=( double4_16a& a, const double b )
1258 {
1259   a = a + b;
1260   return a;
1261 }
1262 /** @} */
1263 
1264 /** subtract
1265 * @{
1266 */
1267 OTK_INLINE OTK_HOSTDEVICE double4_16a operator-( const double4_16a& a, const double4_16a& b )
1268 {
1269   return make_double4_16a( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );
1270 }
1271 OTK_INLINE OTK_HOSTDEVICE double4_16a operator-( const double4_16a& a, const double b )
1272 {
1273   return make_double4_16a( a.x - b, a.y - b, a.z - b, a.w - b );
1274 }
1275 OTK_INLINE OTK_HOSTDEVICE double4_16a operator-( const double a, const double4_16a& b )
1276 {
1277   return make_double4_16a( a - b.x, a - b.y, a - b.z, a - b.w );
1278 }
1279 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator-=( double4_16a& a, const double4_16a& b )
1280 {
1281   a = a - b;
1282   return a;
1283 }
1284 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator-=( double4_16a& a, const double b )
1285 {
1286   a = a - b;
1287   return a;
1288 }
1289 /** @} */
1290 
1291 /** multiply
1292 * @{
1293 */
1294 OTK_INLINE OTK_HOSTDEVICE double4_16a operator*(const double4_16a& a, const double4_16a& b)
1295 {
1296   return make_double4_16a(a.x * b.x, a.y * b.y, a.z * b.z, 0);
1297 }
1298 OTK_INLINE OTK_HOSTDEVICE double4_16a operator*(const double4_16a& a, const double s)
1299 {
1300   return make_double4_16a(a.x * s, a.y * s, a.z * s, 0);
1301 }
1302 OTK_INLINE OTK_HOSTDEVICE double4_16a operator*(const double s, const double4_16a& a)
1303 {
1304   return make_double4_16a(a.x * s, a.y * s, a.z * s, 0);
1305 }
1306 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator*=(double4_16a& a, const double4_16a& s)
1307 {
1308   a = a * s;
1309   return a;
1310 }
1311 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator*=(double4_16a& a, const double s)
1312 {
1313   a = a * s;
1314   return a;
1315 }
1316 /** @} */
1317 
1318 /** divide
1319 * @{
1320 */
1321 OTK_INLINE OTK_HOSTDEVICE double4_16a operator/(const double4_16a& a, const double4_16a& b)
1322 {
1323   return make_double4_16a(a.x / b.x, a.y / b.y, a.z / b.z, 0);
1324 }
1325 OTK_INLINE OTK_HOSTDEVICE double4_16a operator/(const double4_16a& a, const double s)
1326 {
1327   return make_double4_16a(a.x / s, a.y / s, a.z / s, 0);
1328 }
1329 OTK_INLINE OTK_HOSTDEVICE double4_16a operator/(const double s, const double4_16a& a)
1330 {
1331   return make_double4_16a(s /a.x, s / a.y, s / a.z, 0);
1332 }
1333 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator/=(double4_16a& a, const double4_16a& s)
1334 {
1335   a = a / s;
1336   return a;
1337 }
1338 OTK_INLINE OTK_HOSTDEVICE double4_16a& operator/=(double4_16a& a, const double s)
1339 {
1340   a = a / s;
1341   return a;
1342 }
1343 /** @} */
1344 
1345 /** equality
1346 * @{
1347 */
1348 OTK_INLINE OTK_HOSTDEVICE bool operator==( const double4_16a& a, const double4_16a& b )
1349 {
1350   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
1351 }
1352 
1353 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const double4_16a& a, const double4_16a& b )
1354 {
1355   return !( a == b );
1356 }
1357 /** @} */
1358 
1359 namespace otk {
1360 
1361 /* double4_16a functions */
1362 /******************************************************************************/
1363 
1364 } // namespace otk
1365 #endif // CUDART_VERSION >= 13000
1366 
1367 namespace otk {
1368 
1369 /* int functions */
1370 /******************************************************************************/
1371 
1372 /** clamp */
1373 OTK_INLINE OTK_HOSTDEVICE int clamp(const int f, const int a, const int b)
1374 {
1375   return max(a, min(f, b));
1376 }
1377 
1378 /** If used on the device, this could place the the 'v' in local memory */
1379 OTK_INLINE OTK_HOSTDEVICE int getByIndex(const int1& v, int i)
1380 {
1381   return ((int*)(&v))[i];
1382 }
1383 
1384 /** If used on the device, this could place the the 'v' in local memory */
1385 OTK_INLINE OTK_HOSTDEVICE void setByIndex(int1& v, int i, int x)
1386 {
1387   ((int*)(&v))[i] = x;
1388 }
1389 
1390 } // namespace otk
1391 
1392 /* short2 operators */
1393 /******************************************************************************/
1394 
1395 /** negate */
1396 OTK_INLINE OTK_HOSTDEVICE short2 operator-(const short2& a)
1397 {
1398   return ::make_short2(-a.x, -a.y);
1399 }
1400 
1401 /** add
1402 * @{
1403 */
1404 OTK_INLINE OTK_HOSTDEVICE short2 operator+(const short2& a, const short2& b)
1405 {
1406   return ::make_short2(a.x + b.x, a.y + b.y);
1407 }
1408 OTK_INLINE OTK_HOSTDEVICE short2 operator+(const short2& a, const short b)
1409 {
1410   return ::make_short2(a.x + b, a.y + b);
1411 }
1412 OTK_INLINE OTK_HOSTDEVICE short2 operator+(const short a, const short2& b)
1413 {
1414   return ::make_short2(a + b.x, a + b.y);
1415 }
1416 OTK_INLINE OTK_HOSTDEVICE short2& operator+=(short2& a, const short2& b)
1417 {
1418   a = a + b;
1419   return a;
1420 }
1421 OTK_INLINE OTK_HOSTDEVICE short2& operator+=(short2& a, const short b)
1422 {
1423   a = a + b;
1424   return a;
1425 }
1426 /** @} */
1427 
1428 /** subtract
1429 * @{
1430 */
1431 OTK_INLINE OTK_HOSTDEVICE short2 operator-(const short2& a, const short2& b)
1432 {
1433   return ::make_short2(a.x - b.x, a.y - b.y);
1434 }
1435 OTK_INLINE OTK_HOSTDEVICE short2 operator-(const short2& a, const short b)
1436 {
1437   return ::make_short2(a.x - b, a.y - b);
1438 }
1439 OTK_INLINE OTK_HOSTDEVICE short2 operator-(const short a, const short2& b)
1440 {
1441   return ::make_short2(a - b.x, a - b.y);
1442 }
1443 OTK_INLINE OTK_HOSTDEVICE short2& operator-=(short2& a, const short2& b)
1444 {
1445   a = a - b;
1446   return a;
1447 }
1448 OTK_INLINE OTK_HOSTDEVICE short2& operator-=(short2& a, const short b)
1449 {
1450   a = a - b;
1451   return a;
1452 }
1453 /** @} */
1454 
1455 /** multiply
1456 * @{
1457 */
1458 OTK_INLINE OTK_HOSTDEVICE short2 operator*(const short2& a, const short2& b)
1459 {
1460   return ::make_short2(a.x * b.x, a.y * b.y);
1461 }
1462 OTK_INLINE OTK_HOSTDEVICE short2 operator*(const short2& a, const short s)
1463 {
1464   return ::make_short2(a.x * s, a.y * s);
1465 }
1466 OTK_INLINE OTK_HOSTDEVICE short2 operator*(const short s, const short2& a)
1467 {
1468   return ::make_short2(a.x * s, a.y * s);
1469 }
1470 OTK_INLINE OTK_HOSTDEVICE short2& operator*=(short2& a, const short2& s)
1471 {
1472   a = a * s;
1473   return a;
1474 }
1475 OTK_INLINE OTK_HOSTDEVICE short2& operator*=(short2& a, const short s)
1476 {
1477   a = a * s;
1478   return a;
1479 }
1480 /** @} */
1481 
1482 /** divide
1483 * @{
1484 */
1485 OTK_INLINE OTK_HOSTDEVICE short2 operator/(const short2& a, const short2& b)
1486 {
1487   return ::make_short2(a.x / b.x, a.y / b.y);
1488 }
1489 OTK_INLINE OTK_HOSTDEVICE short2 operator/(const short2& a, const short s)
1490 {
1491   return ::make_short2(a.x / s, a.y / s);
1492 }
1493 OTK_INLINE OTK_HOSTDEVICE short2 operator/(const short s, const short2& a)
1494 {
1495   return ::make_short2( s/a.x, s/a.y );
1496 }
1497 OTK_INLINE OTK_HOSTDEVICE short2& operator/=(short2& a, const short2& s)
1498 {
1499   a = a / s;
1500   return a;
1501 }
1502 OTK_INLINE OTK_HOSTDEVICE short2& operator/=(short2& a, const short s)
1503 {
1504   a = a / s;
1505   return a;
1506 }
1507 /** @} */
1508 
1509 /** equality
1510 * @{
1511 */
1512 OTK_INLINE OTK_HOSTDEVICE bool operator==(const short2& a, const short2& b)
1513 {
1514   return a.x == b.x && a.y == b.y;
1515 }
1516 
1517 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const short2& a, const short2& b)
1518 {
1519   return a.x != b.x || a.y != b.y;
1520 }
1521 /** @} */
1522 
1523 /* short3 operators */
1524 /******************************************************************************/
1525 
1526 /** negate */
1527 OTK_INLINE OTK_HOSTDEVICE short3 operator-( const short3& a )
1528 {
1529   return ::make_short3( -a.x, -a.y, -a.z );
1530 }
1531 
1532 /** add
1533 * @{
1534 */
1535 OTK_INLINE OTK_HOSTDEVICE short3 operator+( const short3& a, const short3& b )
1536 {
1537   return ::make_short3( a.x + b.x, a.y + b.y, a.z + b.z );
1538 }
1539 OTK_INLINE OTK_HOSTDEVICE short3 operator+( const short3& a, const short b )
1540 {
1541   return ::make_short3( a.x + b, a.y + b, a.z + b );
1542 }
1543 OTK_INLINE OTK_HOSTDEVICE short3 operator+( const short a, const short3& b )
1544 {
1545   return ::make_short3( a + b.x, a + b.y, a + b.z );
1546 }
1547 OTK_INLINE OTK_HOSTDEVICE short3& operator+=( short3& a, const short3& b )
1548 {
1549   a = a + b;
1550   return a;
1551 }
1552 OTK_INLINE OTK_HOSTDEVICE short3& operator+=( short3& a, const short b )
1553 {
1554   a = a + b;
1555   return a;
1556 }
1557 /** @} */
1558 
1559 /** subtract
1560 * @{
1561 */
1562 OTK_INLINE OTK_HOSTDEVICE short3 operator-( const short3& a, const short3& b )
1563 {
1564   return ::make_short3( a.x - b.x, a.y - b.y, a.z - b.z );
1565 }
1566 OTK_INLINE OTK_HOSTDEVICE short3 operator-( const short3& a, const short b )
1567 {
1568   return ::make_short3( a.x - b, a.y - b, a.z - b );
1569 }
1570 OTK_INLINE OTK_HOSTDEVICE short3 operator-( const short a, const short3& b )
1571 {
1572   return ::make_short3( a - b.x, a - b.y, a - b.z );
1573 }
1574 OTK_INLINE OTK_HOSTDEVICE short3& operator-=( short3& a, const short3& b )
1575 {
1576   a = a - b;
1577   return a;
1578 }
1579 OTK_INLINE OTK_HOSTDEVICE short3& operator-=( short3& a, const short b )
1580 {
1581   a = a - b;
1582   return a;
1583 }
1584 /** @} */
1585 
1586 /** multiply
1587 * @{
1588 */
1589 OTK_INLINE OTK_HOSTDEVICE short3 operator*(const short3& a, const short3& b)
1590 {
1591   return ::make_short3(a.x * b.x, a.y * b.y, a.z * b.z);
1592 }
1593 OTK_INLINE OTK_HOSTDEVICE short3 operator*(const short3& a, const short s)
1594 {
1595   return ::make_short3(a.x * s, a.y * s, a.z * s);
1596 }
1597 OTK_INLINE OTK_HOSTDEVICE short3 operator*(const short s, const short3& a)
1598 {
1599   return ::make_short3(a.x * s, a.y * s, a.z * s);
1600 }
1601 OTK_INLINE OTK_HOSTDEVICE short3& operator*=(short3& a, const short3& s)
1602 {
1603   a = a * s;
1604   return a;
1605 }
1606 OTK_INLINE OTK_HOSTDEVICE short3& operator*=(short3& a, const short s)
1607 {
1608   a = a * s;
1609   return a;
1610 }
1611 /** @} */
1612 
1613 /** divide
1614 * @{
1615 */
1616 OTK_INLINE OTK_HOSTDEVICE short3 operator/(const short3& a, const short3& b)
1617 {
1618   return ::make_short3(a.x / b.x, a.y / b.y, a.z / b.z);
1619 }
1620 OTK_INLINE OTK_HOSTDEVICE short3 operator/(const short3& a, const short s)
1621 {
1622   return ::make_short3(a.x / s, a.y / s, a.z / s);
1623 }
1624 OTK_INLINE OTK_HOSTDEVICE short3 operator/(const short s, const short3& a)
1625 {
1626   return ::make_short3(s /a.x, s / a.y, s / a.z);
1627 }
1628 OTK_INLINE OTK_HOSTDEVICE short3& operator/=(short3& a, const short3& s)
1629 {
1630   a = a / s;
1631   return a;
1632 }
1633 OTK_INLINE OTK_HOSTDEVICE short3& operator/=(short3& a, const short s)
1634 {
1635   a = a / s;
1636   return a;
1637 }
1638 /** @} */
1639 
1640 /** equality
1641 * @{
1642 */
1643 OTK_INLINE OTK_HOSTDEVICE bool operator==(const short3& a, const short3& b)
1644 {
1645   return a.x == b.x && a.y == b.y && a.z == b.z;
1646 }
1647 
1648 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const short3& a, const short3& b)
1649 {
1650   return a.x != b.x || a.y != b.y || a.z != b.z;
1651 }
1652 /** @} */
1653 
1654 /* short4 operators */
1655 /******************************************************************************/
1656 
1657 /** negate */
1658 OTK_INLINE OTK_HOSTDEVICE short4 operator-(const short4& a)
1659 {
1660   return ::make_short4(-a.x, -a.y, -a.z, -a.w);
1661 }
1662 
1663 /** add
1664 * @{
1665 */
1666 OTK_INLINE OTK_HOSTDEVICE short4 operator+(const short4& a, const short4& b)
1667 {
1668   return ::make_short4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
1669 }
1670 OTK_INLINE OTK_HOSTDEVICE short4 operator+(const short4& a, const short b)
1671 {
1672   return ::make_short4(a.x + b, a.y + b, a.z + b, a.w + b);
1673 }
1674 OTK_INLINE OTK_HOSTDEVICE short4 operator+(const short a, const short4& b)
1675 {
1676   return b + a;
1677 }
1678 OTK_INLINE OTK_HOSTDEVICE short4& operator+=(short4& a, const short4& b)
1679 {
1680   a = a + b;
1681   return a;
1682 }
1683 OTK_INLINE OTK_HOSTDEVICE short4& operator+=(short4& a, const short b)
1684 {
1685   a = a + b;
1686   return a;
1687 }
1688 /** @} */
1689 
1690 /** subtract
1691 * @{
1692 */
1693 OTK_INLINE OTK_HOSTDEVICE short4 operator-(const short4& a, const short4& b)
1694 {
1695   return ::make_short4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
1696 }
1697 OTK_INLINE OTK_HOSTDEVICE short4 operator-(const short a, const short4& b)
1698 {
1699   return ::make_short4(a - b.x, a - b.y, a - b.z, a - b.w);
1700 }
1701 OTK_INLINE OTK_HOSTDEVICE short4 operator-(const short4& a, const short b)
1702 {
1703   return ::make_short4(a.x - b, a.y - b, a.z - b, a.w - b);
1704 }
1705 OTK_INLINE OTK_HOSTDEVICE short4& operator-=(short4& a, const short4& b)
1706 {
1707   a = a - b;
1708   return a;
1709 }
1710 OTK_INLINE OTK_HOSTDEVICE short4& operator-=(short4& a, const short b)
1711 {
1712   a = a - b;
1713   return a;
1714 }
1715 /** @} */
1716 
1717 /** multiply
1718 * @{
1719 */
1720 OTK_INLINE OTK_HOSTDEVICE short4 operator*(const short4& a, const short4& b)
1721 {
1722   return ::make_short4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
1723 }
1724 OTK_INLINE OTK_HOSTDEVICE short4 operator*(const short4& a, const short s)
1725 {
1726   return ::make_short4(a.x * s, a.y * s, a.z * s, a.w * s);
1727 }
1728 OTK_INLINE OTK_HOSTDEVICE short4 operator*(const short s, const short4& a)
1729 {
1730   return ::make_short4(a.x * s, a.y * s, a.z * s, a.w * s);
1731 }
1732 OTK_INLINE OTK_HOSTDEVICE short4& operator*=(short4& a, const short4& s)
1733 {
1734   a = a * s;
1735   return a;
1736 }
1737 OTK_INLINE OTK_HOSTDEVICE short4& operator*=(short4& a, const short s)
1738 {
1739   a = a * s;
1740   return a;
1741 }
1742 /** @} */
1743 
1744 /** divide
1745 * @{
1746 */
1747 OTK_INLINE OTK_HOSTDEVICE short4 operator/(const short4& a, const short4& b)
1748 {
1749   return ::make_short4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
1750 }
1751 OTK_INLINE OTK_HOSTDEVICE short4 operator/(const short4& a, const short s)
1752 {
1753   return ::make_short4(a.x / s, a.y / s, a.z / s, a.w / s);
1754 }
1755 OTK_INLINE OTK_HOSTDEVICE short4 operator/(const short s, const short4& a)
1756 {
1757   return ::make_short4(s / a.x, s / a.y, s / a.z, s / a.w);
1758 }
1759 OTK_INLINE OTK_HOSTDEVICE short4& operator/=(short4& a, const short4& s)
1760 {
1761   a = a / s;
1762   return a;
1763 }
1764 OTK_INLINE OTK_HOSTDEVICE short4& operator/=(short4& a, const short s)
1765 {
1766   a = a / s;
1767   return a;
1768 }
1769 /** @} */
1770 
1771 /** equality
1772 * @{
1773 */
1774 OTK_INLINE OTK_HOSTDEVICE bool operator==(const short4& a, const short4& b)
1775 {
1776   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
1777 }
1778 
1779 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const short4& a, const short4& b)
1780 {
1781   return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
1782 }
1783 /** @} */
1784 
1785 /* ushort2 operators */
1786 /******************************************************************************/
1787 
1788 /** add
1789 * @{
1790 */
1791 OTK_INLINE OTK_HOSTDEVICE ushort2 operator+(const ushort2& a, const ushort2& b)
1792 {
1793   return ::make_ushort2(a.x + b.x, a.y + b.y);
1794 }
1795 OTK_INLINE OTK_HOSTDEVICE ushort2 operator+(const ushort2& a, const short b)
1796 {
1797   return ::make_ushort2(a.x + b, a.y + b);
1798 }
1799 OTK_INLINE OTK_HOSTDEVICE ushort2 operator+(const short a, const ushort2& b)
1800 {
1801   return ::make_ushort2(a + b.x, a + b.y);
1802 }
1803 OTK_INLINE OTK_HOSTDEVICE ushort2& operator+=(ushort2& a, const ushort2& b)
1804 {
1805   a = a + b;
1806   return a;
1807 }
1808 OTK_INLINE OTK_HOSTDEVICE ushort2& operator+=(ushort2& a, const short b)
1809 {
1810   a = a + b;
1811   return a;
1812 }
1813 /** @} */
1814 
1815 /** subtract
1816 * @{
1817 */
1818 OTK_INLINE OTK_HOSTDEVICE ushort2 operator-(const ushort2& a, const ushort2& b)
1819 {
1820   return ::make_ushort2(a.x - b.x, a.y - b.y);
1821 }
1822 OTK_INLINE OTK_HOSTDEVICE ushort2 operator-(const ushort2& a, const short b)
1823 {
1824   return ::make_ushort2(a.x - b, a.y - b);
1825 }
1826 OTK_INLINE OTK_HOSTDEVICE ushort2 operator-(const short a, const ushort2& b)
1827 {
1828   return ::make_ushort2(a - b.x, a - b.y);
1829 }
1830 OTK_INLINE OTK_HOSTDEVICE ushort2& operator-=(ushort2& a, const ushort2& b)
1831 {
1832   a = a - b;
1833   return a;
1834 }
1835 OTK_INLINE OTK_HOSTDEVICE ushort2& operator-=(ushort2& a, const short b)
1836 {
1837   a = a - b;
1838   return a;
1839 }
1840 /** @} */
1841 
1842 /** multiply
1843 * @{
1844 */
1845 OTK_INLINE OTK_HOSTDEVICE ushort2 operator*(const ushort2& a, const ushort2& b)
1846 {
1847   return ::make_ushort2(a.x * b.x, a.y * b.y);
1848 }
1849 OTK_INLINE OTK_HOSTDEVICE ushort2 operator*(const ushort2& a, const short s)
1850 {
1851   return ::make_ushort2(a.x * s, a.y * s);
1852 }
1853 OTK_INLINE OTK_HOSTDEVICE ushort2 operator*(const short s, const ushort2& a)
1854 {
1855   return ::make_ushort2(a.x * s, a.y * s);
1856 }
1857 OTK_INLINE OTK_HOSTDEVICE ushort2& operator*=(ushort2& a, const ushort2& s)
1858 {
1859   a = a * s;
1860   return a;
1861 }
1862 OTK_INLINE OTK_HOSTDEVICE ushort2& operator*=(ushort2& a, const short s)
1863 {
1864   a = a * s;
1865   return a;
1866 }
1867 /** @} */
1868 
1869 /** divide
1870 * @{
1871 */
1872 OTK_INLINE OTK_HOSTDEVICE ushort2 operator/(const ushort2& a, const ushort2& b)
1873 {
1874   return ::make_ushort2(a.x / b.x, a.y / b.y);
1875 }
1876 OTK_INLINE OTK_HOSTDEVICE ushort2 operator/(const ushort2& a, const short s)
1877 {
1878   return ::make_ushort2(a.x / s, a.y / s);
1879 }
1880 OTK_INLINE OTK_HOSTDEVICE ushort2 operator/(const short s, const ushort2& a)
1881 {
1882   return ::make_ushort2( s/a.x, s/a.y );
1883 }
1884 OTK_INLINE OTK_HOSTDEVICE ushort2& operator/=(ushort2& a, const ushort2& s)
1885 {
1886   a = a / s;
1887   return a;
1888 }
1889 OTK_INLINE OTK_HOSTDEVICE ushort2& operator/=(ushort2& a, const short s)
1890 {
1891   a = a / s;
1892   return a;
1893 }
1894 /** @} */
1895 
1896 /** equality
1897 * @{
1898 */
1899 OTK_INLINE OTK_HOSTDEVICE bool operator==(const ushort2& a, const ushort2& b)
1900 {
1901   return a.x == b.x && a.y == b.y;
1902 }
1903 
1904 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const ushort2& a, const ushort2& b)
1905 {
1906   return a.x != b.x || a.y != b.y;
1907 }
1908 /** @} */
1909 
1910 /* ushort3 operators */
1911 /******************************************************************************/
1912 
1913 /** add
1914 * @{
1915 */
1916 OTK_INLINE OTK_HOSTDEVICE ushort3 operator+( const ushort3& a, const ushort3& b )
1917 {
1918   return ::make_ushort3( a.x + b.x, a.y + b.y, a.z + b.z );
1919 }
1920 OTK_INLINE OTK_HOSTDEVICE ushort3 operator+( const ushort3& a, const unsigned short b )
1921 {
1922   return ::make_ushort3( a.x + b, a.y + b, a.z + b );
1923 }
1924 OTK_INLINE OTK_HOSTDEVICE ushort3 operator+( const unsigned short a, const ushort3& b )
1925 {
1926   return ::make_ushort3( a + b.x, a + b.y, a + b.z );
1927 }
1928 OTK_INLINE OTK_HOSTDEVICE ushort3& operator+=( ushort3& a, const ushort3& b )
1929 {
1930   a = a + b;
1931   return a;
1932 }
1933 OTK_INLINE OTK_HOSTDEVICE ushort3& operator+=( ushort3& a, const unsigned short b )
1934 {
1935   a = a + b;
1936   return a;
1937 }
1938 /** @} */
1939 
1940 /** subtract
1941 * @{
1942 */
1943 OTK_INLINE OTK_HOSTDEVICE ushort3 operator-( const ushort3& a, const ushort3& b )
1944 {
1945   return ::make_ushort3( a.x - b.x, a.y - b.y, a.z - b.z );
1946 }
1947 OTK_INLINE OTK_HOSTDEVICE ushort3 operator-( const ushort3& a, const unsigned short b )
1948 {
1949   return ::make_ushort3( a.x - b, a.y - b, a.z - b );
1950 }
1951 OTK_INLINE OTK_HOSTDEVICE ushort3 operator-( const unsigned short a, const ushort3& b )
1952 {
1953   return ::make_ushort3( a - b.x, a - b.y, a - b.z );
1954 }
1955 OTK_INLINE OTK_HOSTDEVICE ushort3& operator-=( ushort3& a, const ushort3& b )
1956 {
1957   a = a - b;
1958   return a;
1959 }
1960 OTK_INLINE OTK_HOSTDEVICE ushort3& operator-=( ushort3& a, const unsigned short b )
1961 {
1962   a = a - b;
1963   return a;
1964 }
1965 /** @} */
1966 
1967 /** multiply
1968 * @{
1969 */
1970 OTK_INLINE OTK_HOSTDEVICE ushort3 operator*(const ushort3& a, const ushort3& b)
1971 {
1972   return ::make_ushort3(a.x * b.x, a.y * b.y, a.z * b.z);
1973 }
1974 OTK_INLINE OTK_HOSTDEVICE ushort3 operator*(const ushort3& a, const unsigned short s)
1975 {
1976   return ::make_ushort3(a.x * s, a.y * s, a.z * s);
1977 }
1978 OTK_INLINE OTK_HOSTDEVICE ushort3 operator*(const unsigned short s, const ushort3& a)
1979 {
1980   return ::make_ushort3(a.x * s, a.y * s, a.z * s);
1981 }
1982 OTK_INLINE OTK_HOSTDEVICE ushort3& operator*=(ushort3& a, const ushort3& s)
1983 {
1984   a = a * s;
1985   return a;
1986 }
1987 OTK_INLINE OTK_HOSTDEVICE ushort3& operator*=(ushort3& a, const unsigned short s)
1988 {
1989   a = a * s;
1990   return a;
1991 }
1992 /** @} */
1993 
1994 /** divide
1995 * @{
1996 */
1997 OTK_INLINE OTK_HOSTDEVICE ushort3 operator/(const ushort3& a, const ushort3& b)
1998 {
1999   return ::make_ushort3(a.x / b.x, a.y / b.y, a.z / b.z);
2000 }
2001 OTK_INLINE OTK_HOSTDEVICE ushort3 operator/(const ushort3& a, const unsigned short s)
2002 {
2003   return ::make_ushort3(a.x / s, a.y / s, a.z / s);
2004 }
2005 OTK_INLINE OTK_HOSTDEVICE ushort3 operator/(const unsigned short s, const ushort3& a)
2006 {
2007   return ::make_ushort3(s /a.x, s / a.y, s / a.z);
2008 }
2009 OTK_INLINE OTK_HOSTDEVICE ushort3& operator/=(ushort3& a, const ushort3& s)
2010 {
2011   a = a / s;
2012   return a;
2013 }
2014 OTK_INLINE OTK_HOSTDEVICE ushort3& operator/=(ushort3& a, const unsigned short s)
2015 {
2016   a = a / s;
2017   return a;
2018 }
2019 /** @} */
2020 
2021 /** equality
2022 * @{
2023 */
2024 OTK_INLINE OTK_HOSTDEVICE bool operator==( const ushort3& a, const ushort3& b )
2025 {
2026   return a.x == b.x && a.y == b.y && a.z == b.z;
2027 }
2028 
2029 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const ushort3& a, const ushort3& b )
2030 {
2031   return !( a == b );
2032 }
2033 /** @} */
2034 
2035 /* ushort4 operators */
2036 /******************************************************************************/
2037 
2038 /** add
2039 * @{
2040 */
2041 OTK_INLINE OTK_HOSTDEVICE ushort4 operator+(const ushort4& a, const ushort4& b)
2042 {
2043   return ::make_ushort4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
2044 }
2045 OTK_INLINE OTK_HOSTDEVICE ushort4 operator+(const ushort4& a, const unsigned short b)
2046 {
2047   return ::make_ushort4(a.x + b, a.y + b, a.z + b, a.w + b);
2048 }
2049 OTK_INLINE OTK_HOSTDEVICE ushort4 operator+(const unsigned short a, const ushort4& b)
2050 {
2051   return b + a;
2052 }
2053 OTK_INLINE OTK_HOSTDEVICE ushort4& operator+=(ushort4& a, const ushort4& b)
2054 {
2055   a = a + b;
2056   return a;
2057 }
2058 OTK_INLINE OTK_HOSTDEVICE ushort4& operator+=(ushort4& a, const unsigned short b)
2059 {
2060   a = a + b;
2061   return a;
2062 }
2063 /** @} */
2064 
2065 /** subtract
2066 * @{
2067 */
2068 OTK_INLINE OTK_HOSTDEVICE ushort4 operator-(const ushort4& a, const ushort4& b)
2069 {
2070   return ::make_ushort4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
2071 }
2072 OTK_INLINE OTK_HOSTDEVICE ushort4 operator-(const ushort4& a, const unsigned short b)
2073 {
2074   return ::make_ushort4(a.x - b, a.y - b, a.z - b, a.w - b);
2075 }
2076 OTK_INLINE OTK_HOSTDEVICE ushort4 operator-(const unsigned short a, const ushort4& b)
2077 {
2078   return ::make_ushort4(a - b.x, a - b.y, a - b.z, a - b.w);
2079 }
2080 OTK_INLINE OTK_HOSTDEVICE ushort4& operator-=(ushort4& a, const ushort4& b)
2081 {
2082   a = a - b;
2083   return a;
2084 }
2085 OTK_INLINE OTK_HOSTDEVICE ushort4& operator-=(ushort4& a, const unsigned short b)
2086 {
2087   a = a - b;
2088   return a;
2089 }
2090 /** @} */
2091 
2092 /** multiply
2093 * @{
2094 */
2095 OTK_INLINE OTK_HOSTDEVICE ushort4 operator*(const ushort4& a, const ushort4& b)
2096 {
2097   return ::make_ushort4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
2098 }
2099 OTK_INLINE OTK_HOSTDEVICE ushort4 operator*(const ushort4& a, const unsigned short s)
2100 {
2101   return ::make_ushort4(a.x * s, a.y * s, a.z * s, a.w * s);
2102 }
2103 OTK_INLINE OTK_HOSTDEVICE ushort4 operator*(const unsigned short s, const ushort4& a)
2104 {
2105   return ::make_ushort4(a.x * s, a.y * s, a.z * s, a.w * s);
2106 }
2107 OTK_INLINE OTK_HOSTDEVICE ushort4& operator*=(ushort4& a, const ushort4& s)
2108 {
2109   a = a * s;
2110   return a;
2111 }
2112 OTK_INLINE OTK_HOSTDEVICE ushort4& operator*=(ushort4& a, const unsigned short s)
2113 {
2114   a = a * s;
2115   return a;
2116 }
2117 /** @} */
2118 
2119 /** divide
2120 * @{
2121 */
2122 OTK_INLINE OTK_HOSTDEVICE ushort4 operator/(const ushort4& a, const ushort4& b)
2123 {
2124   return ::make_ushort4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
2125 }
2126 OTK_INLINE OTK_HOSTDEVICE ushort4 operator/(const ushort4& a, const unsigned short s)
2127 {
2128   return ::make_ushort4(a.x / s, a.y / s, a.z / s, a.w / s);
2129 }
2130 OTK_INLINE OTK_HOSTDEVICE ushort4 operator/(const unsigned short s, const ushort4& a)
2131 {
2132   return ::make_ushort4(s / a.x, s / a.y, s / a.z, s / a.w);
2133 }
2134 OTK_INLINE OTK_HOSTDEVICE ushort4& operator/=(ushort4& a, const ushort4& s)
2135 {
2136   a = a / s;
2137   return a;
2138 }
2139 OTK_INLINE OTK_HOSTDEVICE ushort4& operator/=(ushort4& a, const unsigned short s)
2140 {
2141   a = a / s;
2142   return a;
2143 }
2144 /** @} */
2145 
2146 /** equality
2147 * @{
2148 */
2149 OTK_INLINE OTK_HOSTDEVICE bool operator==(const ushort4& a, const ushort4& b)
2150 {
2151   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
2152 }
2153 
2154 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const ushort4& a, const ushort4& b)
2155 {
2156   return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
2157 }
2158 /** @} */
2159 
2160 /* int2 operators */
2161 /******************************************************************************/
2162 
2163 /** negate */
2164 OTK_INLINE OTK_HOSTDEVICE int2 operator-(const int2& a)
2165 {
2166   return ::make_int2(-a.x, -a.y);
2167 }
2168 
2169 /** add
2170 * @{
2171 */
2172 OTK_INLINE OTK_HOSTDEVICE int2 operator+(const int2& a, const int2& b)
2173 {
2174   return ::make_int2(a.x + b.x, a.y + b.y);
2175 }
2176 OTK_INLINE OTK_HOSTDEVICE int2 operator+(const int2& a, const int b)
2177 {
2178   return ::make_int2(a.x + b, a.y + b);
2179 }
2180 OTK_INLINE OTK_HOSTDEVICE int2 operator+(const int a, const int2& b)
2181 {
2182   return ::make_int2(a + b.x, a + b.y);
2183 }
2184 OTK_INLINE OTK_HOSTDEVICE int2& operator+=(int2& a, const int2& b)
2185 {
2186   a = a + b;
2187   return a;
2188 }
2189 OTK_INLINE OTK_HOSTDEVICE int2& operator+=(int2& a, const int b)
2190 {
2191   a = a + b;
2192   return a;
2193 }
2194 /** @} */
2195 
2196 /** subtract
2197 * @{
2198 */
2199 OTK_INLINE OTK_HOSTDEVICE int2 operator-(const int2& a, const int2& b)
2200 {
2201   return ::make_int2(a.x - b.x, a.y - b.y);
2202 }
2203 OTK_INLINE OTK_HOSTDEVICE int2 operator-(const int2& a, const int b)
2204 {
2205   return ::make_int2(a.x - b, a.y - b);
2206 }
2207 OTK_INLINE OTK_HOSTDEVICE int2 operator-(const int a, const int2& b)
2208 {
2209   return ::make_int2(a - b.x, a - b.y);
2210 }
2211 OTK_INLINE OTK_HOSTDEVICE int2& operator-=(int2& a, const int2& b)
2212 {
2213   a = a - b;
2214   return a;
2215 }
2216 OTK_INLINE OTK_HOSTDEVICE int2& operator-=(int2& a, const int b)
2217 {
2218   a = a - b;
2219   return a;
2220 }
2221 /** @} */
2222 
2223 /** multiply
2224 * @{
2225 */
2226 OTK_INLINE OTK_HOSTDEVICE int2 operator*(const int2& a, const int2& b)
2227 {
2228   return ::make_int2(a.x * b.x, a.y * b.y);
2229 }
2230 OTK_INLINE OTK_HOSTDEVICE int2 operator*(const int2& a, const int s)
2231 {
2232   return ::make_int2(a.x * s, a.y * s);
2233 }
2234 OTK_INLINE OTK_HOSTDEVICE int2 operator*(const int s, const int2& a)
2235 {
2236   return ::make_int2(a.x * s, a.y * s);
2237 }
2238 OTK_INLINE OTK_HOSTDEVICE int2& operator*=(int2& a, const int2& s)
2239 {
2240   a = a * s;
2241   return a;
2242 }
2243 OTK_INLINE OTK_HOSTDEVICE int2& operator*=(int2& a, const int s)
2244 {
2245   a = a * s;
2246   return a;
2247 }
2248 /** @} */
2249 
2250 /** divide
2251 * @{
2252 */
2253 OTK_INLINE OTK_HOSTDEVICE int2 operator/(const int2& a, const int2& b)
2254 {
2255   return ::make_int2(a.x / b.x, a.y / b.y);
2256 }
2257 OTK_INLINE OTK_HOSTDEVICE int2 operator/(const int2& a, const int s)
2258 {
2259   return ::make_int2(a.x / s, a.y / s);
2260 }
2261 OTK_INLINE OTK_HOSTDEVICE int2 operator/(const int s, const int2& a)
2262 {
2263   return ::make_int2( s/a.x, s/a.y );
2264 }
2265 OTK_INLINE OTK_HOSTDEVICE int2& operator/=(int2& a, const int2& s)
2266 {
2267   a = a / s;
2268   return a;
2269 }
2270 OTK_INLINE OTK_HOSTDEVICE int2& operator/=(int2& a, const int s)
2271 {
2272   a = a / s;
2273   return a;
2274 }
2275 /** @} */
2276 
2277 /** equality
2278 * @{
2279 */
2280 OTK_INLINE OTK_HOSTDEVICE bool operator==(const int2& a, const int2& b)
2281 {
2282   return a.x == b.x && a.y == b.y;
2283 }
2284 
2285 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const int2& a, const int2& b)
2286 {
2287   return a.x != b.x || a.y != b.y;
2288 }
2289 /** @} */
2290 
2291 namespace otk {
2292 
2293 /* int2 functions */
2294 /******************************************************************************/
2295 
2296 /** additional constructors
2297 * @{
2298 */
2299 using ::make_int2;
2300 
2301 OTK_INLINE OTK_HOSTDEVICE int2 make_int2(const int s)
2302 {
2303   return ::make_int2(s, s);
2304 }
2305 OTK_INLINE OTK_HOSTDEVICE int2 make_int2(const float2& a)
2306 {
2307   return ::make_int2(int(a.x), int(a.y));
2308 }
2309 /** @} */
2310 
2311 /** min */
2312 OTK_INLINE OTK_HOSTDEVICE int2 min(const int2& a, const int2& b)
2313 {
2314   return ::make_int2(min(a.x,b.x), min(a.y,b.y));
2315 }
2316 
2317 /** max */
2318 OTK_INLINE OTK_HOSTDEVICE int2 max(const int2& a, const int2& b)
2319 {
2320   return ::make_int2(max(a.x,b.x), max(a.y,b.y));
2321 }
2322 
2323 /** clamp
2324 * @{
2325 */
2326 OTK_INLINE OTK_HOSTDEVICE int2 clamp(const int2& v, const int a, const int b)
2327 {
2328   return ::make_int2(clamp(v.x, a, b), clamp(v.y, a, b));
2329 }
2330 
2331 OTK_INLINE OTK_HOSTDEVICE int2 clamp(const int2& v, const int2& a, const int2& b)
2332 {
2333   return ::make_int2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
2334 }
2335 /** @} */
2336 
2337 /** If used on the device, this could place the the 'v' in local memory */
2338 OTK_INLINE OTK_HOSTDEVICE int getByIndex(const int2& v, int i)
2339 {
2340   return ((int*)(&v))[i];
2341 }
2342 
2343 /** If used on the device, this could place the the 'v' in local memory */
2344 OTK_INLINE OTK_HOSTDEVICE void setByIndex(int2& v, int i, int x)
2345 {
2346   ((int*)(&v))[i] = x;
2347 }
2348 
2349 }  // namespace otk
2350 
2351 /* int3 operators */
2352 /******************************************************************************/
2353 
2354 /** negate */
2355 OTK_INLINE OTK_HOSTDEVICE int3 operator-( const int3& a )
2356 {
2357   return ::make_int3( -a.x, -a.y, -a.z );
2358 }
2359 
2360 /** add
2361 * @{
2362 */
2363 OTK_INLINE OTK_HOSTDEVICE int3 operator+( const int3& a, const int3& b )
2364 {
2365   return ::make_int3( a.x + b.x, a.y + b.y, a.z + b.z );
2366 }
2367 OTK_INLINE OTK_HOSTDEVICE int3 operator+( const int3& a, const int b )
2368 {
2369   return ::make_int3( a.x + b, a.y + b, a.z + b );
2370 }
2371 OTK_INLINE OTK_HOSTDEVICE int3 operator+( const int a, const int3& b )
2372 {
2373   return ::make_int3( a + b.x, a + b.y, a + b.z );
2374 }
2375 OTK_INLINE OTK_HOSTDEVICE int3& operator+=( int3& a, const int3& b )
2376 {
2377   a = a + b;
2378   return a;
2379 }
2380 OTK_INLINE OTK_HOSTDEVICE int3& operator+=( int3& a, const int b )
2381 {
2382   a = a + b;
2383   return a;
2384 }
2385 /** @} */
2386 
2387 /** subtract
2388 * @{
2389 */
2390 OTK_INLINE OTK_HOSTDEVICE int3 operator-( const int3& a, const int3& b )
2391 {
2392   return ::make_int3( a.x - b.x, a.y - b.y, a.z - b.z );
2393 }
2394 OTK_INLINE OTK_HOSTDEVICE int3 operator-( const int3& a, const int b )
2395 {
2396   return ::make_int3( a.x - b, a.y - b, a.z - b );
2397 }
2398 OTK_INLINE OTK_HOSTDEVICE int3 operator-( const int a, const int3& b )
2399 {
2400   return ::make_int3( a - b.x, a - b.y, a - b.z );
2401 }
2402 OTK_INLINE OTK_HOSTDEVICE int3& operator-=( int3& a, const int3& b )
2403 {
2404   a = a - b;
2405   return a;
2406 }
2407 OTK_INLINE OTK_HOSTDEVICE int3& operator-=( int3& a, const int b )
2408 {
2409   a = a - b;
2410   return a;
2411 }
2412 /** @} */
2413 
2414 /** multiply
2415 * @{
2416 */
2417 OTK_INLINE OTK_HOSTDEVICE int3 operator*(const int3& a, const int3& b)
2418 {
2419   return ::make_int3(a.x * b.x, a.y * b.y, a.z * b.z);
2420 }
2421 OTK_INLINE OTK_HOSTDEVICE int3 operator*(const int3& a, const int s)
2422 {
2423   return ::make_int3(a.x * s, a.y * s, a.z * s);
2424 }
2425 OTK_INLINE OTK_HOSTDEVICE int3 operator*(const int s, const int3& a)
2426 {
2427   return ::make_int3(a.x * s, a.y * s, a.z * s);
2428 }
2429 OTK_INLINE OTK_HOSTDEVICE int3& operator*=(int3& a, const int3& s)
2430 {
2431   a = a * s;
2432   return a;
2433 }
2434 OTK_INLINE OTK_HOSTDEVICE int3& operator*=(int3& a, const int s)
2435 {
2436   a = a * s;
2437   return a;
2438 }
2439 /** @} */
2440 
2441 /** divide
2442 * @{
2443 */
2444 OTK_INLINE OTK_HOSTDEVICE int3 operator/(const int3& a, const int3& b)
2445 {
2446   return ::make_int3(a.x / b.x, a.y / b.y, a.z / b.z);
2447 }
2448 OTK_INLINE OTK_HOSTDEVICE int3 operator/(const int3& a, const int s)
2449 {
2450   return ::make_int3(a.x / s, a.y / s, a.z / s);
2451 }
2452 OTK_INLINE OTK_HOSTDEVICE int3 operator/(const int s, const int3& a)
2453 {
2454   return ::make_int3(s /a.x, s / a.y, s / a.z);
2455 }
2456 OTK_INLINE OTK_HOSTDEVICE int3& operator/=(int3& a, const int3& s)
2457 {
2458   a = a / s;
2459   return a;
2460 }
2461 OTK_INLINE OTK_HOSTDEVICE int3& operator/=(int3& a, const int s)
2462 {
2463   a = a / s;
2464   return a;
2465 }
2466 /** @} */
2467 
2468 /** equality
2469 * @{
2470 */
2471 OTK_INLINE OTK_HOSTDEVICE bool operator==(const int3& a, const int3& b)
2472 {
2473   return a.x == b.x && a.y == b.y && a.z == b.z;
2474 }
2475 
2476 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const int3& a, const int3& b)
2477 {
2478   return a.x != b.x || a.y != b.y || a.z != b.z;
2479 }
2480 /** @} */
2481 
2482 namespace otk {
2483 
2484 /* int3 functions */
2485 /******************************************************************************/
2486 
2487 /** additional constructors
2488 * @{
2489 */
2490 using ::make_int3;
2491 OTK_INLINE OTK_HOSTDEVICE int3 make_int3(const int s)
2492 {
2493   return ::make_int3(s, s, s);
2494 }
2495 OTK_INLINE OTK_HOSTDEVICE int3 make_int3(const float3& a)
2496 {
2497   return ::make_int3(int(a.x), int(a.y), int(a.z));
2498 }
2499 /** @} */
2500 
2501 /** min */
2502 OTK_INLINE OTK_HOSTDEVICE int3 min(const int3& a, const int3& b)
2503 {
2504   return ::make_int3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
2505 }
2506 
2507 /** max */
2508 OTK_INLINE OTK_HOSTDEVICE int3 max(const int3& a, const int3& b)
2509 {
2510   return ::make_int3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
2511 }
2512 
2513 /** clamp
2514 * @{
2515 */
2516 OTK_INLINE OTK_HOSTDEVICE int3 clamp(const int3& v, const int a, const int b)
2517 {
2518   return ::make_int3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
2519 }
2520 
2521 OTK_INLINE OTK_HOSTDEVICE int3 clamp(const int3& v, const int3& a, const int3& b)
2522 {
2523   return ::make_int3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
2524 }
2525 /** @} */
2526 
2527 /** If used on the device, this could place the the 'v' in local memory */
2528 OTK_INLINE OTK_HOSTDEVICE int getByIndex(const int3& v, int i)
2529 {
2530   return ((int*)(&v))[i];
2531 }
2532 
2533 /** If used on the device, this could place the the 'v' in local memory */
2534 OTK_INLINE OTK_HOSTDEVICE void setByIndex(int3& v, int i, int x)
2535 {
2536   ((int*)(&v))[i] = x;
2537 }
2538 
2539 } // namespace otk
2540 
2541 /* int4 operators */
2542 /******************************************************************************/
2543 
2544 /** negate */
2545 OTK_INLINE OTK_HOSTDEVICE int4 operator-(const int4& a)
2546 {
2547   return ::make_int4(-a.x, -a.y, -a.z, -a.w);
2548 }
2549 
2550 /** add
2551 * @{
2552 */
2553 OTK_INLINE OTK_HOSTDEVICE int4 operator+(const int4& a, const int4& b)
2554 {
2555   return ::make_int4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
2556 }
2557 OTK_INLINE OTK_HOSTDEVICE int4 operator+(const int4& a, const int b)
2558 {
2559   return ::make_int4(a.x + b, a.y + b, a.z + b, a.w + b);
2560 }
2561 OTK_INLINE OTK_HOSTDEVICE int4 operator+(const int a, const int4& b)
2562 {
2563   return b + a;
2564 }
2565 OTK_INLINE OTK_HOSTDEVICE int4& operator+=(int4& a, const int4& b)
2566 {
2567   a = a + b;
2568   return a;
2569 }
2570 OTK_INLINE OTK_HOSTDEVICE int4& operator+=(int4& a, const int b)
2571 {
2572   a = a + b;
2573   return a;
2574 }
2575 /** @} */
2576 
2577 /** subtract
2578 * @{
2579 */
2580 OTK_INLINE OTK_HOSTDEVICE int4 operator-(const int4& a, const int4& b)
2581 {
2582   return ::make_int4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
2583 }
2584 OTK_INLINE OTK_HOSTDEVICE int4 operator-(const int a, const int4& b)
2585 {
2586   return ::make_int4(a - b.x, a - b.y, a - b.z, a - b.w);
2587 }
2588 OTK_INLINE OTK_HOSTDEVICE int4 operator-(const int4& a, const int b)
2589 {
2590   return ::make_int4(a.x - b, a.y - b, a.z - b, a.w - b);
2591 }
2592 OTK_INLINE OTK_HOSTDEVICE int4& operator-=(int4& a, const int4& b)
2593 {
2594   a = a - b;
2595   return a;
2596 }
2597 OTK_INLINE OTK_HOSTDEVICE int4& operator-=(int4& a, const int b)
2598 {
2599   a = a - b;
2600   return a;
2601 }
2602 /** @} */
2603 
2604 /** multiply
2605 * @{
2606 */
2607 OTK_INLINE OTK_HOSTDEVICE int4 operator*(const int4& a, const int4& b)
2608 {
2609   return ::make_int4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
2610 }
2611 OTK_INLINE OTK_HOSTDEVICE int4 operator*(const int4& a, const int s)
2612 {
2613   return ::make_int4(a.x * s, a.y * s, a.z * s, a.w * s);
2614 }
2615 OTK_INLINE OTK_HOSTDEVICE int4 operator*(const int s, const int4& a)
2616 {
2617   return ::make_int4(a.x * s, a.y * s, a.z * s, a.w * s);
2618 }
2619 OTK_INLINE OTK_HOSTDEVICE int4& operator*=(int4& a, const int4& s)
2620 {
2621   a = a * s;
2622   return a;
2623 }
2624 OTK_INLINE OTK_HOSTDEVICE int4& operator*=(int4& a, const int s)
2625 {
2626   a = a * s;
2627   return a;
2628 }
2629 /** @} */
2630 
2631 /** divide
2632 * @{
2633 */
2634 OTK_INLINE OTK_HOSTDEVICE int4 operator/(const int4& a, const int4& b)
2635 {
2636   return ::make_int4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
2637 }
2638 OTK_INLINE OTK_HOSTDEVICE int4 operator/(const int4& a, const int s)
2639 {
2640   return ::make_int4(a.x / s, a.y / s, a.z / s, a.w / s);
2641 }
2642 OTK_INLINE OTK_HOSTDEVICE int4 operator/(const int s, const int4& a)
2643 {
2644   return ::make_int4(s / a.x, s / a.y, s / a.z, s / a.w);
2645 }
2646 OTK_INLINE OTK_HOSTDEVICE int4& operator/=(int4& a, const int4& s)
2647 {
2648   a = a / s;
2649   return a;
2650 }
2651 OTK_INLINE OTK_HOSTDEVICE int4& operator/=(int4& a, const int s)
2652 {
2653   a = a / s;
2654   return a;
2655 }
2656 /** @} */
2657 
2658 /** equality
2659 * @{
2660 */
2661 OTK_INLINE OTK_HOSTDEVICE bool operator==(const int4& a, const int4& b)
2662 {
2663   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
2664 }
2665 
2666 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const int4& a, const int4& b)
2667 {
2668   return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
2669 }
2670 /** @} */
2671 
2672 namespace otk {
2673 
2674 /* int4 functions */
2675 /******************************************************************************/
2676 
2677 /** additional constructors
2678 * @{
2679 */
2680 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int s)
2681 {
2682   return ::make_int4(s, s, s, s);
2683 }
2684 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const float4& a)
2685 {
2686   return ::make_int4((int)a.x, (int)a.y, (int)a.z, (int)a.w);
2687 }
2688 /** @} */
2689 
2690 /** min */
2691 OTK_INLINE OTK_HOSTDEVICE int4 min(const int4& a, const int4& b)
2692 {
2693   return ::make_int4(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z), min(a.w,b.w));
2694 }
2695 
2696 /** max */
2697 OTK_INLINE OTK_HOSTDEVICE int4 max(const int4& a, const int4& b)
2698 {
2699   return ::make_int4(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z), max(a.w,b.w));
2700 }
2701 
2702 /** clamp
2703 * @{
2704 */
2705 OTK_INLINE OTK_HOSTDEVICE int4 clamp(const int4& v, const int a, const int b)
2706 {
2707   return ::make_int4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
2708 }
2709 
2710 OTK_INLINE OTK_HOSTDEVICE int4 clamp(const int4& v, const int4& a, const int4& b)
2711 {
2712   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));
2713 }
2714 /** @} */
2715 
2716 /** If used on the device, this could place the the 'v' in local memory */
2717 OTK_INLINE OTK_HOSTDEVICE int getByIndex(const int4& v, int i)
2718 {
2719   return ((int*)(&v))[i];
2720 }
2721 
2722 /** If used on the device, this could place the the 'v' in local memory */
2723 OTK_INLINE OTK_HOSTDEVICE void setByIndex(int4& v, int i, int x)
2724 {
2725   ((int*)(&v))[i] = x;
2726 }
2727 
2728 
2729 /* uint functions */
2730 /******************************************************************************/
2731 
2732 /** clamp */
2733 OTK_INLINE OTK_HOSTDEVICE unsigned int clamp(const unsigned int f, const unsigned int a, const unsigned int b)
2734 {
2735   return max(a, min(f, b));
2736 }
2737 
2738 /** If used on the device, this could place the the 'v' in local memory */
2739 OTK_INLINE OTK_HOSTDEVICE unsigned int getByIndex(const uint1& v, unsigned int i)
2740 {
2741   return ((unsigned int*)(&v))[i];
2742 }
2743 
2744 /** If used on the device, this could place the the 'v' in local memory */
2745 OTK_INLINE OTK_HOSTDEVICE void setByIndex(uint1& v, int i, unsigned int x)
2746 {
2747   ((unsigned int*)(&v))[i] = x;
2748 }
2749 
2750 } // namespace otk
2751 
2752 /* uint2 operators */
2753 /******************************************************************************/
2754 
2755 /** add
2756 * @{
2757 */
2758 OTK_INLINE OTK_HOSTDEVICE uint2 operator+(const uint2& a, const uint2& b)
2759 {
2760   return ::make_uint2(a.x + b.x, a.y + b.y);
2761 }
2762 OTK_INLINE OTK_HOSTDEVICE uint2 operator+(const uint2& a, const unsigned int b)
2763 {
2764   return ::make_uint2(a.x + b, a.y + b);
2765 }
2766 OTK_INLINE OTK_HOSTDEVICE uint2 operator+(const unsigned int a, const uint2& b)
2767 {
2768   return ::make_uint2(a + b.x, a + b.y);
2769 }
2770 OTK_INLINE OTK_HOSTDEVICE uint2& operator+=(uint2& a, const uint2& b)
2771 {
2772   a = a + b;
2773   return a;
2774 }
2775 OTK_INLINE OTK_HOSTDEVICE uint2& operator+=(uint2& a, const unsigned int b)
2776 {
2777   a = a + b;
2778   return a;
2779 }
2780 /** @} */
2781 
2782 /** subtract
2783 * @{
2784 */
2785 OTK_INLINE OTK_HOSTDEVICE uint2 operator-(const uint2& a, const uint2& b)
2786 {
2787   return ::make_uint2(a.x - b.x, a.y - b.y);
2788 }
2789 OTK_INLINE OTK_HOSTDEVICE uint2 operator-(const uint2& a, const unsigned int b)
2790 {
2791   return ::make_uint2(a.x - b, a.y - b);
2792 }
2793 OTK_INLINE OTK_HOSTDEVICE uint2 operator-(const unsigned int a, const uint2& b)
2794 {
2795   return ::make_uint2(a - b.x, a - b.y);
2796 }
2797 OTK_INLINE OTK_HOSTDEVICE uint2& operator-=(uint2& a, const uint2& b)
2798 {
2799   a = a - b;
2800   return a;
2801 }
2802 OTK_INLINE OTK_HOSTDEVICE uint2& operator-=(uint2& a, const unsigned int b)
2803 {
2804   a = a - b;
2805   return a;
2806 }
2807 /** @} */
2808 
2809 /** multiply
2810 * @{
2811 */
2812 OTK_INLINE OTK_HOSTDEVICE uint2 operator*(const uint2& a, const uint2& b)
2813 {
2814   return ::make_uint2(a.x * b.x, a.y * b.y);
2815 }
2816 OTK_INLINE OTK_HOSTDEVICE uint2 operator*(const uint2& a, const unsigned int s)
2817 {
2818   return ::make_uint2(a.x * s, a.y * s);
2819 }
2820 OTK_INLINE OTK_HOSTDEVICE uint2 operator*(const unsigned int s, const uint2& a)
2821 {
2822   return ::make_uint2(a.x * s, a.y * s);
2823 }
2824 OTK_INLINE OTK_HOSTDEVICE uint2& operator*=( uint2& a, const uint2& s )
2825 {
2826   a = a * s;
2827   return a;
2828 }
2829 OTK_INLINE OTK_HOSTDEVICE uint2& operator*=( uint2& a, const unsigned int s )
2830 {
2831   a = a * s;
2832   return a;
2833 }
2834 /** @} */
2835 
2836 /** divide
2837 * @{
2838 */
2839 OTK_INLINE OTK_HOSTDEVICE uint2 operator/(const uint2& a, const uint2& b)
2840 {
2841   return ::make_uint2(a.x / b.x, a.y / b.y);
2842 }
2843 OTK_INLINE OTK_HOSTDEVICE uint2 operator/(const uint2& a, const unsigned int s)
2844 {
2845   return ::make_uint2(a.x / s, a.y / s);
2846 }
2847 OTK_INLINE OTK_HOSTDEVICE uint2 operator/(const unsigned int s, const uint2& a)
2848 {
2849   return ::make_uint2( s/a.x, s/a.y );
2850 }
2851 OTK_INLINE OTK_HOSTDEVICE uint2& operator/=(uint2& a, const uint2& s)
2852 {
2853   a = a / s;
2854   return a;
2855 }
2856 OTK_INLINE OTK_HOSTDEVICE uint2& operator/=(uint2& a, const unsigned int s)
2857 {
2858   a = a / s;
2859   return a;
2860 }
2861 /** @} */
2862 
2863 /** equality
2864 * @{
2865 */
2866 OTK_INLINE OTK_HOSTDEVICE bool operator==(const uint2& a, const uint2& b)
2867 {
2868   return a.x == b.x && a.y == b.y;
2869 }
2870 
2871 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const uint2& a, const uint2& b)
2872 {
2873   return a.x != b.x || a.y != b.y;
2874 }
2875 /** @} */
2876 
2877 namespace otk {
2878 
2879 /* uint2 functions */
2880 /******************************************************************************/
2881 
2882 /** additional constructors
2883 * @{
2884 */
2885 OTK_INLINE OTK_HOSTDEVICE uint2 make_uint2(const unsigned int s)
2886 {
2887   return ::make_uint2(s, s);
2888 }
2889 OTK_INLINE OTK_HOSTDEVICE uint2 make_uint2(const float2& a)
2890 {
2891   return ::make_uint2((unsigned int)a.x, (unsigned int)a.y);
2892 }
2893 /** @} */
2894 
2895 /** min */
2896 OTK_INLINE OTK_HOSTDEVICE uint2 min(const uint2& a, const uint2& b)
2897 {
2898   return ::make_uint2(min(a.x,b.x), min(a.y,b.y));
2899 }
2900 
2901 /** max */
2902 OTK_INLINE OTK_HOSTDEVICE uint2 max(const uint2& a, const uint2& b)
2903 {
2904   return ::make_uint2(max(a.x,b.x), max(a.y,b.y));
2905 }
2906 
2907 /** clamp
2908 * @{
2909 */
2910 OTK_INLINE OTK_HOSTDEVICE uint2 clamp(const uint2& v, const unsigned int a, const unsigned int b)
2911 {
2912   return ::make_uint2(clamp(v.x, a, b), clamp(v.y, a, b));
2913 }
2914 
2915 OTK_INLINE OTK_HOSTDEVICE uint2 clamp(const uint2& v, const uint2& a, const uint2& b)
2916 {
2917   return ::make_uint2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
2918 }
2919 /** @} */
2920 
2921 /** If used on the device, this could place the the 'v' in local memory */
2922 OTK_INLINE OTK_HOSTDEVICE unsigned int getByIndex(const uint2& v, unsigned int i)
2923 {
2924   return ((unsigned int*)(&v))[i];
2925 }
2926 
2927 /** If used on the device, this could place the the 'v' in local memory */
2928 OTK_INLINE OTK_HOSTDEVICE void setByIndex(uint2& v, int i, unsigned int x)
2929 {
2930   ((unsigned int*)(&v))[i] = x;
2931 }
2932 
2933 } // namespace otk
2934 
2935 /* uint3 operators */
2936 /******************************************************************************/
2937 
2938 /** add
2939 * @{
2940 */
2941 OTK_INLINE OTK_HOSTDEVICE uint3 operator+( const uint3& a, const uint3& b )
2942 {
2943   return ::make_uint3( a.x + b.x, a.y + b.y, a.z + b.z );
2944 }
2945 OTK_INLINE OTK_HOSTDEVICE uint3 operator+( const uint3& a, const unsigned int b )
2946 {
2947   return ::make_uint3( a.x + b, a.y + b, a.z + b );
2948 }
2949 OTK_INLINE OTK_HOSTDEVICE uint3 operator+( const unsigned int a, const uint3& b )
2950 {
2951   return ::make_uint3( a + b.x, a + b.y, a + b.z );
2952 }
2953 OTK_INLINE OTK_HOSTDEVICE uint3& operator+=( uint3& a, const uint3& b )
2954 {
2955   a = a + b;
2956   return a;
2957 }
2958 OTK_INLINE OTK_HOSTDEVICE uint3& operator+=( uint3& a, const unsigned int b )
2959 {
2960   a = a + b;
2961   return a;
2962 }
2963 /** @} */
2964 
2965 /** subtract
2966 * @{
2967 */
2968 OTK_INLINE OTK_HOSTDEVICE uint3 operator-( const uint3& a, const uint3& b )
2969 {
2970   return ::make_uint3( a.x - b.x, a.y - b.y, a.z - b.z );
2971 }
2972 OTK_INLINE OTK_HOSTDEVICE uint3 operator-( const uint3& a, const unsigned int b )
2973 {
2974   return ::make_uint3( a.x - b, a.y - b, a.z - b );
2975 }
2976 OTK_INLINE OTK_HOSTDEVICE uint3 operator-( const unsigned int a, const uint3& b )
2977 {
2978   return ::make_uint3( a - b.x, a - b.y, a - b.z );
2979 }
2980 OTK_INLINE OTK_HOSTDEVICE uint3& operator-=( uint3& a, const uint3& b )
2981 {
2982   a = a - b;
2983   return a;
2984 }
2985 OTK_INLINE OTK_HOSTDEVICE uint3& operator-=( uint3& a, const unsigned int b )
2986 {
2987   a = a - b;
2988   return a;
2989 }
2990 /** @} */
2991 
2992 /** multiply
2993 * @{
2994 */
2995 OTK_INLINE OTK_HOSTDEVICE uint3 operator*(const uint3& a, const uint3& b)
2996 {
2997   return ::make_uint3(a.x * b.x, a.y * b.y, a.z * b.z);
2998 }
2999 OTK_INLINE OTK_HOSTDEVICE uint3 operator*(const uint3& a, const unsigned int s)
3000 {
3001   return ::make_uint3(a.x * s, a.y * s, a.z * s);
3002 }
3003 OTK_INLINE OTK_HOSTDEVICE uint3 operator*(const unsigned int s, const uint3& a)
3004 {
3005   return ::make_uint3(a.x * s, a.y * s, a.z * s);
3006 }
3007 OTK_INLINE OTK_HOSTDEVICE uint3& operator*=(uint3& a, const uint3& s)
3008 {
3009   a = a * s;
3010   return a;
3011 }
3012 OTK_INLINE OTK_HOSTDEVICE uint3& operator*=(uint3& a, const unsigned int s)
3013 {
3014   a = a * s;
3015   return a;
3016 }
3017 /** @} */
3018 
3019 /** divide
3020 * @{
3021 */
3022 OTK_INLINE OTK_HOSTDEVICE uint3 operator/(const uint3& a, const uint3& b)
3023 {
3024   return ::make_uint3(a.x / b.x, a.y / b.y, a.z / b.z);
3025 }
3026 OTK_INLINE OTK_HOSTDEVICE uint3 operator/(const uint3& a, const unsigned int s)
3027 {
3028   return ::make_uint3(a.x / s, a.y / s, a.z / s);
3029 }
3030 OTK_INLINE OTK_HOSTDEVICE uint3 operator/(const unsigned int s, const uint3& a)
3031 {
3032   return ::make_uint3(s /a.x, s / a.y, s / a.z);
3033 }
3034 OTK_INLINE OTK_HOSTDEVICE uint3& operator/=(uint3& a, const uint3& s)
3035 {
3036   a = a / s;
3037   return a;
3038 }
3039 OTK_INLINE OTK_HOSTDEVICE uint3& operator/=(uint3& a, const unsigned int s)
3040 {
3041   a = a / s;
3042   return a;
3043 }
3044 /** @} */
3045 
3046 /** equality
3047 * @{
3048 */
3049 OTK_INLINE OTK_HOSTDEVICE bool operator==( const uint3& a, const uint3& b )
3050 {
3051   return a.x == b.x && a.y == b.y && a.z == b.z;
3052 }
3053 
3054 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const uint3& a, const uint3& b )
3055 {
3056   return !( a == b );
3057 }
3058 /** @} */
3059 
3060 namespace otk {
3061 
3062 /* uint3 functions */
3063 /******************************************************************************/
3064 
3065 /** additional constructors
3066 * @{
3067 */
3068 OTK_INLINE OTK_HOSTDEVICE uint3 make_uint3(const unsigned int s)
3069 {
3070   return ::make_uint3(s, s, s);
3071 }
3072 OTK_INLINE OTK_HOSTDEVICE uint3 make_uint3(const float3& a)
3073 {
3074   return ::make_uint3((unsigned int)a.x, (unsigned int)a.y, (unsigned int)a.z);
3075 }
3076 /** @} */
3077 
3078 /** min */
3079 OTK_INLINE OTK_HOSTDEVICE uint3 min(const uint3& a, const uint3& b)
3080 {
3081   return ::make_uint3(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z));
3082 }
3083 
3084 /** max */
3085 OTK_INLINE OTK_HOSTDEVICE uint3 max(const uint3& a, const uint3& b)
3086 {
3087   return ::make_uint3(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z));
3088 }
3089 
3090 /** clamp
3091 * @{
3092 */
3093 OTK_INLINE OTK_HOSTDEVICE uint3 clamp(const uint3& v, const unsigned int a, const unsigned int b)
3094 {
3095   return ::make_uint3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
3096 }
3097 
3098 OTK_INLINE OTK_HOSTDEVICE uint3 clamp(const uint3& v, const uint3& a, const uint3& b)
3099 {
3100   return ::make_uint3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
3101 }
3102 /** @} */
3103 
3104 /** If used on the device, this could place the the 'v' in local memory
3105 */
3106 OTK_INLINE OTK_HOSTDEVICE unsigned int getByIndex(const uint3& v, unsigned int i)
3107 {
3108   return ((unsigned int*)(&v))[i];
3109 }
3110 
3111 /** If used on the device, this could place the the 'v' in local memory
3112 */
3113 OTK_INLINE OTK_HOSTDEVICE void setByIndex(uint3& v, int i, unsigned int x)
3114 {
3115   ((unsigned int*)(&v))[i] = x;
3116 }
3117 
3118 } // namespace otk
3119 
3120 /* uint4 operators */
3121 /******************************************************************************/
3122 
3123 /** add
3124 * @{
3125 */
3126 OTK_INLINE OTK_HOSTDEVICE uint4 operator+(const uint4& a, const uint4& b)
3127 {
3128   return ::make_uint4(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
3129 }
3130 OTK_INLINE OTK_HOSTDEVICE uint4 operator+(const uint4& a, const unsigned int b)
3131 {
3132   return ::make_uint4(a.x + b, a.y + b, a.z + b, a.w + b);
3133 }
3134 OTK_INLINE OTK_HOSTDEVICE uint4 operator+(const unsigned int a, const uint4& b)
3135 {
3136   return b + a;
3137 }
3138 OTK_INLINE OTK_HOSTDEVICE uint4& operator+=(uint4& a, const uint4& b)
3139 {
3140   a = a + b;
3141   return a;
3142 }
3143 OTK_INLINE OTK_HOSTDEVICE uint4& operator+=(uint4& a, const unsigned int b)
3144 {
3145   a = a + b;
3146   return a;
3147 }
3148 /** @} */
3149 
3150 /** subtract
3151 * @{
3152 */
3153 OTK_INLINE OTK_HOSTDEVICE uint4 operator-(const uint4& a, const uint4& b)
3154 {
3155   return ::make_uint4(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
3156 }
3157 OTK_INLINE OTK_HOSTDEVICE uint4 operator-(const uint4& a, const unsigned int b)
3158 {
3159   return ::make_uint4(a.x - b, a.y - b, a.z - b, a.w - b);
3160 }
3161 OTK_INLINE OTK_HOSTDEVICE uint4 operator-(const unsigned int a, const uint4& b)
3162 {
3163   return ::make_uint4(a - b.x, a - b.y, a - b.z, a - b.w);
3164 }
3165 OTK_INLINE OTK_HOSTDEVICE uint4& operator-=(uint4& a, const uint4& b)
3166 {
3167   a = a - b;
3168   return a;
3169 }
3170 OTK_INLINE OTK_HOSTDEVICE uint4& operator-=(uint4& a, const unsigned int b)
3171 {
3172   a = a - b;
3173   return a;
3174 }
3175 /** @} */
3176 
3177 /** multiply
3178 * @{
3179 */
3180 OTK_INLINE OTK_HOSTDEVICE uint4 operator*(const uint4& a, const uint4& b)
3181 {
3182   return ::make_uint4(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
3183 }
3184 OTK_INLINE OTK_HOSTDEVICE uint4 operator*(const uint4& a, const unsigned int s)
3185 {
3186   return ::make_uint4(a.x * s, a.y * s, a.z * s, a.w * s);
3187 }
3188 OTK_INLINE OTK_HOSTDEVICE uint4 operator*(const unsigned int s, const uint4& a)
3189 {
3190   return ::make_uint4(a.x * s, a.y * s, a.z * s, a.w * s);
3191 }
3192 OTK_INLINE OTK_HOSTDEVICE uint4& operator*=(uint4& a, const uint4& s)
3193 {
3194   a = a * s;
3195   return a;
3196 }
3197 OTK_INLINE OTK_HOSTDEVICE uint4& operator*=(uint4& a, const unsigned int s)
3198 {
3199   a = a * s;
3200   return a;
3201 }
3202 /** @} */
3203 
3204 /** divide
3205 * @{
3206 */
3207 OTK_INLINE OTK_HOSTDEVICE uint4 operator/(const uint4& a, const uint4& b)
3208 {
3209   return ::make_uint4(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
3210 }
3211 OTK_INLINE OTK_HOSTDEVICE uint4 operator/(const uint4& a, const unsigned int s)
3212 {
3213   return ::make_uint4(a.x / s, a.y / s, a.z / s, a.w / s);
3214 }
3215 OTK_INLINE OTK_HOSTDEVICE uint4 operator/(const unsigned int s, const uint4& a)
3216 {
3217   return ::make_uint4(s / a.x, s / a.y, s / a.z, s / a.w);
3218 }
3219 OTK_INLINE OTK_HOSTDEVICE uint4& operator/=(uint4& a, const uint4& s)
3220 {
3221   a = a / s;
3222   return a;
3223 }
3224 OTK_INLINE OTK_HOSTDEVICE uint4& operator/=(uint4& a, const unsigned int s)
3225 {
3226   a = a / s;
3227   return a;
3228 }
3229 /** @} */
3230 
3231 /** equality
3232 * @{
3233 */
3234 OTK_INLINE OTK_HOSTDEVICE bool operator==(const uint4& a, const uint4& b)
3235 {
3236   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
3237 }
3238 
3239 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const uint4& a, const uint4& b)
3240 {
3241   return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
3242 }
3243 /** @} */
3244 
3245 namespace otk {
3246 
3247 /* uint4 functions */
3248 /******************************************************************************/
3249 
3250 /** additional constructors
3251 * @{
3252 */
3253 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const unsigned int s)
3254 {
3255   return ::make_uint4(s, s, s, s);
3256 }
3257 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const float4& a)
3258 {
3259   return ::make_uint4((unsigned int)a.x, (unsigned int)a.y, (unsigned int)a.z, (unsigned int)a.w);
3260 }
3261 /** @} */
3262 
3263 /** min
3264 * @{
3265 */
3266 OTK_INLINE OTK_HOSTDEVICE uint4 min(const uint4& a, const uint4& b)
3267 {
3268   return ::make_uint4(min(a.x,b.x), min(a.y,b.y), min(a.z,b.z), min(a.w,b.w));
3269 }
3270 /** @} */
3271 
3272 /** max
3273 * @{
3274 */
3275 OTK_INLINE OTK_HOSTDEVICE uint4 max(const uint4& a, const uint4& b)
3276 {
3277   return ::make_uint4(max(a.x,b.x), max(a.y,b.y), max(a.z,b.z), max(a.w,b.w));
3278 }
3279 /** @} */
3280 
3281 /** clamp
3282 * @{
3283 */
3284 OTK_INLINE OTK_HOSTDEVICE uint4 clamp(const uint4& v, const unsigned int a, const unsigned int b)
3285 {
3286   return ::make_uint4(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
3287 }
3288 
3289 OTK_INLINE OTK_HOSTDEVICE uint4 clamp(const uint4& v, const uint4& a, const uint4& b)
3290 {
3291   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));
3292 }
3293 /** @} */
3294 
3295 /** If used on the device, this could place the the 'v' in local memory
3296 */
3297 OTK_INLINE OTK_HOSTDEVICE unsigned int getByIndex(const uint4& v, unsigned int i)
3298 {
3299   return ((unsigned int*)(&v))[i];
3300 }
3301 
3302 /** If used on the device, this could place the the 'v' in local memory
3303 */
3304 OTK_INLINE OTK_HOSTDEVICE void setByIndex(uint4& v, int i, unsigned int x)
3305 {
3306   ((unsigned int*)(&v))[i] = x;
3307 }
3308 
3309 } // namespace otk
3310 
3311 /* long2 operators */
3312 /******************************************************************************/
3313 
3314 /** negate */
3315 OTK_INLINE OTK_HOSTDEVICE long2 operator-(const long2& a)
3316 {
3317     return ::make_long2(-a.x, -a.y);
3318 }
3319 
3320 /** add
3321 * @{
3322 */
3323 OTK_INLINE OTK_HOSTDEVICE long2 operator+(const long2& a, const long2& b)
3324 {
3325   return ::make_long2(a.x + b.x, a.y + b.y);
3326 }
3327 OTK_INLINE OTK_HOSTDEVICE long2 operator+(const long2& a, const long b)
3328 {
3329   return ::make_long2(a.x + b, a.y + b);
3330 }
3331 OTK_INLINE OTK_HOSTDEVICE long2 operator+(const long a, const long2& b)
3332 {
3333   return ::make_long2(a + b.x, a + b.y);
3334 }
3335 OTK_INLINE OTK_HOSTDEVICE long2& operator+=(long2& a, const long2& b)
3336 {
3337   a = a + b;
3338   return a;
3339 }
3340 OTK_INLINE OTK_HOSTDEVICE long2& operator+=(long2& a, const long b)
3341 {
3342   a = a + b;
3343   return a;
3344 }
3345 /** @} */
3346 
3347 /** subtract
3348 * @{
3349 */
3350 OTK_INLINE OTK_HOSTDEVICE long2 operator-(const long2& a, const long2& b)
3351 {
3352   return ::make_long2(a.x - b.x, a.y - b.y);
3353 }
3354 OTK_INLINE OTK_HOSTDEVICE long2 operator-(const long2& a, const long b)
3355 {
3356   return ::make_long2(a.x - b, a.y - b);
3357 }
3358 OTK_INLINE OTK_HOSTDEVICE long2 operator-(const long a, const long2& b)
3359 {
3360   return ::make_long2(a - b.x, a - b.y);
3361 }
3362 OTK_INLINE OTK_HOSTDEVICE long2& operator-=(long2& a, const long2& b)
3363 {
3364   a = a - b;
3365   return a;
3366 }
3367 OTK_INLINE OTK_HOSTDEVICE long2& operator-=(long2& a, const long b)
3368 {
3369   a = a - b;
3370   return a;
3371 }
3372 /** @} */
3373 
3374 /** multiply
3375 * @{
3376 */
3377 OTK_INLINE OTK_HOSTDEVICE long2 operator*(const long2& a, const long2& b)
3378 {
3379   return ::make_long2(a.x * b.x, a.y * b.y);
3380 }
3381 OTK_INLINE OTK_HOSTDEVICE long2 operator*(const long2& a, const long s)
3382 {
3383   return ::make_long2(a.x * s, a.y * s);
3384 }
3385 OTK_INLINE OTK_HOSTDEVICE long2 operator*(const long s, const long2& a)
3386 {
3387   return ::make_long2(a.x * s, a.y * s);
3388 }
3389 OTK_INLINE OTK_HOSTDEVICE long2& operator*=(long2& a, const long2& s)
3390 {
3391   a = a * s;
3392   return a;
3393 }
3394 OTK_INLINE OTK_HOSTDEVICE long2& operator*=(long2& a, const long s)
3395 {
3396   a = a * s;
3397   return a;
3398 }
3399 /** @} */
3400 
3401 /** divide
3402 * @{
3403 */
3404 OTK_INLINE OTK_HOSTDEVICE long2 operator/(const long2& a, const long2& b)
3405 {
3406   return ::make_long2(a.x / b.x, a.y / b.y);
3407 }
3408 OTK_INLINE OTK_HOSTDEVICE long2 operator/(const long2& a, const long s)
3409 {
3410   return ::make_long2(a.x / s, a.y / s);
3411 }
3412 OTK_INLINE OTK_HOSTDEVICE long2 operator/(const long s, const long2& a)
3413 {
3414   return ::make_long2( s/a.x, s/a.y );
3415 }
3416 OTK_INLINE OTK_HOSTDEVICE long2& operator/=(long2& a, const long2& s)
3417 {
3418   a = a / s;
3419   return a;
3420 }
3421 OTK_INLINE OTK_HOSTDEVICE long2& operator/=(long2& a, const long s)
3422 {
3423   a = a / s;
3424   return a;
3425 }
3426 /** @} */
3427 
3428 /** equality
3429 * @{
3430 */
3431 OTK_INLINE OTK_HOSTDEVICE bool operator==( const long2& a, const long2& b )
3432 {
3433   return a.x == b.x && a.y == b.y;
3434 }
3435 
3436 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const long2& a, const long2& b )
3437 {
3438   return !( a == b );
3439 }
3440 /** @} */
3441 
3442 namespace otk {
3443 
3444 /* long2 functions */
3445 /******************************************************************************/
3446 
3447 } // namespace otk
3448 
3449 /* long3 operators */
3450 /******************************************************************************/
3451 
3452 /** negate */
3453 OTK_INLINE OTK_HOSTDEVICE long3 operator-( const long3& a )
3454 {
3455   return ::make_long3( -a.x, -a.y, -a.z );
3456 }
3457 
3458 /** add
3459 * @{
3460 */
3461 OTK_INLINE OTK_HOSTDEVICE long3 operator+( const long3& a, const long3& b )
3462 {
3463   return ::make_long3( a.x + b.x, a.y + b.y, a.z + b.z );
3464 }
3465 OTK_INLINE OTK_HOSTDEVICE long3 operator+( const long3& a, const long b )
3466 {
3467   return ::make_long3( a.x + b, a.y + b, a.z + b );
3468 }
3469 OTK_INLINE OTK_HOSTDEVICE long3 operator+( const long a, const long3& b )
3470 {
3471   return ::make_long3( a + b.x, a + b.y, a + b.z );
3472 }
3473 OTK_INLINE OTK_HOSTDEVICE long3& operator+=( long3& a, const long3& b )
3474 {
3475   a = a + b;
3476   return a;
3477 }
3478 OTK_INLINE OTK_HOSTDEVICE long3& operator+=( long3& a, const long b )
3479 {
3480   a = a + b;
3481   return a;
3482 }
3483 /** @} */
3484 
3485 /** subtract
3486 * @{
3487 */
3488 OTK_INLINE OTK_HOSTDEVICE long3 operator-( const long3& a, const long3& b )
3489 {
3490   return ::make_long3( a.x - b.x, a.y - b.y, a.z - b.z );
3491 }
3492 OTK_INLINE OTK_HOSTDEVICE long3 operator-( const long3& a, const long b )
3493 {
3494   return ::make_long3( a.x - b, a.y - b, a.z - b );
3495 }
3496 OTK_INLINE OTK_HOSTDEVICE long3 operator-( const long a, const long3& b )
3497 {
3498   return ::make_long3( a - b.x, a - b.y, a - b.z );
3499 }
3500 OTK_INLINE OTK_HOSTDEVICE long3& operator-=( long3& a, const long3& b )
3501 {
3502   a = a - b;
3503   return a;
3504 }
3505 OTK_INLINE OTK_HOSTDEVICE long3& operator-=( long3& a, const long b )
3506 {
3507   a = a - b;
3508   return a;
3509 }
3510 /** @} */
3511 
3512 /** multiply
3513 * @{
3514 */
3515 OTK_INLINE OTK_HOSTDEVICE long3 operator*(const long3& a, const long3& b)
3516 {
3517   return ::make_long3(a.x * b.x, a.y * b.y, a.z * b.z);
3518 }
3519 OTK_INLINE OTK_HOSTDEVICE long3 operator*(const long3& a, const long s)
3520 {
3521   return ::make_long3(a.x * s, a.y * s, a.z * s);
3522 }
3523 OTK_INLINE OTK_HOSTDEVICE long3 operator*(const long s, const long3& a)
3524 {
3525   return ::make_long3(a.x * s, a.y * s, a.z * s);
3526 }
3527 OTK_INLINE OTK_HOSTDEVICE long3& operator*=(long3& a, const long3& s)
3528 {
3529   a = a * s;
3530   return a;
3531 }
3532 OTK_INLINE OTK_HOSTDEVICE long3& operator*=(long3& a, const long s)
3533 {
3534   a = a * s;
3535   return a;
3536 }
3537 /** @} */
3538 
3539 /** divide
3540 * @{
3541 */
3542 OTK_INLINE OTK_HOSTDEVICE long3 operator/(const long3& a, const long3& b)
3543 {
3544   return ::make_long3(a.x / b.x, a.y / b.y, a.z / b.z);
3545 }
3546 OTK_INLINE OTK_HOSTDEVICE long3 operator/(const long3& a, const long s)
3547 {
3548   return ::make_long3(a.x / s, a.y / s, a.z / s);
3549 }
3550 OTK_INLINE OTK_HOSTDEVICE long3 operator/(const long s, const long3& a)
3551 {
3552   return ::make_long3(s /a.x, s / a.y, s / a.z);
3553 }
3554 OTK_INLINE OTK_HOSTDEVICE long3& operator/=(long3& a, const long3& s)
3555 {
3556   a = a / s;
3557   return a;
3558 }
3559 OTK_INLINE OTK_HOSTDEVICE long3& operator/=(long3& a, const long s)
3560 {
3561   a = a / s;
3562   return a;
3563 }
3564 /** @} */
3565 
3566 /** equality
3567 * @{
3568 */
3569 OTK_INLINE OTK_HOSTDEVICE bool operator==( const long3& a, const long3& b )
3570 {
3571   return a.x == b.x && a.y == b.y && a.z == b.z;
3572 }
3573 
3574 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const long3& a, const long3& b )
3575 {
3576   return !( a == b );
3577 }
3578 /** @} */
3579 
3580 namespace otk {
3581 
3582 /* long3 functions */
3583 /******************************************************************************/
3584 
3585 } // namespace otk
3586 
3587 #if CUDART_VERSION >= 13000
3588 /* long4_16a operators */
3589 /******************************************************************************/
3590 
3591 /** negate */
3592 OTK_INLINE OTK_HOSTDEVICE long4_16a operator-( const long4_16a& a )
3593 {
3594   return make_long4_16a( -a.x, -a.y, -a.z, -a.w );
3595 }
3596 
3597 /** add
3598 * @{
3599 */
3600 OTK_INLINE OTK_HOSTDEVICE long4_16a operator+( const long4_16a& a, const long4_16a& b )
3601 {
3602   return make_long4_16a( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );
3603 }
3604 OTK_INLINE OTK_HOSTDEVICE long4_16a operator+( const long4_16a& a, const long b )
3605 {
3606   return make_long4_16a( a.x + b, a.y + b, a.z + b, a.w + b );
3607 }
3608 OTK_INLINE OTK_HOSTDEVICE long4_16a operator+( const long a, const long4_16a& b )
3609 {
3610   return make_long4_16a( a + b.x, a + b.y, a + b.z, a + b.w );
3611 }
3612 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator+=( long4_16a& a, const long4_16a& b )
3613 {
3614   a = a + b;
3615   return a;
3616 }
3617 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator+=( long4_16a& a, const long b )
3618 {
3619   a = a + b;
3620   return a;
3621 }
3622 /** @} */
3623 
3624 /** subtract
3625 * @{
3626 */
3627 OTK_INLINE OTK_HOSTDEVICE long4_16a operator-( const long4_16a& a, const long4_16a& b )
3628 {
3629   return make_long4_16a( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );
3630 }
3631 OTK_INLINE OTK_HOSTDEVICE long4_16a operator-( const long4_16a& a, const long b )
3632 {
3633   return make_long4_16a( a.x - b, a.y - b, a.z - b, a.w - b );
3634 }
3635 OTK_INLINE OTK_HOSTDEVICE long4_16a operator-( const long a, const long4_16a& b )
3636 {
3637   return make_long4_16a( a - b.x, a - b.y, a - b.z, a - b.w );
3638 }
3639 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator-=( long4_16a& a, const long4_16a& b )
3640 {
3641   a = a - b;
3642   return a;
3643 }
3644 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator-=( long4_16a& a, const long b )
3645 {
3646   a = a - b;
3647   return a;
3648 }
3649 /** @} */
3650 
3651 /** multiply
3652 * @{
3653 */
3654 OTK_INLINE OTK_HOSTDEVICE long4_16a operator*(const long4_16a& a, const long4_16a& b)
3655 {
3656   return make_long4_16a(a.x * b.x, a.y * b.y, a.z * b.z, 0);
3657 }
3658 OTK_INLINE OTK_HOSTDEVICE long4_16a operator*(const long4_16a& a, const long s)
3659 {
3660   return make_long4_16a(a.x * s, a.y * s, a.z * s, 0);
3661 }
3662 OTK_INLINE OTK_HOSTDEVICE long4_16a operator*(const long s, const long4_16a& a)
3663 {
3664   return make_long4_16a(a.x * s, a.y * s, a.z * s, 0);
3665 }
3666 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator*=(long4_16a& a, const long4_16a& s)
3667 {
3668   a = a *s;
3669   return a;
3670 }
3671 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator*=(long4_16a& a, const long s)
3672 {
3673   a = a *s;
3674   return a;
3675 }
3676 /** @} */
3677 
3678 /** divide
3679 * @{
3680 */
3681 OTK_INLINE OTK_HOSTDEVICE long4_16a operator/(const long4_16a& a, const long4_16a& b)
3682 {
3683   return make_long4_16a(a.x / b.x, a.y / b.y, a.z / b.z, 0);
3684 }
3685 OTK_INLINE OTK_HOSTDEVICE long4_16a operator/(const long4_16a& a, const long s)
3686 {
3687   return make_long4_16a(a.x / s, a.y / s, a.z / s, 0);
3688 }
3689 OTK_INLINE OTK_HOSTDEVICE long4_16a operator/(const long s, const long4_16a& a)
3690 {
3691   return make_long4_16a(s /a.x, s / a.y, s / a.z, 0);
3692 }
3693 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator/=(long4_16a& a, const long4_16a& s)
3694 {
3695   a = a / s;
3696   return a;
3697 }
3698 OTK_INLINE OTK_HOSTDEVICE long4_16a& operator/=(long4_16a& a, const long s)
3699 {
3700   a = a / s;
3701   return a;
3702 }
3703 /** @} */
3704 
3705 /** equality
3706 * @{
3707 */
3708 OTK_INLINE OTK_HOSTDEVICE bool operator==( const long4_16a& a, const long4_16a& b )
3709 {
3710   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
3711 }
3712 
3713 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const long4_16a& a, const long4_16a& b )
3714 {
3715   return !( a == b );
3716 }
3717 /** @} */
3718 
3719 namespace otk {
3720 
3721 /* long4_16a functions */
3722 /******************************************************************************/
3723 
3724 } // namespace otk
3725 
3726 /* ulong4_16a operators */
3727 /******************************************************************************/
3728 
3729 /** add
3730 * @{
3731 */
3732 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator+( const ulong4_16a& a, const ulong4_16a& b )
3733 {
3734   return make_ulong4_16a( a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w );
3735 }
3736 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator+( const ulong4_16a& a, const long b )
3737 {
3738   return make_ulong4_16a( a.x + b, a.y + b, a.z + b, a.w + b );
3739 }
3740 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator+( const long a, const ulong4_16a& b )
3741 {
3742   return make_ulong4_16a( a + b.x, a + b.y, a + b.z, a + b.w );
3743 }
3744 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator+=( ulong4_16a& a, const ulong4_16a& b )
3745 {
3746   a = a + b;
3747   return a;
3748 }
3749 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator+=( ulong4_16a& a, const long b )
3750 {
3751   a = a + b;
3752   return a;
3753 }
3754 /** @} */
3755 
3756 /** subtract
3757 * @{
3758 */
3759 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator-( const ulong4_16a& a, const ulong4_16a& b )
3760 {
3761   return make_ulong4_16a( a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w );
3762 }
3763 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator-( const ulong4_16a& a, const long b )
3764 {
3765   return make_ulong4_16a( a.x - b, a.y - b, a.z - b, a.w - b );
3766 }
3767 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator-( const long a, const ulong4_16a& b )
3768 {
3769   return make_ulong4_16a( a - b.x, a - b.y, a - b.z, a - b.w );
3770 }
3771 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator-=( ulong4_16a& a, const ulong4_16a& b )
3772 {
3773   a = a - b;
3774   return a;
3775 }
3776 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator-=( ulong4_16a& a, const long b )
3777 {
3778   a = a - b;
3779   return a;
3780 }
3781 /** @} */
3782 
3783 /** multiply
3784 * @{
3785 */
3786 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator*(const ulong4_16a& a, const ulong4_16a& b)
3787 {
3788   return make_ulong4_16a(a.x * b.x, a.y * b.y, a.z * b.z, 0);
3789 }
3790 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator*(const ulong4_16a& a, const long s)
3791 {
3792   return make_ulong4_16a(a.x * s, a.y * s, a.z * s, 0);
3793 }
3794 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator*(const long s, const ulong4_16a& a)
3795 {
3796   return make_ulong4_16a(a.x * s, a.y * s, a.z * s, 0);
3797 }
3798 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator*=(ulong4_16a& a, const ulong4_16a& s)
3799 {
3800   a = a * s;
3801   return a;
3802 }
3803 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator*=(ulong4_16a& a, const long s)
3804 {
3805   a = a * s;
3806   return a;
3807 }
3808 /** @} */
3809 
3810 /** divide
3811 * @{
3812 */
3813 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator/(const ulong4_16a& a, const ulong4_16a& b)
3814 {
3815   return make_ulong4_16a(a.x / b.x, a.y / b.y, a.z / b.z, 0);
3816 }
3817 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator/(const ulong4_16a& a, const long s)
3818 {
3819   return make_ulong4_16a(a.x / s, a.y / s, a.z / s, 0);
3820 }
3821 OTK_INLINE OTK_HOSTDEVICE ulong4_16a operator/(const long s, const ulong4_16a& a)
3822 {
3823   return make_ulong4_16a(s /a.x, s / a.y, s / a.z, 0);
3824 }
3825 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator/=(ulong4_16a& a, const ulong4_16a& s)
3826 {
3827   a = a / s;
3828   return a;
3829 }
3830 OTK_INLINE OTK_HOSTDEVICE ulong4_16a& operator/=(ulong4_16a& a, const long s)
3831 {
3832   a = a / s;
3833   return a;
3834 }
3835 /** @} */
3836 
3837 /** equality
3838 * @{
3839 */
3840 OTK_INLINE OTK_HOSTDEVICE bool operator==( const ulong4_16a& a, const ulong4_16a& b )
3841 {
3842   return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
3843 }
3844 
3845 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const ulong4_16a& a, const ulong4_16a& b )
3846 {
3847   return !( a == b );
3848 }
3849 /** @} */
3850 
3851 namespace otk {
3852 
3853 /* ulong4_16a functions */
3854 /******************************************************************************/
3855 
3856 } // namespace otk
3857 #endif // CUDART_VERSION >= 13000
3858 
3859 /* ulong2 operators */
3860 /******************************************************************************/
3861 
3862 /** add
3863 * @{
3864 */
3865 OTK_INLINE OTK_HOSTDEVICE ulong2 operator+(const ulong2& a, const ulong2& b)
3866 {
3867   return ::make_ulong2(a.x + b.x, a.y + b.y);
3868 }
3869 OTK_INLINE OTK_HOSTDEVICE ulong2 operator+(const ulong2& a, const unsigned long b)
3870 {
3871   return ::make_ulong2(a.x + b, a.y + b);
3872 }
3873 OTK_INLINE OTK_HOSTDEVICE ulong2 operator+(const unsigned long a, const ulong2& b)
3874 {
3875   return ::make_ulong2(a + b.x, a + b.y);
3876 }
3877 OTK_INLINE OTK_HOSTDEVICE ulong2& operator+=(ulong2& a, const ulong2& b)
3878 {
3879   a = a + b;
3880   return a;
3881 }
3882 OTK_INLINE OTK_HOSTDEVICE ulong2& operator+=(ulong2& a, const unsigned long b)
3883 {
3884   a = a + b;
3885   return a;
3886 }
3887 /** @} */
3888 
3889 /** subtract
3890 * @{
3891 */
3892 OTK_INLINE OTK_HOSTDEVICE ulong2 operator-(const ulong2& a, const ulong2& b)
3893 {
3894   return ::make_ulong2(a.x - b.x, a.y - b.y);
3895 }
3896 OTK_INLINE OTK_HOSTDEVICE ulong2 operator-(const ulong2& a, const unsigned long b)
3897 {
3898   return ::make_ulong2(a.x - b, a.y - b);
3899 }
3900 OTK_INLINE OTK_HOSTDEVICE ulong2 operator-(const unsigned long a, const ulong2& b)
3901 {
3902   return ::make_ulong2(a - b.x, a - b.y);
3903 }
3904 OTK_INLINE OTK_HOSTDEVICE ulong2& operator-=(ulong2& a, const ulong2& b)
3905 {
3906   a = a - b;
3907   return a;
3908 }
3909 OTK_INLINE OTK_HOSTDEVICE ulong2& operator-=(ulong2& a, const unsigned long b)
3910 {
3911   a = a - b;
3912   return a;
3913 }
3914 /** @} */
3915 
3916 /** multiply
3917 * @{
3918 */
3919 OTK_INLINE OTK_HOSTDEVICE ulong2 operator*(const ulong2& a, const ulong2& b)
3920 {
3921   return ::make_ulong2(a.x * b.x, a.y * b.y);
3922 }
3923 OTK_INLINE OTK_HOSTDEVICE ulong2 operator*(const ulong2& a, const unsigned long s)
3924 {
3925   return ::make_ulong2(a.x * s, a.y * s);
3926 }
3927 OTK_INLINE OTK_HOSTDEVICE ulong2 operator*(const unsigned long s, const ulong2& a)
3928 {
3929   return ::make_ulong2(a.x * s, a.y * s);
3930 }
3931 OTK_INLINE OTK_HOSTDEVICE ulong2& operator*=(ulong2& a, const ulong2& s)
3932 {
3933   a = a * s;
3934   return a;
3935 }
3936 OTK_INLINE OTK_HOSTDEVICE ulong2& operator*=(ulong2& a, const unsigned long s)
3937 {
3938   a = a * s;
3939   return a;
3940 }
3941 /** @} */
3942 
3943 /** divide
3944 * @{
3945 */
3946 OTK_INLINE OTK_HOSTDEVICE ulong2 operator/(const ulong2& a, const ulong2& b)
3947 {
3948   return ::make_ulong2(a.x / b.x, a.y / b.y);
3949 }
3950 OTK_INLINE OTK_HOSTDEVICE ulong2 operator/(const ulong2& a, const unsigned long s)
3951 {
3952   return ::make_ulong2(a.x / s, a.y / s);
3953 }
3954 OTK_INLINE OTK_HOSTDEVICE ulong2 operator/(const unsigned long s, const ulong2& a)
3955 {
3956   return ::make_ulong2( s/a.x, s/a.y );
3957 }
3958 OTK_INLINE OTK_HOSTDEVICE ulong2& operator/=(ulong2& a, const ulong2& s)
3959 {
3960   a = a / s;
3961   return a;
3962 }
3963 OTK_INLINE OTK_HOSTDEVICE ulong2& operator/=(ulong2& a, const unsigned long s)
3964 {
3965   a = a / s;
3966   return a;
3967 }
3968 /** @} */
3969 
3970 /** equality
3971 * @{
3972 */
3973 OTK_INLINE OTK_HOSTDEVICE bool operator==( const ulong2& a, const ulong2& b )
3974 {
3975   return a.x == b.x && a.y == b.y;
3976 }
3977 
3978 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const ulong2& a, const ulong2& b )
3979 {
3980   return !( a == b );
3981 }
3982 /** @} */
3983 
3984 namespace otk {
3985 
3986 /* ulong2 functions */
3987 /******************************************************************************/
3988 
3989 /* long long functions */
3990 /******************************************************************************/
3991 
3992 /** clamp */
3993 OTK_INLINE OTK_HOSTDEVICE long long clamp(const long long f, const long long a, const long long b)
3994 {
3995     return max(a, min(f, b));
3996 }
3997 
3998 /** If used on the device, this could place the the 'v' in local memory */
3999 OTK_INLINE OTK_HOSTDEVICE long long getByIndex(const longlong1& v, int i)
4000 {
4001     return ((long long*)(&v))[i];
4002 }
4003 
4004 /** If used on the device, this could place the the 'v' in local memory */
4005 OTK_INLINE OTK_HOSTDEVICE void setByIndex(longlong1& v, int i, long long x)
4006 {
4007     ((long long*)(&v))[i] = x;
4008 }
4009 
4010 } // namespace otk
4011 
4012 /* ulong3 operators */
4013 /******************************************************************************/
4014 
4015 /** add
4016 * @{
4017 */
4018 OTK_INLINE OTK_HOSTDEVICE ulong3 operator+( const ulong3& a, const ulong3& b )
4019 {
4020   return ::make_ulong3( a.x + b.x, a.y + b.y, a.z + b.z );
4021 }
4022 OTK_INLINE OTK_HOSTDEVICE ulong3 operator+( const ulong3& a, const unsigned long b )
4023 {
4024   return ::make_ulong3( a.x + b, a.y + b, a.z + b );
4025 }
4026 OTK_INLINE OTK_HOSTDEVICE ulong3 operator+( const unsigned long a, const ulong3& b )
4027 {
4028   return ::make_ulong3( a + b.x, a + b.y, a + b.z );
4029 }
4030 OTK_INLINE OTK_HOSTDEVICE ulong3& operator+=( ulong3& a, const ulong3& b )
4031 {
4032   a = a + b;
4033   return a;
4034 }
4035 OTK_INLINE OTK_HOSTDEVICE ulong3& operator+=( ulong3& a, const unsigned long b )
4036 {
4037   a = a + b;
4038   return a;
4039 }
4040 /** @} */
4041 
4042 /** subtract
4043 * @{
4044 */
4045 OTK_INLINE OTK_HOSTDEVICE ulong3 operator-( const ulong3& a, const ulong3& b )
4046 {
4047   return ::make_ulong3( a.x - b.x, a.y - b.y, a.z - b.z );
4048 }
4049 OTK_INLINE OTK_HOSTDEVICE ulong3 operator-( const ulong3& a, const unsigned long b )
4050 {
4051   return ::make_ulong3( a.x - b, a.y - b, a.z - b );
4052 }
4053 OTK_INLINE OTK_HOSTDEVICE ulong3 operator-( const unsigned long a, const ulong3& b )
4054 {
4055   return ::make_ulong3( a - b.x, a - b.y, a - b.z );
4056 }
4057 OTK_INLINE OTK_HOSTDEVICE ulong3& operator-=( ulong3& a, const ulong3& b )
4058 {
4059   a = a - b;
4060   return a;
4061 }
4062 OTK_INLINE OTK_HOSTDEVICE ulong3& operator-=( ulong3& a, const unsigned long b )
4063 {
4064   a = a - b;
4065   return a;
4066 }
4067 /** @} */
4068 
4069 /** multiply
4070 * @{
4071 */
4072 OTK_INLINE OTK_HOSTDEVICE ulong3 operator*(const ulong3& a, const ulong3& b)
4073 {
4074   return ::make_ulong3(a.x * b.x, a.y * b.y, a.z * b.z);
4075 }
4076 OTK_INLINE OTK_HOSTDEVICE ulong3 operator*(const ulong3& a, const unsigned long s)
4077 {
4078   return ::make_ulong3(a.x * s, a.y * s, a.z * s);
4079 }
4080 OTK_INLINE OTK_HOSTDEVICE ulong3 operator*(const unsigned long s, const ulong3& a)
4081 {
4082   return ::make_ulong3(a.x * s, a.y * s, a.z * s);
4083 }
4084 OTK_INLINE OTK_HOSTDEVICE ulong3& operator*=(ulong3& a, const ulong3& s)
4085 {
4086   a = a * s;
4087   return a;
4088 }
4089 OTK_INLINE OTK_HOSTDEVICE ulong3& operator*=(ulong3& a, const unsigned long s)
4090 {
4091   a = a * s;
4092   return a;
4093 }
4094 /** @} */
4095 
4096 /** divide
4097 * @{
4098 */
4099 OTK_INLINE OTK_HOSTDEVICE ulong3 operator/(const ulong3& a, const ulong3& b)
4100 {
4101   return ::make_ulong3(a.x / b.x, a.y / b.y, a.z / b.z);
4102 }
4103 OTK_INLINE OTK_HOSTDEVICE ulong3 operator/(const ulong3& a, const unsigned long s)
4104 {
4105   return ::make_ulong3(a.x / s, a.y / s, a.z / s);
4106 }
4107 OTK_INLINE OTK_HOSTDEVICE ulong3 operator/(const unsigned long s, const ulong3& a)
4108 {
4109   return ::make_ulong3(s /a.x, s / a.y, s / a.z);
4110 }
4111 OTK_INLINE OTK_HOSTDEVICE ulong3& operator/=(ulong3& a, const ulong3& s)
4112 {
4113   a = a / s;
4114   return a;
4115 }
4116 OTK_INLINE OTK_HOSTDEVICE ulong3& operator/=(ulong3& a, const unsigned long s)
4117 {
4118   a = a / s;
4119   return a;
4120 }
4121 /** @} */
4122 
4123 /** equality
4124 * @{
4125 */
4126 OTK_INLINE OTK_HOSTDEVICE bool operator==( const ulong3& a, const ulong3& b )
4127 {
4128   return a.x == b.x && a.y == b.y && a.z == b.z;
4129 }
4130 
4131 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const ulong3& a, const ulong3& b )
4132 {
4133   return !( a == b );
4134 }
4135 /** @} */
4136 
4137 namespace otk {
4138 
4139 /* ulong3 functions */
4140 /******************************************************************************/
4141 
4142 } // namespace otk
4143 
4144 /* longlong2 operators */
4145 /******************************************************************************/
4146 
4147 /** negate */
4148 OTK_INLINE OTK_HOSTDEVICE longlong2 operator-(const longlong2& a)
4149 {
4150     return ::make_longlong2(-a.x, -a.y);
4151 }
4152 
4153 /** add
4154 * @{
4155 */
4156 OTK_INLINE OTK_HOSTDEVICE longlong2 operator+(const longlong2& a, const longlong2& b)
4157 {
4158   return ::make_longlong2(a.x + b.x, a.y + b.y);
4159 }
4160 OTK_INLINE OTK_HOSTDEVICE longlong2 operator+(const longlong2& a, const long long b)
4161 {
4162   return ::make_longlong2(a.x + b, a.y + b);
4163 }
4164 OTK_INLINE OTK_HOSTDEVICE longlong2 operator+(const long long a, const longlong2& b)
4165 {
4166   return ::make_longlong2(a + b.x, a + b.y);
4167 }
4168 OTK_INLINE OTK_HOSTDEVICE longlong2& operator+=(longlong2& a, const longlong2& b)
4169 {
4170   a = a + b;
4171   return a;
4172 }
4173 OTK_INLINE OTK_HOSTDEVICE longlong2& operator+=(longlong2& a, const long long b)
4174 {
4175   a = a + b;
4176   return a;
4177 }
4178 /** @} */
4179 
4180 /** subtract
4181 * @{
4182 */
4183 OTK_INLINE OTK_HOSTDEVICE longlong2 operator-(const longlong2& a, const longlong2& b)
4184 {
4185   return ::make_longlong2(a.x - b.x, a.y - b.y);
4186 }
4187 OTK_INLINE OTK_HOSTDEVICE longlong2 operator-(const longlong2& a, const long long b)
4188 {
4189   return ::make_longlong2(a.x - b, a.y - b);
4190 }
4191 OTK_INLINE OTK_HOSTDEVICE longlong2 operator-(const long long a, const longlong2& b)
4192 {
4193   return ::make_longlong2(a - b.x, a - b.y);
4194 }
4195 OTK_INLINE OTK_HOSTDEVICE longlong2& operator-=(longlong2& a, const longlong2& b)
4196 {
4197   a = a - b;
4198   return a;
4199 }
4200 OTK_INLINE OTK_HOSTDEVICE longlong2& operator-=(longlong2& a, const long long b)
4201 {
4202   a = a - b;
4203   return a;
4204 }
4205 /** @} */
4206 
4207 /** multiply
4208 * @{
4209 */
4210 OTK_INLINE OTK_HOSTDEVICE longlong2 operator*(const longlong2& a, const longlong2& b)
4211 {
4212     return ::make_longlong2(a.x * b.x, a.y * b.y);
4213 }
4214 OTK_INLINE OTK_HOSTDEVICE longlong2 operator*(const longlong2& a, const long long s)
4215 {
4216     return ::make_longlong2(a.x * s, a.y * s);
4217 }
4218 OTK_INLINE OTK_HOSTDEVICE longlong2 operator*(const long long s, const longlong2& a)
4219 {
4220     return ::make_longlong2(a.x * s, a.y * s);
4221 }
4222 OTK_INLINE OTK_HOSTDEVICE longlong2& operator*=(longlong2& a, const longlong2& s)
4223 {
4224     a = a * s;
4225     return a;
4226 }
4227 OTK_INLINE OTK_HOSTDEVICE longlong2& operator*=(longlong2& a, const long long s)
4228 {
4229     a = a * s;
4230     return a;
4231 }
4232 /** @} */
4233 
4234 /** divide
4235 * @{
4236 */
4237 OTK_INLINE OTK_HOSTDEVICE longlong2 operator/(const longlong2& a, const longlong2& b)
4238 {
4239   return ::make_longlong2(a.x / b.x, a.y / b.y);
4240 }
4241 OTK_INLINE OTK_HOSTDEVICE longlong2 operator/(const longlong2& a, const long long s)
4242 {
4243   return ::make_longlong2(a.x / s, a.y / s);
4244 }
4245 OTK_INLINE OTK_HOSTDEVICE longlong2 operator/(const long long s, const longlong2& a)
4246 {
4247   return ::make_longlong2( s/a.x, s/a.y );
4248 }
4249 OTK_INLINE OTK_HOSTDEVICE longlong2& operator/=(longlong2& a, const longlong2& s)
4250 {
4251   a = a / s;
4252   return a;
4253 }
4254 OTK_INLINE OTK_HOSTDEVICE longlong2& operator/=(longlong2& a, const long long s)
4255 {
4256   a = a / s;
4257   return a;
4258 }
4259 /** @} */
4260 
4261 /** equality
4262 * @{
4263 */
4264 OTK_INLINE OTK_HOSTDEVICE bool operator==(const longlong2& a, const longlong2& b)
4265 {
4266     return a.x == b.x && a.y == b.y;
4267 }
4268 
4269 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const longlong2& a, const longlong2& b)
4270 {
4271     return a.x != b.x || a.y != b.y;
4272 }
4273 /** @} */
4274 
4275 namespace otk {
4276 
4277 /* longlong2 functions */
4278 /******************************************************************************/
4279 
4280 /** additional constructors
4281 * @{
4282 */
4283 OTK_INLINE OTK_HOSTDEVICE longlong2 make_longlong2(const long long s)
4284 {
4285     return ::make_longlong2(s, s);
4286 }
4287 OTK_INLINE OTK_HOSTDEVICE longlong2 make_longlong2(const float2& a)
4288 {
4289     return ::make_longlong2(int(a.x), int(a.y));
4290 }
4291 /** @} */
4292 
4293 /** min */
4294 OTK_INLINE OTK_HOSTDEVICE longlong2 min(const longlong2& a, const longlong2& b)
4295 {
4296     return ::make_longlong2(min(a.x, b.x), min(a.y, b.y));
4297 }
4298 
4299 /** max */
4300 OTK_INLINE OTK_HOSTDEVICE longlong2 max(const longlong2& a, const longlong2& b)
4301 {
4302     return ::make_longlong2(max(a.x, b.x), max(a.y, b.y));
4303 }
4304 
4305 /** clamp
4306 * @{
4307 */
4308 OTK_INLINE OTK_HOSTDEVICE longlong2 clamp(const longlong2& v, const long long a, const long long b)
4309 {
4310     return ::make_longlong2(clamp(v.x, a, b), clamp(v.y, a, b));
4311 }
4312 
4313 OTK_INLINE OTK_HOSTDEVICE longlong2 clamp(const longlong2& v, const longlong2& a, const longlong2& b)
4314 {
4315     return ::make_longlong2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
4316 }
4317 /** @} */
4318 
4319 /** If used on the device, this could place the the 'v' in local memory */
4320 OTK_INLINE OTK_HOSTDEVICE long long getByIndex(const longlong2& v, int i)
4321 {
4322     return ((long long*)(&v))[i];
4323 }
4324 
4325 /** If used on the device, this could place the the 'v' in local memory */
4326 OTK_INLINE OTK_HOSTDEVICE void setByIndex(longlong2& v, int i, long long x)
4327 {
4328     ((long long*)(&v))[i] = x;
4329 }
4330 
4331 } // namespace otk
4332 
4333 /* longlong3 operators */
4334 /******************************************************************************/
4335 
4336 /** negate */
4337 OTK_INLINE OTK_HOSTDEVICE longlong3 operator-( const longlong3& a )
4338 {
4339   return ::make_longlong3( -a.x, -a.y, -a.z );
4340 }
4341 
4342 /** add
4343 * @{
4344 */
4345 OTK_INLINE OTK_HOSTDEVICE longlong3 operator+( const longlong3& a, const longlong3& b )
4346 {
4347   return ::make_longlong3( a.x + b.x, a.y + b.y, a.z + b.z );
4348 }
4349 OTK_INLINE OTK_HOSTDEVICE longlong3 operator+( const longlong3& a, const long long b )
4350 {
4351   return ::make_longlong3( a.x + b, a.y + b, a.z + b );
4352 }
4353 OTK_INLINE OTK_HOSTDEVICE longlong3 operator+( const long long a, const longlong3& b )
4354 {
4355   return ::make_longlong3( a + b.x, a + b.y, a + b.z );
4356 }
4357 OTK_INLINE OTK_HOSTDEVICE longlong3& operator+=( longlong3& a, const longlong3& b )
4358 {
4359   a = a + b;
4360   return a;
4361 }
4362 OTK_INLINE OTK_HOSTDEVICE longlong3& operator+=( longlong3& a, const long long b )
4363 {
4364   a = a + b;
4365   return a;
4366 }
4367 /** @} */
4368 
4369 /** subtract
4370 * @{
4371 */
4372 OTK_INLINE OTK_HOSTDEVICE longlong3 operator-( const longlong3& a, const longlong3& b )
4373 {
4374   return ::make_longlong3( a.x - b.x, a.y - b.y, a.z - b.z );
4375 }
4376 OTK_INLINE OTK_HOSTDEVICE longlong3 operator-( const longlong3& a, const long long b )
4377 {
4378   return ::make_longlong3( a.x - b, a.y - b, a.z - b );
4379 }
4380 OTK_INLINE OTK_HOSTDEVICE longlong3 operator-( const long long a, const longlong3& b )
4381 {
4382   return ::make_longlong3( a - b.x, a - b.y, a - b.z );
4383 }
4384 OTK_INLINE OTK_HOSTDEVICE longlong3& operator-=( longlong3& a, const longlong3& b )
4385 {
4386   a = a - b;
4387   return a;
4388 }
4389 OTK_INLINE OTK_HOSTDEVICE longlong3& operator-=( longlong3& a, const long long b )
4390 {
4391   a = a - b;
4392   return a;
4393 }
4394 /** @} */
4395 
4396 /** multiply
4397 * @{
4398 */
4399 OTK_INLINE OTK_HOSTDEVICE longlong3 operator*(const longlong3& a, const longlong3& b)
4400 {
4401   return ::make_longlong3(a.x * b.x, a.y * b.y, a.z * b.z);
4402 }
4403 OTK_INLINE OTK_HOSTDEVICE longlong3 operator*(const longlong3& a, const long long s)
4404 {
4405   return ::make_longlong3(a.x * s, a.y * s, a.z * s);
4406 }
4407 OTK_INLINE OTK_HOSTDEVICE longlong3 operator*(const long long s, const longlong3& a)
4408 {
4409   return ::make_longlong3(a.x * s, a.y * s, a.z * s);
4410 }
4411 OTK_INLINE OTK_HOSTDEVICE longlong3& operator*=(longlong3& a, const longlong3& s)
4412 {
4413   a = a * s;
4414   return a;
4415 }
4416 OTK_INLINE OTK_HOSTDEVICE longlong3& operator*=(longlong3& a, const long long s)
4417 {
4418   a = a * s;
4419   return a;
4420 }
4421 /** @} */
4422 
4423 /** divide
4424 * @{
4425 */
4426 OTK_INLINE OTK_HOSTDEVICE longlong3 operator/(const longlong3& a, const longlong3& b)
4427 {
4428   return ::make_longlong3(a.x / b.x, a.y / b.y, a.z / b.z);
4429 }
4430 OTK_INLINE OTK_HOSTDEVICE longlong3 operator/(const longlong3& a, const long long s)
4431 {
4432   return ::make_longlong3(a.x / s, a.y / s, a.z / s);
4433 }
4434 OTK_INLINE OTK_HOSTDEVICE longlong3 operator/(const long long s, const longlong3& a)
4435 {
4436   return ::make_longlong3(s /a.x, s / a.y, s / a.z);
4437 }
4438 OTK_INLINE OTK_HOSTDEVICE longlong3& operator/=(longlong3& a, const longlong3& s)
4439 {
4440   a = a / s;
4441   return a;
4442 }
4443 OTK_INLINE OTK_HOSTDEVICE longlong3& operator/=(longlong3& a, const long long s)
4444 {
4445   a = a / s;
4446   return a;
4447 }
4448 /** @} */
4449 
4450 /** equality
4451 * @{
4452 */
4453 OTK_INLINE OTK_HOSTDEVICE bool operator==( const longlong3& a, const longlong3& b )
4454 {
4455   return a.x == b.x && a.y == b.y && a.z == b.z;
4456 }
4457 
4458 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const longlong3& a, const longlong3& b )
4459 {
4460   return !( a == b );
4461 }
4462 /** @} */
4463 
4464 namespace otk {
4465 
4466 /* longlong3 functions */
4467 /******************************************************************************/
4468 
4469 /** additional constructors
4470 * @{
4471 */
4472 OTK_INLINE OTK_HOSTDEVICE longlong3 make_longlong3(const long long s)
4473 {
4474     return ::make_longlong3(s, s, s);
4475 }
4476 OTK_INLINE OTK_HOSTDEVICE longlong3 make_longlong3(const float3& a)
4477 {
4478     return ::make_longlong3( (long long)a.x, (long long)a.y, (long long)a.z);
4479 }
4480 /** @} */
4481 
4482 /** min */
4483 OTK_INLINE OTK_HOSTDEVICE longlong3 min(const longlong3& a, const longlong3& b)
4484 {
4485     return ::make_longlong3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
4486 }
4487 
4488 /** max */
4489 OTK_INLINE OTK_HOSTDEVICE longlong3 max(const longlong3& a, const longlong3& b)
4490 {
4491     return ::make_longlong3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
4492 }
4493 
4494 /** clamp
4495 * @{
4496 */
4497 OTK_INLINE OTK_HOSTDEVICE longlong3 clamp(const longlong3& v, const long long a, const long long b)
4498 {
4499     return ::make_longlong3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
4500 }
4501 
4502 OTK_INLINE OTK_HOSTDEVICE longlong3 clamp(const longlong3& v, const longlong3& a, const longlong3& b)
4503 {
4504     return ::make_longlong3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
4505 }
4506 /** @} */
4507 
4508 /** If used on the device, this could place the the 'v' in local memory */
4509 OTK_INLINE OTK_HOSTDEVICE long long getByIndex(const longlong3& v, int i)
4510 {
4511     return ((long long*)(&v))[i];
4512 }
4513 
4514 /** If used on the device, this could place the the 'v' in local memory */
4515 OTK_INLINE OTK_HOSTDEVICE void setByIndex(longlong3& v, int i, int x)
4516 {
4517     ((long long*)(&v))[i] = x;
4518 }
4519 
4520 } // namespace otk
4521 
4522 #if CUDART_VERSION >= 13000
4523 /* longlong4_16a operators */
4524 /******************************************************************************/
4525 
4526 /** negate */
4527 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator-(const longlong4_16a& a)
4528 {
4529     return make_longlong4_16a(-a.x, -a.y, -a.z, -a.w);
4530 }
4531 
4532 /** add
4533 * @{
4534 */
4535 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator+(const longlong4_16a& a, const longlong4_16a& b)
4536 {
4537     return make_longlong4_16a(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
4538 }
4539 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator+(const long long a, const longlong4_16a& b)
4540 {
4541     return make_longlong4_16a(a + b.x, a + b.y, a + b.z, a + b.w);
4542 }
4543 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator+(const longlong4_16a& a, const long long b)
4544 {
4545     return make_longlong4_16a(a.x + b, a.y + b, a.z + b, a.w + b);
4546 }
4547 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator+=(longlong4_16a& a, const longlong4_16a& b)
4548 {
4549     a = a + b;
4550     return a;
4551 }
4552 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator+=(longlong4_16a& a, const long long b)
4553 {
4554     a = a + b;
4555     return a;
4556 }
4557 /** @} */
4558 
4559 /** subtract
4560 * @{
4561 */
4562 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator-(const longlong4_16a& a, const longlong4_16a& b)
4563 {
4564     return make_longlong4_16a(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
4565 }
4566 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator-(const long long a, const longlong4_16a& b)
4567 {
4568     return make_longlong4_16a(a - b.x, a - b.y, a - b.z, a - b.w);
4569 }
4570 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator-(const longlong4_16a& a, const long long b)
4571 {
4572     return make_longlong4_16a(a.x - b, a.y - b, a.z - b, a.w - b);
4573 }
4574 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator-=(longlong4_16a& a, const longlong4_16a& b)
4575 {
4576     a = a - b;
4577     return a;
4578 }
4579 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator-=(longlong4_16a& a, const long long b)
4580 {
4581     a = a - b;
4582     return a;
4583 }
4584 /** @} */
4585 
4586 /** multiply
4587 * @{
4588 */
4589 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator*(const longlong4_16a& a, const longlong4_16a& b)
4590 {
4591     return make_longlong4_16a(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
4592 }
4593 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator*(const longlong4_16a& a, const long long s)
4594 {
4595     return make_longlong4_16a(a.x * s, a.y * s, a.z * s, a.w * s);
4596 }
4597 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator*(const long long s, const longlong4_16a& a)
4598 {
4599     return make_longlong4_16a(a.x * s, a.y * s, a.z * s, a.w * s);
4600 }
4601 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator*=(longlong4_16a& a, const longlong4_16a& s)
4602 {
4603     a = a * s;
4604     return a;
4605 }
4606 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator*=(longlong4_16a& a, const long long s)
4607 {
4608     a = a * s;
4609     return a;
4610 }
4611 /** @} */
4612 
4613 /** divide
4614 * @{
4615 */
4616 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator/(const longlong4_16a& a, const longlong4_16a& b)
4617 {
4618     return make_longlong4_16a(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
4619 }
4620 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator/(const longlong4_16a& a, const long long s)
4621 {
4622     return make_longlong4_16a(a.x / s, a.y / s, a.z / s, a.w / s);
4623 }
4624 OTK_INLINE OTK_HOSTDEVICE longlong4_16a operator/(const long long s, const longlong4_16a& a)
4625 {
4626     return make_longlong4_16a(s / a.x, s / a.y, s / a.z, s / a.w);
4627 }
4628 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator/=(longlong4_16a& a, const longlong4_16a& s)
4629 {
4630     a = a / s;
4631     return a;
4632 }
4633 OTK_INLINE OTK_HOSTDEVICE longlong4_16a& operator/=(longlong4_16a& a, const long long s)
4634 {
4635     a = a / s;
4636     return a;
4637 }
4638 /** @} */
4639 
4640 /** equality
4641 * @{
4642 */
4643 OTK_INLINE OTK_HOSTDEVICE bool operator==(const longlong4_16a& a, const longlong4_16a& b)
4644 {
4645     return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
4646 }
4647 
4648 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const longlong4_16a& a, const longlong4_16a& b)
4649 {
4650     return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
4651 }
4652 /** @} */
4653 
4654 namespace otk {
4655 
4656 /* longlong4_16a functions */
4657 /******************************************************************************/
4658 
4659 /** additional constructors
4660 * @{
4661 */
4662 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const long long x, const long long y, const long long z, const long long w)
4663 {
4664     return ::make_longlong4_16a(x, y, z, w);
4665 }
4666 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const long long s)
4667 {
4668     return make_longlong4_16a(s, s, s, s);
4669 }
4670 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const float4& a)
4671 {
4672     return make_longlong4_16a((long long)a.x, (long long)a.y, (long long)a.z, (long long)a.w);
4673 }
4674 /** @} */
4675 
4676 /** min */
4677 OTK_INLINE OTK_HOSTDEVICE longlong4_16a min(const longlong4_16a& a, const longlong4_16a& b)
4678 {
4679     return make_longlong4_16a(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
4680 }
4681 
4682 /** max */
4683 OTK_INLINE OTK_HOSTDEVICE longlong4_16a max(const longlong4_16a& a, const longlong4_16a& b)
4684 {
4685     return make_longlong4_16a(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
4686 }
4687 
4688 /** clamp
4689 * @{
4690 */
4691 OTK_INLINE OTK_HOSTDEVICE longlong4_16a clamp(const longlong4_16a& v, const long long a, const long long b)
4692 {
4693     return make_longlong4_16a(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
4694 }
4695 
4696 OTK_INLINE OTK_HOSTDEVICE longlong4_16a clamp(const longlong4_16a& v, const longlong4_16a& a, const longlong4_16a& b)
4697 {
4698     return make_longlong4_16a(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));
4699 }
4700 /** @} */
4701 
4702 /** If used on the device, this could place the the 'v' in local memory */
4703 OTK_INLINE OTK_HOSTDEVICE long long getByIndex(const longlong4_16a& v, int i)
4704 {
4705     return ((long long*)(&v))[i];
4706 }
4707 
4708 /** If used on the device, this could place the the 'v' in local memory */
4709 OTK_INLINE OTK_HOSTDEVICE void setByIndex(longlong4_16a& v, int i, long long x)
4710 {
4711     ((long long*)(&v))[i] = x;
4712 }
4713 
4714 } // namespace otk
4715 #endif // CUDART_VERSION >= 13000
4716 
4717 /* ulonglong operators */
4718 /******************************************************************************/
4719 
4720 namespace otk {
4721 
4722 /* ulonglong functions */
4723 /******************************************************************************/
4724 
4725 /** clamp */
4726 OTK_INLINE OTK_HOSTDEVICE unsigned long long clamp(const unsigned long long f, const unsigned long long a, const unsigned long long b)
4727 {
4728     return max(a, min(f, b));
4729 }
4730 
4731 /** If used on the device, this could place the the 'v' in local memory */
4732 OTK_INLINE OTK_HOSTDEVICE unsigned long long getByIndex(const ulonglong1& v, unsigned int i)
4733 {
4734     return ((unsigned long long*)(&v))[i];
4735 }
4736 
4737 /** If used on the device, this could place the the 'v' in local memory */
4738 OTK_INLINE OTK_HOSTDEVICE void setByIndex(ulonglong1& v, int i, unsigned long long x)
4739 {
4740     ((unsigned long long*)(&v))[i] = x;
4741 }
4742 
4743 } // namespace otk
4744 
4745 /* ulonglong2 operators */
4746 /******************************************************************************/
4747 
4748 /** add
4749 * @{
4750 */
4751 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator+(const ulonglong2& a, const ulonglong2& b)
4752 {
4753   return ::make_ulonglong2(a.x + b.x, a.y + b.y);
4754 }
4755 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator+(const ulonglong2& a, const unsigned long long b)
4756 {
4757   return ::make_ulonglong2(a.x + b, a.y + b);
4758 }
4759 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator+(const unsigned long long a, const ulonglong2& b)
4760 {
4761   return ::make_ulonglong2(a + b.x, a + b.y);
4762 }
4763 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator+=(ulonglong2& a, const ulonglong2& b)
4764 {
4765   a = a + b;
4766   return a;
4767 }
4768 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator+=(ulonglong2& a, const unsigned long long b)
4769 {
4770   a = a + b;
4771   return a;
4772 }
4773 /** @} */
4774 
4775 /** subtract
4776 * @{
4777 */
4778 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator-(const ulonglong2& a, const ulonglong2& b)
4779 {
4780   return ::make_ulonglong2(a.x - b.x, a.y - b.y);
4781 }
4782 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator-(const ulonglong2& a, const unsigned long long b)
4783 {
4784   return ::make_ulonglong2(a.x - b, a.y - b);
4785 }
4786 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator-(const unsigned long long a, const ulonglong2& b)
4787 {
4788   return ::make_ulonglong2(a - b.x, a - b.y);
4789 }
4790 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator-=(ulonglong2& a, const ulonglong2& b)
4791 {
4792   a = a - b;
4793   return a;
4794 }
4795 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator-=(ulonglong2& a, const unsigned long long b)
4796 {
4797   a = a - b;
4798   return a;
4799 }
4800 /** @} */
4801 
4802 /** multiply
4803 * @{
4804 */
4805 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator*(const ulonglong2& a, const ulonglong2& b)
4806 {
4807     return ::make_ulonglong2(a.x * b.x, a.y * b.y);
4808 }
4809 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator*(const ulonglong2& a, const unsigned long long s)
4810 {
4811     return ::make_ulonglong2(a.x * s, a.y * s);
4812 }
4813 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator*(const unsigned long long s, const ulonglong2& a)
4814 {
4815     return ::make_ulonglong2(a.x * s, a.y * s);
4816 }
4817 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator*=(ulonglong2& a, const ulonglong2& s)
4818 {
4819     a = a * s;
4820     return a;
4821 }
4822 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator*=(ulonglong2& a, const unsigned long long s)
4823 {
4824     a = a * s;
4825     return a;
4826 }
4827 /** @} */
4828 
4829 /** divide
4830 * @{
4831 */
4832 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator/(const ulonglong2& a, const ulonglong2& b)
4833 {
4834   return ::make_ulonglong2(a.x / b.x, a.y / b.y);
4835 }
4836 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator/(const ulonglong2& a, const unsigned long long s)
4837 {
4838   return ::make_ulonglong2(a.x / s, a.y / s);
4839 }
4840 OTK_INLINE OTK_HOSTDEVICE ulonglong2 operator/(const unsigned long long s, const ulonglong2& a)
4841 {
4842   return ::make_ulonglong2( s/a.x, s/a.y );
4843 }
4844 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator/=(ulonglong2& a, const ulonglong2& s)
4845 {
4846   a = a / s;
4847   return a;
4848 }
4849 OTK_INLINE OTK_HOSTDEVICE ulonglong2& operator/=(ulonglong2& a, const unsigned long long s)
4850 {
4851   a = a / s;
4852   return a;
4853 }
4854 /** @} */
4855 
4856 /** equality
4857 * @{
4858 */
4859 OTK_INLINE OTK_HOSTDEVICE bool operator==(const ulonglong2& a, const ulonglong2& b)
4860 {
4861     return a.x == b.x && a.y == b.y;
4862 }
4863 
4864 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const ulonglong2& a, const ulonglong2& b)
4865 {
4866     return a.x != b.x || a.y != b.y;
4867 }
4868 /** @} */
4869 
4870 namespace otk {
4871 
4872 /* ulonglong2 functions */
4873 /******************************************************************************/
4874 
4875 /** additional constructors
4876 * @{
4877 */
4878 OTK_INLINE OTK_HOSTDEVICE ulonglong2 make_ulonglong2(const unsigned long long s)
4879 {
4880     return ::make_ulonglong2(s, s);
4881 }
4882 OTK_INLINE OTK_HOSTDEVICE ulonglong2 make_ulonglong2(const float2& a)
4883 {
4884     return ::make_ulonglong2((unsigned long long)a.x, (unsigned long long)a.y);
4885 }
4886 /** @} */
4887 
4888 /** min */
4889 OTK_INLINE OTK_HOSTDEVICE ulonglong2 min(const ulonglong2& a, const ulonglong2& b)
4890 {
4891     return ::make_ulonglong2(min(a.x, b.x), min(a.y, b.y));
4892 }
4893 
4894 /** max */
4895 OTK_INLINE OTK_HOSTDEVICE ulonglong2 max(const ulonglong2& a, const ulonglong2& b)
4896 {
4897     return ::make_ulonglong2(max(a.x, b.x), max(a.y, b.y));
4898 }
4899 
4900 /** clamp
4901 * @{
4902 */
4903 OTK_INLINE OTK_HOSTDEVICE ulonglong2 clamp(const ulonglong2& v, const unsigned long long a, const unsigned long long b)
4904 {
4905     return ::make_ulonglong2(clamp(v.x, a, b), clamp(v.y, a, b));
4906 }
4907 
4908 OTK_INLINE OTK_HOSTDEVICE ulonglong2 clamp(const ulonglong2& v, const ulonglong2& a, const ulonglong2& b)
4909 {
4910     return ::make_ulonglong2(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y));
4911 }
4912 /** @} */
4913 
4914 /** If used on the device, this could place the the 'v' in local memory */
4915 OTK_INLINE OTK_HOSTDEVICE unsigned long long getByIndex(const ulonglong2& v, unsigned int i)
4916 {
4917     return ((unsigned long long*)(&v))[i];
4918 }
4919 
4920 /** If used on the device, this could place the the 'v' in local memory */
4921 OTK_INLINE OTK_HOSTDEVICE void setByIndex(ulonglong2& v, int i, unsigned long long x)
4922 {
4923     ((unsigned long long*)(&v))[i] = x;
4924 }
4925 
4926 } // namespace otk
4927 
4928 /* ulonglong3 operators */
4929 /******************************************************************************/
4930 
4931 /** add
4932 * @{
4933 */
4934 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator+( const ulonglong3& a, const ulonglong3& b )
4935 {
4936   return ::make_ulonglong3( a.x + b.x, a.y + b.y, a.z + b.z );
4937 }
4938 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator+( const ulonglong3& a, const unsigned long long b )
4939 {
4940   return ::make_ulonglong3( a.x + b, a.y + b, a.z + b );
4941 }
4942 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator+( const unsigned long long a, const ulonglong3& b )
4943 {
4944   return ::make_ulonglong3( a + b.x, a + b.y, a + b.z );
4945 }
4946 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator+=( ulonglong3& a, const ulonglong3& b )
4947 {
4948   a = a + b;
4949   return a;
4950 }
4951 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator+=( ulonglong3& a, const unsigned long long b )
4952 {
4953   a = a + b;
4954   return a;
4955 }
4956 /** @} */
4957 
4958 /** subtract
4959 * @{
4960 */
4961 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator-( const ulonglong3& a, const ulonglong3& b )
4962 {
4963   return ::make_ulonglong3( a.x - b.x, a.y - b.y, a.z - b.z );
4964 }
4965 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator-( const ulonglong3& a, const unsigned long long b )
4966 {
4967   return ::make_ulonglong3( a.x - b, a.y - b, a.z - b );
4968 }
4969 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator-( const unsigned long long a, const ulonglong3& b )
4970 {
4971   return ::make_ulonglong3( a - b.x, a - b.y, a - b.z );
4972 }
4973 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator-=( ulonglong3& a, const ulonglong3& b )
4974 {
4975   a = a - b;
4976   return a;
4977 }
4978 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator-=( ulonglong3& a, const unsigned long long b )
4979 {
4980   a = a - b;
4981   return a;
4982 }
4983 /** @} */
4984 
4985 /** multiply
4986 * @{
4987 */
4988 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator*(const ulonglong3& a, const ulonglong3& b)
4989 {
4990   return ::make_ulonglong3(a.x * b.x, a.y * b.y, a.z * b.z);
4991 }
4992 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator*(const ulonglong3& a, const unsigned long long s)
4993 {
4994   return ::make_ulonglong3(a.x * s, a.y * s, a.z * s);
4995 }
4996 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator*(const unsigned long long s, const ulonglong3& a)
4997 {
4998   return ::make_ulonglong3(a.x * s, a.y * s, a.z * s);
4999 }
5000 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator*=(ulonglong3& a, const ulonglong3& s)
5001 {
5002   a = a * s;
5003   return a;
5004 }
5005 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator*=(ulonglong3& a, const unsigned long long s)
5006 {
5007   a = a * s;
5008   return a;
5009 }
5010 /** @} */
5011 
5012 /** divide
5013 * @{
5014 */
5015 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator/(const ulonglong3& a, const ulonglong3& b)
5016 {
5017   return ::make_ulonglong3(a.x / b.x, a.y / b.y, a.z / b.z);
5018 }
5019 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator/(const ulonglong3& a, const unsigned long long s)
5020 {
5021   return ::make_ulonglong3(a.x / s, a.y / s, a.z / s);
5022 }
5023 OTK_INLINE OTK_HOSTDEVICE ulonglong3 operator/(const unsigned long long s, const ulonglong3& a)
5024 {
5025   return ::make_ulonglong3(s /a.x, s / a.y, s / a.z);
5026 }
5027 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator/=(ulonglong3& a, const ulonglong3& s)
5028 {
5029   a = a / s;
5030   return a;
5031 }
5032 OTK_INLINE OTK_HOSTDEVICE ulonglong3& operator/=(ulonglong3& a, const unsigned long long s)
5033 {
5034   a = a / s;
5035   return a;
5036 }
5037 /** @} */
5038 
5039 /** equality
5040 * @{
5041 */
5042 OTK_INLINE OTK_HOSTDEVICE bool operator==( const ulonglong3& a, const ulonglong3& b )
5043 {
5044   return a.x == b.x && a.y == b.y && a.z == b.z;
5045 }
5046 
5047 OTK_INLINE OTK_HOSTDEVICE bool operator!=( const ulonglong3& a, const ulonglong3& b )
5048 {
5049   return !( a == b );
5050 }
5051 /** @} */
5052 
5053 /* ulonglong3 functions */
5054 /******************************************************************************/
5055 
5056 namespace otk {
5057 
5058 /** additional constructors
5059 * @{
5060 */
5061 OTK_INLINE OTK_HOSTDEVICE ulonglong3 make_ulonglong3(const unsigned long long s)
5062 {
5063     return ::make_ulonglong3(s, s, s);
5064 }
5065 OTK_INLINE OTK_HOSTDEVICE ulonglong3 make_ulonglong3(const float3& a)
5066 {
5067     return ::make_ulonglong3((unsigned long long)a.x, (unsigned long long)a.y, (unsigned long long)a.z);
5068 }
5069 /** @} */
5070 
5071 /** min */
5072 OTK_INLINE OTK_HOSTDEVICE ulonglong3 min(const ulonglong3& a, const ulonglong3& b)
5073 {
5074     return ::make_ulonglong3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z));
5075 }
5076 
5077 /** max */
5078 OTK_INLINE OTK_HOSTDEVICE ulonglong3 max(const ulonglong3& a, const ulonglong3& b)
5079 {
5080     return ::make_ulonglong3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z));
5081 }
5082 
5083 /** clamp
5084 * @{
5085 */
5086 OTK_INLINE OTK_HOSTDEVICE ulonglong3 clamp(const ulonglong3& v, const unsigned long long a, const unsigned long long b)
5087 {
5088     return ::make_ulonglong3(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b));
5089 }
5090 
5091 OTK_INLINE OTK_HOSTDEVICE ulonglong3 clamp(const ulonglong3& v, const ulonglong3& a, const ulonglong3& b)
5092 {
5093     return ::make_ulonglong3(clamp(v.x, a.x, b.x), clamp(v.y, a.y, b.y), clamp(v.z, a.z, b.z));
5094 }
5095 /** @} */
5096 
5097 /** If used on the device, this could place the the 'v' in local memory
5098 */
5099 OTK_INLINE OTK_HOSTDEVICE unsigned long long getByIndex(const ulonglong3& v, unsigned int i)
5100 {
5101     return ((unsigned long long*)(&v))[i];
5102 }
5103 
5104 /** If used on the device, this could place the the 'v' in local memory
5105 */
5106 OTK_INLINE OTK_HOSTDEVICE void setByIndex(ulonglong3& v, int i, unsigned long long x)
5107 {
5108     ((unsigned long long*)(&v))[i] = x;
5109 }
5110 
5111 } // namespace otk
5112 
5113 #if CUDART_VERSION >= 13000
5114 /* ulonglong4_16a operators */
5115 /******************************************************************************/
5116 
5117 /** add
5118 * @{
5119 */
5120 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator+(const ulonglong4_16a& a, const ulonglong4_16a& b)
5121 {
5122     return make_ulonglong4_16a(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w);
5123 }
5124 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator+(const unsigned long long a, const ulonglong4_16a& b)
5125 {
5126     return make_ulonglong4_16a(a + b.x, a + b.y, a + b.z, a + b.w);
5127 }
5128 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator+(const ulonglong4_16a& a, const unsigned long long b)
5129 {
5130     return make_ulonglong4_16a(a.x + b, a.y + b, a.z + b, a.w + b);
5131 }
5132 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator+=(ulonglong4_16a& a, const ulonglong4_16a& b)
5133 {
5134     a = a + b;
5135     return a;
5136 }
5137 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator+=(ulonglong4_16a& a, const unsigned long long b)
5138 {
5139     a = a + b;
5140     return a;
5141 }
5142 /** @} */
5143 
5144 /** subtract
5145 * @{
5146 */
5147 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator-(const ulonglong4_16a& a, const ulonglong4_16a& b)
5148 {
5149     return make_ulonglong4_16a(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w);
5150 }
5151 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator-(const unsigned long long a, const ulonglong4_16a& b)
5152 {
5153     return make_ulonglong4_16a(a - b.x, a - b.y, a - b.z, a - b.w);
5154 }
5155 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator-(const ulonglong4_16a& a, const unsigned long long b)
5156 {
5157     return make_ulonglong4_16a(a.x - b, a.y - b, a.z - b, a.w - b);
5158 }
5159 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator-=(ulonglong4_16a& a, const ulonglong4_16a& b)
5160 {
5161     a = a - b;
5162     return a;
5163 }
5164 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator-=(ulonglong4_16a& a, const unsigned long long b)
5165 {
5166     a = a - b;
5167     return a;
5168 }
5169 /** @} */
5170 
5171 /** multiply
5172 * @{
5173 */
5174 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator*(const ulonglong4_16a& a, const ulonglong4_16a& b)
5175 {
5176     return make_ulonglong4_16a(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
5177 }
5178 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator*(const ulonglong4_16a& a, const unsigned long long s)
5179 {
5180     return make_ulonglong4_16a(a.x * s, a.y * s, a.z * s, a.w * s);
5181 }
5182 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator*(const unsigned long long s, const ulonglong4_16a& a)
5183 {
5184     return make_ulonglong4_16a(a.x * s, a.y * s, a.z * s, a.w * s);
5185 }
5186 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator*=(ulonglong4_16a& a, const ulonglong4_16a& s)
5187 {
5188     a = a * s;
5189     return a;
5190 }
5191 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator*=(ulonglong4_16a& a, const unsigned long long s)
5192 {
5193     a = a * s;
5194     return a;
5195 }
5196 /** @} */
5197 
5198 /** divide
5199 * @{
5200 */
5201 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator/(const ulonglong4_16a& a, const ulonglong4_16a& b)
5202 {
5203     return make_ulonglong4_16a(a.x / b.x, a.y / b.y, a.z / b.z, a.w / b.w);
5204 }
5205 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator/(const ulonglong4_16a& a, const unsigned long long s)
5206 {
5207     return make_ulonglong4_16a(a.x / s, a.y / s, a.z / s, a.w / s);
5208 }
5209 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a operator/(const unsigned long long s, const ulonglong4_16a& a)
5210 {
5211     return make_ulonglong4_16a(s / a.x, s / a.y, s / a.z, s / a.w);
5212 }
5213 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator/=(ulonglong4_16a& a, const ulonglong4_16a& s)
5214 {
5215     a = a / s;
5216     return a;
5217 }
5218 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a& operator/=(ulonglong4_16a& a, const unsigned long long s)
5219 {
5220     a = a / s;
5221     return a;
5222 }
5223 /** @} */
5224 
5225 /** equality
5226 * @{
5227 */
5228 OTK_INLINE OTK_HOSTDEVICE bool operator==(const ulonglong4_16a& a, const ulonglong4_16a& b)
5229 {
5230     return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
5231 }
5232 
5233 OTK_INLINE OTK_HOSTDEVICE bool operator!=(const ulonglong4_16a& a, const ulonglong4_16a& b)
5234 {
5235     return a.x != b.x || a.y != b.y || a.z != b.z || a.w != b.w;
5236 }
5237 /** @} */
5238 
5239 namespace otk {
5240 
5241 /* ulonglong4_16a functions */
5242 /******************************************************************************/
5243 
5244 /** additional constructors
5245 * @{
5246 */
5247 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const unsigned long long x, const unsigned long long y, const unsigned long long z, const unsigned long long w)
5248 {
5249     return ::make_ulonglong4_16a(x, y, z, w);
5250 }
5251 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const unsigned long long s)
5252 {
5253     return make_ulonglong4_16a(s, s, s, s);
5254 }
5255 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const float4& a)
5256 {
5257     return make_ulonglong4_16a((unsigned long long)a.x, (unsigned long long)a.y, (unsigned long long)a.z, (unsigned long long)a.w);
5258 }
5259 /** @} */
5260 
5261 /** min
5262 * @{
5263 */
5264 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a min(const ulonglong4_16a& a, const ulonglong4_16a& b)
5265 {
5266     return make_ulonglong4_16a(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w));
5267 }
5268 /** @} */
5269 
5270 /** max
5271 * @{
5272 */
5273 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a max(const ulonglong4_16a& a, const ulonglong4_16a& b)
5274 {
5275     return make_ulonglong4_16a(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w));
5276 }
5277 /** @} */
5278 
5279 /** clamp
5280 * @{
5281 */
5282 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a clamp(const ulonglong4_16a& v, const unsigned long long a, const unsigned long long b)
5283 {
5284     return make_ulonglong4_16a(clamp(v.x, a, b), clamp(v.y, a, b), clamp(v.z, a, b), clamp(v.w, a, b));
5285 }
5286 
5287 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a clamp(const ulonglong4_16a& v, const ulonglong4_16a& a, const ulonglong4_16a& b)
5288 {
5289     return make_ulonglong4_16a(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));
5290 }
5291 /** @} */
5292 
5293 
5294 
5295 /******************************************************************************/
5296 
5297 /** Narrowing functions
5298 * @{
5299 */
5300 OTK_INLINE OTK_HOSTDEVICE int2 make_int2(const int3& v0) { return ::make_int2( v0.x, v0.y ); }
5301 OTK_INLINE OTK_HOSTDEVICE int2 make_int2(const int4& v0) { return ::make_int2( v0.x, v0.y ); }
5302 OTK_INLINE OTK_HOSTDEVICE int3 make_int3(const int4& v0) { return ::make_int3( v0.x, v0.y, v0.z ); }
5303 OTK_INLINE OTK_HOSTDEVICE uint2 make_uint2(const uint3& v0) { return ::make_uint2( v0.x, v0.y ); }
5304 OTK_INLINE OTK_HOSTDEVICE uint2 make_uint2(const uint4& v0) { return ::make_uint2( v0.x, v0.y ); }
5305 OTK_INLINE OTK_HOSTDEVICE uint3 make_uint3(const uint4& v0) { return ::make_uint3( v0.x, v0.y, v0.z ); }
5306 OTK_INLINE OTK_HOSTDEVICE longlong2 make_longlong2(const longlong3& v0) { return ::make_longlong2( v0.x, v0.y ); }
5307 OTK_INLINE OTK_HOSTDEVICE longlong2 make_longlong2(const longlong4_16a& v0) { return ::make_longlong2( v0.x, v0.y ); }
5308 OTK_INLINE OTK_HOSTDEVICE longlong3 make_longlong3(const longlong4_16a& v0) { return ::make_longlong3( v0.x, v0.y, v0.z ); }
5309 OTK_INLINE OTK_HOSTDEVICE ulonglong2 make_ulonglong2(const ulonglong3& v0) { return ::make_ulonglong2( v0.x, v0.y ); }
5310 OTK_INLINE OTK_HOSTDEVICE ulonglong2 make_ulonglong2(const ulonglong4_16a& v0) { return ::make_ulonglong2( v0.x, v0.y ); }
5311 OTK_INLINE OTK_HOSTDEVICE ulonglong3 make_ulonglong3(const ulonglong4_16a& v0) { return ::make_ulonglong3( v0.x, v0.y, v0.z ); }
5312 OTK_INLINE OTK_HOSTDEVICE float2 make_float2(const float3& v0) { return ::make_float2( v0.x, v0.y ); }
5313 OTK_INLINE OTK_HOSTDEVICE float2 make_float2(const float4& v0) { return ::make_float2( v0.x, v0.y ); }
5314 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const float4& v0) { return ::make_float3( v0.x, v0.y, v0.z ); }
5315 /** @} */
5316 
5317 /** Assemble functions from smaller vectors
5318 * @{
5319 */
5320 OTK_INLINE OTK_HOSTDEVICE int3 make_int3(const int v0, const int2& v1) { return ::make_int3( v0, v1.x, v1.y ); }
5321 OTK_INLINE OTK_HOSTDEVICE int3 make_int3(const int2& v0, const int v1) { return ::make_int3( v0.x, v0.y, v1 ); }
5322 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int v0, const int v1, const int2& v2) { return ::make_int4( v0, v1, v2.x, v2.y ); }
5323 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int v0, const int2& v1, const int v2) { return ::make_int4( v0, v1.x, v1.y, v2 ); }
5324 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int2& v0, const int v1, const int v2) { return ::make_int4( v0.x, v0.y, v1, v2 ); }
5325 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int v0, const int3& v1) { return ::make_int4( v0, v1.x, v1.y, v1.z ); }
5326 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int3& v0, const int v1) { return ::make_int4( v0.x, v0.y, v0.z, v1 ); }
5327 OTK_INLINE OTK_HOSTDEVICE int4 make_int4(const int2& v0, const int2& v1) { return ::make_int4( v0.x, v0.y, v1.x, v1.y ); }
5328 OTK_INLINE OTK_HOSTDEVICE uint3 make_uint3(const unsigned int v0, const uint2& v1) { return ::make_uint3( v0, v1.x, v1.y ); }
5329 OTK_INLINE OTK_HOSTDEVICE uint3 make_uint3(const uint2& v0, const unsigned int v1) { return ::make_uint3( v0.x, v0.y, v1 ); }
5330 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const unsigned int v1, const uint2& v2) { return ::make_uint4( v0, v1, v2.x, v2.y ); }
5331 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const uint2& v1, const unsigned int v2) { return ::make_uint4( v0, v1.x, v1.y, v2 ); }
5332 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const uint2& v0, const unsigned int v1, const unsigned int v2) { return ::make_uint4( v0.x, v0.y, v1, v2 ); }
5333 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const unsigned int v0, const uint3& v1) { return ::make_uint4( v0, v1.x, v1.y, v1.z ); }
5334 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const uint3& v0, const unsigned int v1) { return ::make_uint4( v0.x, v0.y, v0.z, v1 ); }
5335 OTK_INLINE OTK_HOSTDEVICE uint4 make_uint4(const uint2& v0, const uint2& v1) { return ::make_uint4( v0.x, v0.y, v1.x, v1.y ); }
5336 OTK_INLINE OTK_HOSTDEVICE longlong3 make_longlong3(const long long v0, const longlong2& v1) { return ::make_longlong3(v0, v1.x, v1.y); }
5337 OTK_INLINE OTK_HOSTDEVICE longlong3 make_longlong3(const longlong2& v0, const long long v1) { return ::make_longlong3(v0.x, v0.y, v1); }
5338 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const long long v0, const long long v1, const longlong2& v2) { return make_longlong4_16a(v0, v1, v2.x, v2.y); }
5339 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const long long v0, const longlong2& v1, const long long v2) { return make_longlong4_16a(v0, v1.x, v1.y, v2); }
5340 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const longlong2& v0, const long long v1, const long long v2) { return make_longlong4_16a(v0.x, v0.y, v1, v2); }
5341 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const long long v0, const longlong3& v1) { return make_longlong4_16a(v0, v1.x, v1.y, v1.z); }
5342 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const longlong3& v0, const long long v1) { return make_longlong4_16a(v0.x, v0.y, v0.z, v1); }
5343 OTK_INLINE OTK_HOSTDEVICE longlong4_16a make_longlong4_16a(const longlong2& v0, const longlong2& v1) { return make_longlong4_16a(v0.x, v0.y, v1.x, v1.y); }
5344 OTK_INLINE OTK_HOSTDEVICE ulonglong3 make_ulonglong3(const unsigned long long v0, const ulonglong2& v1) { return ::make_ulonglong3(v0, v1.x, v1.y); }
5345 OTK_INLINE OTK_HOSTDEVICE ulonglong3 make_ulonglong3(const ulonglong2& v0, const unsigned long long v1) { return ::make_ulonglong3(v0.x, v0.y, v1); }
5346 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const unsigned long long v0, const unsigned long long v1, const ulonglong2& v2) { return make_ulonglong4_16a(v0, v1, v2.x, v2.y); }
5347 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const unsigned long long v0, const ulonglong2& v1, const unsigned long long v2) { return make_ulonglong4_16a(v0, v1.x, v1.y, v2); }
5348 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const ulonglong2& v0, const unsigned long long v1, const unsigned long long v2) { return make_ulonglong4_16a(v0.x, v0.y, v1, v2); }
5349 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const unsigned long long v0, const ulonglong3& v1) { return make_ulonglong4_16a(v0, v1.x, v1.y, v1.z); }
5350 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const ulonglong3& v0, const unsigned long long v1) { return make_ulonglong4_16a(v0.x, v0.y, v0.z, v1); }
5351 OTK_INLINE OTK_HOSTDEVICE ulonglong4_16a make_ulonglong4_16a(const ulonglong2& v0, const ulonglong2& v1) { return make_ulonglong4_16a(v0.x, v0.y, v1.x, v1.y); }
5352 
5353 } // namespace otk
5354 #endif // CUDART_VERSION >= 13000
5355 
5356 namespace otk {
5357 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const float2& v0, const float v1) { return ::make_float3(v0.x, v0.y, v1); }
5358 OTK_INLINE OTK_HOSTDEVICE float3 make_float3(const float v0, const float2& v1) { return ::make_float3( v0, v1.x, v1.y ); }
5359 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float v0, const float v1, const float2& v2) { return ::make_float4( v0, v1, v2.x, v2.y ); }
5360 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float v0, const float2& v1, const float v2) { return ::make_float4( v0, v1.x, v1.y, v2 ); }
5361 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float2& v0, const float v1, const float v2) { return ::make_float4( v0.x, v0.y, v1, v2 ); }
5362 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float v0, const float3& v1) { return ::make_float4( v0, v1.x, v1.y, v1.z ); }
5363 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float3& v0, const float v1) { return ::make_float4( v0.x, v0.y, v0.z, v1 ); }
5364 OTK_INLINE OTK_HOSTDEVICE float4 make_float4(const float2& v0, const float2& v1) { return ::make_float4( v0.x, v0.y, v1.x, v1.y ); }
5365 /** @} */
5366 
5367 } // namespace otk