zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

geometry.h (115542B) - Raw


      1 /*  Copyright (c) 2014-2017 Apple, Inc. All rights reserved.
      2  *
      3  *  The interfaces declared in this header provide operations for mathematical
      4  *  vectors; these functions and macros operate on vectors of floating-point
      5  *  data only.
      6  *
      7  *      Function                    Result
      8  *      ------------------------------------------------------------------
      9  *      simd_dot(x,y)               The dot product of x and y.
     10  *
     11  *      simd_project(x,y)           x projected onto y.  There are two variants
     12  *                                  of this function, simd_precise_project
     13  *                                  and simd_fast_project.  simd_project
     14  *                                  is equivalent to simd_precise_project
     15  *                                  unless you are compiling with -ffast-math
     16  *                                  specified, in which case it is equivalent
     17  *                                  to simd_fast_project.
     18  *
     19  *      simd_length(x)              The length (two-norm) of x.  Undefined if
     20  *                                  x is poorly scaled such that an
     21  *                                  intermediate computation overflows or
     22  *                                  underflows.  There are two variants
     23  *                                  of this function, simd_precise_length
     24  *                                  and simd_fast_length.  simd_length
     25  *                                  is equivalent to simd_precise_length
     26  *                                  unless you are compiling with -ffast-math
     27  *                                  specified, in which case it is equivalent
     28  *                                  to simd_fast_length.
     29  *
     30  *      simd_length_squared(x)      The square of the length of x.  If you
     31  *                                  simply need to compare relative magnitudes,
     32  *                                  use this instead of simd_length; it is
     33  *                                  faster than simd_fast_length and as
     34  *                                  accurate as simd_precise_length.
     35  *
     36  *      simd_norm_one(x)            The one-norm (sum of absolute values) of x.
     37  *
     38  *      simd_norm_inf(x)            The inf-norm (max absolute value) of x.
     39  *
     40  *      simd_distance(x,y)          The distance between x and y. Undefined if
     41  *                                  x and y are poorly scaled such that an
     42  *                                  intermediate computation overflows
     43  *                                  or underflows.  There are two variants
     44  *                                  of this function, simd_precise_distance
     45  *                                  and simd_fast_distance.  simd_distance
     46  *                                  is equivalent to simd_precise_distance
     47  *                                  unless you are compiling with -ffast-math
     48  *                                  specified, in which case it is equivalent
     49  *                                  to simd_fast_distance.
     50  *
     51  *      simd_distance_squared(x,y)  The square of the distance between x and y.
     52  *
     53  *      simd_normalize(x)           A vector pointing in the direction of x
     54  *                                  with length 1.0.  Undefined if x is
     55  *                                  the zero vector, or if x is poorly scaled
     56  *                                  such that an intermediate computation
     57  *                                  overflows or underflows.  There are two
     58  *                                  variants of this function,
     59  *                                  simd_precise_normalize and
     60  *                                  simd_fast_normalize.  simd_normalize
     61  *                                  is equivalent to simd_precise_normalize
     62  *                                  unless you are compiling with -ffast-math
     63  *                                  specified, in which case it is equivalent
     64  *                                  to simd_fast_normalize.
     65  *
     66  *      simd_cross(x,y)             If x and y are vectors of dimension 3,
     67  *                                  the cross-product of x and y.
     68  *
     69  *                                  If x and y are vectors of dimension 2,
     70  *                                  the cross-product of x and y interpreted as
     71  *                                  vectors in the z == 0 plane of a three-
     72  *                                  dimensional space.
     73  *
     74  *                                  If x and y are vectors with a length that
     75  *                                  is neither 2 nor 3, this operation is not
     76  *                                  available.
     77  *
     78  *      simd_reflect(x,n)           Reflects x through the plane perpendicular
     79  *                                  to the normal vector n.  Only available
     80  *                                  for vectors of length 2, 3, or 4.
     81  *
     82  *      simd_refract(x,n,eta)       Calculates the refraction direction given
     83  *                                  unit incident vector x, unit normal vector
     84  *                                  n, and index of refraction eta.  If the
     85  *                                  angle between the incident vector and the
     86  *                                  surface normal is too great for the
     87  *                                  specified index of refraction, zero is
     88  *                                  returned.
     89  *                                  Available for vectors of length 2, 3, or 4.
     90  *
     91  *     simd_orient(x,y,...)         Return a positive value if the origin and
     92  *                                  their ordered arguments determine a positively
     93  *                                  oriented parallelepiped, zero if it is degenerate,
     94  *                                  and a negative value if it is negatively oriented.
     95  *
     96  *  In C++ the following geometric functions are available in the simd::
     97  *  namespace:
     98  *
     99  *      C++ Function                    Equivalent C Function
    100  *      -----------------------------------------------------------
    101  *      simd::dot(x,y)                  simd_dot(x,y)
    102  *      simd::project(x,y)              simd_project(x,y)
    103  *      simd::length_squared(x)         simd_length_squared(x)
    104  *      simd::length(x)                 simd_length(x)
    105  *      simd::distance_squared(x,y)     simd_distance_squared(x,y)
    106  *      simd::norm_one(x)               simd_norm_one(x)
    107  *      simd::norm_inf(x)               simd_norm_inf(x)
    108  *      simd::distance(x,y)             simd_distance(x,y)
    109  *      simd::normalize(x)              simd_normalize(x)
    110  *      simd::cross(x,y)                simd_cross(x,y)
    111  *      simd::reflect(x,n)              simd_reflect(x,n)
    112  *      simd::refract(x,n,eta)          simd_refract(x,n,eta)
    113  *      simd::orient(x,y,...)           simd_orient(x,y,...)
    114  *
    115  *      simd::precise::project(x,y)     simd_precise_project(x,y)
    116  *      simd::precise::length(x)        simd_precise_length(x)
    117  *      simd::precise::distance(x,y)    simd_precise_distance(x,y)
    118  *      simd::precise::normalize(x)     simd_precise_normalize(x)
    119  *
    120  *      simd::fast::project(x,y)        simd_fast_project(x,y)
    121  *      simd::fast::length(x)           simd_fast_length(x)
    122  *      simd::fast::distance(x,y)       simd_fast_distance(x,y)
    123  *      simd::fast::normalize(x)        simd_fast_normalize(x)
    124  */
    125 
    126 #ifndef __SIMD_GEOMETRY_HEADER__
    127 #define __SIMD_GEOMETRY_HEADER__
    128 
    129 #include <simd/base.h>
    130 #if SIMD_COMPILER_HAS_REQUIRED_FEATURES
    131 #include <simd/vector_types.h>
    132 #include <simd/common.h>
    133 #include <simd/extern.h>
    134 
    135 #ifdef __cplusplus
    136 extern "C" {
    137 #endif
    138   
    139 static _Float16 SIMD_CFUNC simd_dot(simd_half2  __x, simd_half2  __y);
    140 static _Float16 SIMD_CFUNC simd_dot(simd_half3  __x, simd_half3  __y);
    141 static _Float16 SIMD_CFUNC simd_dot(simd_half4  __x, simd_half4  __y);
    142 static _Float16 SIMD_CFUNC simd_dot(simd_half8  __x, simd_half8  __y);
    143 static _Float16 SIMD_CFUNC simd_dot(simd_half16 __x, simd_half16 __y);
    144 static _Float16 SIMD_CFUNC simd_dot(simd_half32 __x, simd_half32 __y);
    145 static float  SIMD_CFUNC simd_dot(simd_float2  __x, simd_float2  __y);
    146 static float  SIMD_CFUNC simd_dot(simd_float3  __x, simd_float3  __y);
    147 static float  SIMD_CFUNC simd_dot(simd_float4  __x, simd_float4  __y);
    148 static float  SIMD_CFUNC simd_dot(simd_float8  __x, simd_float8  __y);
    149 static float  SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y);
    150 static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y);
    151 static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y);
    152 static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y);
    153 static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y);
    154 #define vector_dot simd_dot
    155 
    156 static simd_half2   SIMD_CFUNC simd_precise_project(simd_half2   __x, simd_half2   __y);
    157 static simd_half3   SIMD_CFUNC simd_precise_project(simd_half3   __x, simd_half3   __y);
    158 static simd_half4   SIMD_CFUNC simd_precise_project(simd_half4   __x, simd_half4   __y);
    159 static simd_half8   SIMD_CFUNC simd_precise_project(simd_half8   __x, simd_half8   __y);
    160 static simd_half16  SIMD_CFUNC simd_precise_project(simd_half16  __x, simd_half16  __y);
    161 static simd_half32  SIMD_CFUNC simd_precise_project(simd_half32  __x, simd_half32  __y);
    162 static simd_float2  SIMD_CFUNC simd_precise_project(simd_float2  __x, simd_float2  __y);
    163 static simd_float3  SIMD_CFUNC simd_precise_project(simd_float3  __x, simd_float3  __y);
    164 static simd_float4  SIMD_CFUNC simd_precise_project(simd_float4  __x, simd_float4  __y);
    165 static simd_float8  SIMD_CFUNC simd_precise_project(simd_float8  __x, simd_float8  __y);
    166 static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y);
    167 static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y);
    168 static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y);
    169 static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y);
    170 static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y);
    171 #define vector_precise_project simd_precise_project
    172 
    173 static simd_half2   SIMD_CFUNC simd_fast_project(simd_half2   __x, simd_half2   __y);
    174 static simd_half3   SIMD_CFUNC simd_fast_project(simd_half3   __x, simd_half3   __y);
    175 static simd_half4   SIMD_CFUNC simd_fast_project(simd_half4   __x, simd_half4   __y);
    176 static simd_half8   SIMD_CFUNC simd_fast_project(simd_half8   __x, simd_half8   __y);
    177 static simd_half16  SIMD_CFUNC simd_fast_project(simd_half16  __x, simd_half16  __y);
    178 static simd_half32  SIMD_CFUNC simd_fast_project(simd_half32  __x, simd_half32  __y);
    179 static simd_float2  SIMD_CFUNC simd_fast_project(simd_float2  __x, simd_float2  __y);
    180 static simd_float3  SIMD_CFUNC simd_fast_project(simd_float3  __x, simd_float3  __y);
    181 static simd_float4  SIMD_CFUNC simd_fast_project(simd_float4  __x, simd_float4  __y);
    182 static simd_float8  SIMD_CFUNC simd_fast_project(simd_float8  __x, simd_float8  __y);
    183 static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y);
    184 static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y);
    185 static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y);
    186 static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y);
    187 static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y);
    188 #define vector_fast_project simd_fast_project
    189 
    190 static simd_half2   SIMD_CFUNC simd_project(simd_half2   __x, simd_half2   __y);
    191 static simd_half3   SIMD_CFUNC simd_project(simd_half3   __x, simd_half3   __y);
    192 static simd_half4   SIMD_CFUNC simd_project(simd_half4   __x, simd_half4   __y);
    193 static simd_half8   SIMD_CFUNC simd_project(simd_half8   __x, simd_half8   __y);
    194 static simd_half16  SIMD_CFUNC simd_project(simd_half16  __x, simd_half16  __y);
    195 static simd_half32  SIMD_CFUNC simd_project(simd_half32  __x, simd_half32  __y);
    196 static simd_float2  SIMD_CFUNC simd_project(simd_float2  __x, simd_float2  __y);
    197 static simd_float3  SIMD_CFUNC simd_project(simd_float3  __x, simd_float3  __y);
    198 static simd_float4  SIMD_CFUNC simd_project(simd_float4  __x, simd_float4  __y);
    199 static simd_float8  SIMD_CFUNC simd_project(simd_float8  __x, simd_float8  __y);
    200 static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y);
    201 static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y);
    202 static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y);
    203 static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y);
    204 static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y);
    205 #define vector_project simd_project
    206 
    207 #if SIMD_LIBRARY_VERSION >= 6
    208 static _Float16 SIMD_CFUNC simd_precise_length(simd_half2  __x);
    209 static _Float16 SIMD_CFUNC simd_precise_length(simd_half3  __x);
    210 static _Float16 SIMD_CFUNC simd_precise_length(simd_half4  __x);
    211 static _Float16 SIMD_CFUNC simd_precise_length(simd_half8  __x);
    212 static _Float16 SIMD_CFUNC simd_precise_length(simd_half16 __x);
    213 static _Float16 SIMD_CFUNC simd_precise_length(simd_half32 __x);
    214 #endif // SIMD_LIBRARY_VERSION >= 6
    215 static float  SIMD_CFUNC simd_precise_length(simd_float2  __x);
    216 static float  SIMD_CFUNC simd_precise_length(simd_float3  __x);
    217 static float  SIMD_CFUNC simd_precise_length(simd_float4  __x);
    218 static float  SIMD_CFUNC simd_precise_length(simd_float8  __x);
    219 static float  SIMD_CFUNC simd_precise_length(simd_float16 __x);
    220 static double SIMD_CFUNC simd_precise_length(simd_double2 __x);
    221 static double SIMD_CFUNC simd_precise_length(simd_double3 __x);
    222 static double SIMD_CFUNC simd_precise_length(simd_double4 __x);
    223 static double SIMD_CFUNC simd_precise_length(simd_double8 __x);
    224 #define vector_precise_length simd_precise_length
    225 
    226 static _Float16 SIMD_CFUNC simd_fast_length(simd_half2  __x);
    227 static _Float16 SIMD_CFUNC simd_fast_length(simd_half3  __x);
    228 static _Float16 SIMD_CFUNC simd_fast_length(simd_half4  __x);
    229 static _Float16 SIMD_CFUNC simd_fast_length(simd_half8  __x);
    230 static _Float16 SIMD_CFUNC simd_fast_length(simd_half16 __x);
    231 static _Float16 SIMD_CFUNC simd_fast_length(simd_half32 __x);
    232 static float  SIMD_CFUNC simd_fast_length(simd_float2  __x);
    233 static float  SIMD_CFUNC simd_fast_length(simd_float3  __x);
    234 static float  SIMD_CFUNC simd_fast_length(simd_float4  __x);
    235 static float  SIMD_CFUNC simd_fast_length(simd_float8  __x);
    236 static float  SIMD_CFUNC simd_fast_length(simd_float16 __x);
    237 static double SIMD_CFUNC simd_fast_length(simd_double2 __x);
    238 static double SIMD_CFUNC simd_fast_length(simd_double3 __x);
    239 static double SIMD_CFUNC simd_fast_length(simd_double4 __x);
    240 static double SIMD_CFUNC simd_fast_length(simd_double8 __x);
    241 #define vector_fast_length simd_fast_length
    242 
    243 static _Float16 SIMD_CFUNC simd_length(simd_half2  __x);
    244 static _Float16 SIMD_CFUNC simd_length(simd_half3  __x);
    245 static _Float16 SIMD_CFUNC simd_length(simd_half4  __x);
    246 static _Float16 SIMD_CFUNC simd_length(simd_half8  __x);
    247 static _Float16 SIMD_CFUNC simd_length(simd_half16 __x);
    248 static _Float16 SIMD_CFUNC simd_length(simd_half32 __x);
    249 static float  SIMD_CFUNC simd_length(simd_float2  __x);
    250 static float  SIMD_CFUNC simd_length(simd_float3  __x);
    251 static float  SIMD_CFUNC simd_length(simd_float4  __x);
    252 static float  SIMD_CFUNC simd_length(simd_float8  __x);
    253 static float  SIMD_CFUNC simd_length(simd_float16 __x);
    254 static double SIMD_CFUNC simd_length(simd_double2 __x);
    255 static double SIMD_CFUNC simd_length(simd_double3 __x);
    256 static double SIMD_CFUNC simd_length(simd_double4 __x);
    257 static double SIMD_CFUNC simd_length(simd_double8 __x);
    258 #define vector_length simd_length
    259 
    260 static _Float16 SIMD_CFUNC simd_length_squared(simd_half2  __x);
    261 static _Float16 SIMD_CFUNC simd_length_squared(simd_half3  __x);
    262 static _Float16 SIMD_CFUNC simd_length_squared(simd_half4  __x);
    263 static _Float16 SIMD_CFUNC simd_length_squared(simd_half8  __x);
    264 static _Float16 SIMD_CFUNC simd_length_squared(simd_half16 __x);
    265 static _Float16 SIMD_CFUNC simd_length_squared(simd_half32 __x);
    266 static float  SIMD_CFUNC simd_length_squared(simd_float2  __x);
    267 static float  SIMD_CFUNC simd_length_squared(simd_float3  __x);
    268 static float  SIMD_CFUNC simd_length_squared(simd_float4  __x);
    269 static float  SIMD_CFUNC simd_length_squared(simd_float8  __x);
    270 static float  SIMD_CFUNC simd_length_squared(simd_float16 __x);
    271 static double SIMD_CFUNC simd_length_squared(simd_double2 __x);
    272 static double SIMD_CFUNC simd_length_squared(simd_double3 __x);
    273 static double SIMD_CFUNC simd_length_squared(simd_double4 __x);
    274 static double SIMD_CFUNC simd_length_squared(simd_double8 __x);
    275 #define vector_length_squared simd_length_squared
    276 
    277 static _Float16 SIMD_CFUNC simd_norm_one(simd_half2 __x);
    278 static _Float16 SIMD_CFUNC simd_norm_one(simd_half3 __x);
    279 static _Float16 SIMD_CFUNC simd_norm_one(simd_half4 __x);
    280 static _Float16 SIMD_CFUNC simd_norm_one(simd_half8 __x);
    281 static _Float16 SIMD_CFUNC simd_norm_one(simd_half16 __x);
    282 static _Float16 SIMD_CFUNC simd_norm_one(simd_half32 __x);
    283 static float SIMD_CFUNC simd_norm_one(simd_float2 __x);
    284 static float SIMD_CFUNC simd_norm_one(simd_float3 __x);
    285 static float SIMD_CFUNC simd_norm_one(simd_float4 __x);
    286 static float SIMD_CFUNC simd_norm_one(simd_float8 __x);
    287 static float SIMD_CFUNC simd_norm_one(simd_float16 __x);
    288 static double SIMD_CFUNC simd_norm_one(simd_double2 __x);
    289 static double SIMD_CFUNC simd_norm_one(simd_double3 __x);
    290 static double SIMD_CFUNC simd_norm_one(simd_double4 __x);
    291 static double SIMD_CFUNC simd_norm_one(simd_double8 __x);
    292 #define vector_norm_one simd_norm_one
    293 
    294 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half2 __x);
    295 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half3 __x);
    296 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half4 __x);
    297 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half8 __x);
    298 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half16 __x);
    299 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half32 __x);
    300 static float SIMD_CFUNC simd_norm_inf(simd_float2 __x);
    301 static float SIMD_CFUNC simd_norm_inf(simd_float3 __x);
    302 static float SIMD_CFUNC simd_norm_inf(simd_float4 __x);
    303 static float SIMD_CFUNC simd_norm_inf(simd_float8 __x);
    304 static float SIMD_CFUNC simd_norm_inf(simd_float16 __x);
    305 static double SIMD_CFUNC simd_norm_inf(simd_double2 __x);
    306 static double SIMD_CFUNC simd_norm_inf(simd_double3 __x);
    307 static double SIMD_CFUNC simd_norm_inf(simd_double4 __x);
    308 static double SIMD_CFUNC simd_norm_inf(simd_double8 __x);
    309 #define vector_norm_inf simd_norm_inf
    310 
    311 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half2  __x, simd_half2  __y);
    312 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half3  __x, simd_half3  __y);
    313 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half4  __x, simd_half4  __y);
    314 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half8  __x, simd_half8  __y);
    315 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half16 __x, simd_half16 __y);
    316 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half32 __x, simd_half32 __y);
    317 static float  SIMD_CFUNC simd_precise_distance(simd_float2  __x, simd_float2  __y);
    318 static float  SIMD_CFUNC simd_precise_distance(simd_float3  __x, simd_float3  __y);
    319 static float  SIMD_CFUNC simd_precise_distance(simd_float4  __x, simd_float4  __y);
    320 static float  SIMD_CFUNC simd_precise_distance(simd_float8  __x, simd_float8  __y);
    321 static float  SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y);
    322 static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y);
    323 static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y);
    324 static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y);
    325 static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y);
    326 #define vector_precise_distance simd_precise_distance
    327 
    328 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half2  __x, simd_half2  __y);
    329 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half3  __x, simd_half3  __y);
    330 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half4  __x, simd_half4  __y);
    331 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half8  __x, simd_half8  __y);
    332 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half16 __x, simd_half16 __y);
    333 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half32 __x, simd_half32 __y);
    334 static float  SIMD_CFUNC simd_fast_distance(simd_float2  __x, simd_float2  __y);
    335 static float  SIMD_CFUNC simd_fast_distance(simd_float3  __x, simd_float3  __y);
    336 static float  SIMD_CFUNC simd_fast_distance(simd_float4  __x, simd_float4  __y);
    337 static float  SIMD_CFUNC simd_fast_distance(simd_float8  __x, simd_float8  __y);
    338 static float  SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y);
    339 static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y);
    340 static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y);
    341 static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y);
    342 static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y);
    343 #define vector_fast_distance simd_fast_distance
    344 
    345 static _Float16 SIMD_CFUNC simd_distance(simd_half2  __x, simd_half2  __y);
    346 static _Float16 SIMD_CFUNC simd_distance(simd_half3  __x, simd_half3  __y);
    347 static _Float16 SIMD_CFUNC simd_distance(simd_half4  __x, simd_half4  __y);
    348 static _Float16 SIMD_CFUNC simd_distance(simd_half8  __x, simd_half8  __y);
    349 static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y);
    350 static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y);
    351 static float  SIMD_CFUNC simd_distance(simd_float2  __x, simd_float2  __y);
    352 static float  SIMD_CFUNC simd_distance(simd_float3  __x, simd_float3  __y);
    353 static float  SIMD_CFUNC simd_distance(simd_float4  __x, simd_float4  __y);
    354 static float  SIMD_CFUNC simd_distance(simd_float8  __x, simd_float8  __y);
    355 static float  SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y);
    356 static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y);
    357 static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y);
    358 static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y);
    359 static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y);
    360 #define vector_distance simd_distance
    361 
    362 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half2  __x, simd_half2  __y);
    363 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half3  __x, simd_half3  __y);
    364 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half4  __x, simd_half4  __y);
    365 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half8  __x, simd_half8  __y);
    366 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half16 __x, simd_half16 __y);
    367 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half32 __x, simd_half32 __y);
    368 static float  SIMD_CFUNC simd_distance_squared(simd_float2  __x, simd_float2  __y);
    369 static float  SIMD_CFUNC simd_distance_squared(simd_float3  __x, simd_float3  __y);
    370 static float  SIMD_CFUNC simd_distance_squared(simd_float4  __x, simd_float4  __y);
    371 static float  SIMD_CFUNC simd_distance_squared(simd_float8  __x, simd_float8  __y);
    372 static float  SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y);
    373 static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y);
    374 static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y);
    375 static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y);
    376 static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y);
    377 #define vector_distance_squared simd_distance_squared
    378 
    379 static simd_half2   SIMD_CFUNC simd_precise_normalize(simd_half2   __x);
    380 static simd_half3   SIMD_CFUNC simd_precise_normalize(simd_half3   __x);
    381 static simd_half4   SIMD_CFUNC simd_precise_normalize(simd_half4   __x);
    382 static simd_half8   SIMD_CFUNC simd_precise_normalize(simd_half8   __x);
    383 static simd_half16  SIMD_CFUNC simd_precise_normalize(simd_half16  __x);
    384 static simd_half32  SIMD_CFUNC simd_precise_normalize(simd_half32  __x);
    385 static simd_float2  SIMD_CFUNC simd_precise_normalize(simd_float2  __x);
    386 static simd_float3  SIMD_CFUNC simd_precise_normalize(simd_float3  __x);
    387 static simd_float4  SIMD_CFUNC simd_precise_normalize(simd_float4  __x);
    388 static simd_float8  SIMD_CFUNC simd_precise_normalize(simd_float8  __x);
    389 static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x);
    390 static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x);
    391 static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x);
    392 static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x);
    393 static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x);
    394 #define vector_precise_normalize simd_precise_normalize
    395 
    396 static simd_half2   SIMD_CFUNC simd_fast_normalize(simd_half2   __x);
    397 static simd_half3   SIMD_CFUNC simd_fast_normalize(simd_half3   __x);
    398 static simd_half4   SIMD_CFUNC simd_fast_normalize(simd_half4   __x);
    399 static simd_half8   SIMD_CFUNC simd_fast_normalize(simd_half8   __x);
    400 static simd_half16  SIMD_CFUNC simd_fast_normalize(simd_half16  __x);
    401 static simd_half32  SIMD_CFUNC simd_fast_normalize(simd_half32  __x);
    402 static simd_float2  SIMD_CFUNC simd_fast_normalize(simd_float2  __x);
    403 static simd_float3  SIMD_CFUNC simd_fast_normalize(simd_float3  __x);
    404 static simd_float4  SIMD_CFUNC simd_fast_normalize(simd_float4  __x);
    405 static simd_float8  SIMD_CFUNC simd_fast_normalize(simd_float8  __x);
    406 static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x);
    407 static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x);
    408 static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x);
    409 static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x);
    410 static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x);
    411 #define vector_fast_normalize simd_fast_normalize
    412 
    413 static simd_half2   SIMD_CFUNC simd_normalize(simd_half2   __x);
    414 static simd_half3   SIMD_CFUNC simd_normalize(simd_half3   __x);
    415 static simd_half4   SIMD_CFUNC simd_normalize(simd_half4   __x);
    416 static simd_half8   SIMD_CFUNC simd_normalize(simd_half8   __x);
    417 static simd_half16  SIMD_CFUNC simd_normalize(simd_half16  __x);
    418 static simd_half32  SIMD_CFUNC simd_normalize(simd_half32  __x);
    419 static simd_float2  SIMD_CFUNC simd_normalize(simd_float2  __x);
    420 static simd_float3  SIMD_CFUNC simd_normalize(simd_float3  __x);
    421 static simd_float4  SIMD_CFUNC simd_normalize(simd_float4  __x);
    422 static simd_float8  SIMD_CFUNC simd_normalize(simd_float8  __x);
    423 static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x);
    424 static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x);
    425 static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x);
    426 static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x);
    427 static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x);
    428 #define vector_normalize simd_normalize
    429 
    430 static simd_half3   SIMD_CFUNC simd_cross(simd_half2   __x, simd_half2   __y);
    431 static simd_half3   SIMD_CFUNC simd_cross(simd_half3   __x, simd_half3   __y);
    432 static simd_float3  SIMD_CFUNC simd_cross(simd_float2  __x, simd_float2  __y);
    433 static simd_float3  SIMD_CFUNC simd_cross(simd_float3  __x, simd_float3  __y);
    434 static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y);
    435 static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y);
    436 #define vector_cross simd_cross
    437 
    438 static simd_half2   SIMD_CFUNC simd_reflect(simd_half2   __x, simd_half2   __n);
    439 static simd_half3   SIMD_CFUNC simd_reflect(simd_half3   __x, simd_half3   __n);
    440 static simd_half4   SIMD_CFUNC simd_reflect(simd_half4   __x, simd_half4   __n);
    441 static simd_float2  SIMD_CFUNC simd_reflect(simd_float2  __x, simd_float2  __n);
    442 static simd_float3  SIMD_CFUNC simd_reflect(simd_float3  __x, simd_float3  __n);
    443 static simd_float4  SIMD_CFUNC simd_reflect(simd_float4  __x, simd_float4  __n);
    444 static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n);
    445 static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n);
    446 static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n);
    447 #define vector_reflect simd_reflect
    448 
    449 #if SIMD_LIBRARY_VERSION >= 6
    450 static simd_half2   SIMD_CFUNC simd_refract(simd_half2   __x, simd_half2   __n, _Float16 __eta);
    451 static simd_half3   SIMD_CFUNC simd_refract(simd_half3   __x, simd_half3   __n, _Float16 __eta);
    452 static simd_half4   SIMD_CFUNC simd_refract(simd_half4   __x, simd_half4   __n, _Float16 __eta);
    453 #endif // SIMD_LIBRARY_VERSION >= 6
    454 static simd_float2  SIMD_CFUNC simd_refract(simd_float2  __x, simd_float2  __n, float __eta);
    455 static simd_float3  SIMD_CFUNC simd_refract(simd_float3  __x, simd_float3  __n, float __eta);
    456 static simd_float4  SIMD_CFUNC simd_refract(simd_float4  __x, simd_float4  __n, float __eta);
    457 static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta);
    458 static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta);
    459 static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta);
    460 #define vector_refract simd_refract
    461 
    462 #if SIMD_LIBRARY_VERSION >= 2
    463 /*  These functions require that you are building for OS X 10.12 or later,
    464  *  iOS 10.0 or later, watchOS 3.0 or later, and tvOS 10.0 or later.  On
    465  *  earlier OS versions, the library functions that implement these
    466  *  operations are not available.                                             */
    467 
    468 /*! @functiongroup vector orientation
    469  *
    470  *  @discussion These functions return a positive value if the origin and
    471  *  their ordered arguments determine a positively oriented parallelepiped,
    472  *  zero if it is degenerate, and a negative value if it is negatively
    473  *  oriented.  This is equivalent to saying that the matrix with rows equal
    474  *  to the vectors has a positive, zero, or negative determinant,
    475  *  respectively.
    476  *
    477  *  Naive evaluation of the determinant is prone to producing incorrect
    478  *  results if the vectors are nearly degenerate (e.g. floating-point
    479  *  rounding might cause the determinant to be zero or negative when
    480  *  the points are very nearly coplanar but positively oriented).  If
    481  *  the vectors are very large or small, computing the determininat is
    482  *  also prone to premature overflow, which may cause the result to be
    483  *  NaN even though the vectors contain normal floating-point numbers.
    484  *
    485  *  These routines take care to avoid those issues and always return a
    486  *  result with correct sign, even when the problem is very ill-
    487  *  conditioned.                                                              */
    488 
    489 /*! @abstract Test the orientation of two 2d vectors.
    490  *
    491  *  @param __x The first vector.
    492  *  @param __y The second vector.
    493  *
    494  *  @result Positive if (x, y) are positively oriented, zero if they are
    495  *  colinear, and negative if they are negatively oriented.
    496  *
    497  *  @discussion For two-dimensional vectors, "positively oriented" is
    498  *  equivalent to the ordering (0, x, y) proceeding counter-clockwise
    499  *  when viewed down the z axis, or to the cross product of x and y
    500  *  extended to three-dimensions having positive z-component.                 */
    501 static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y);
    502 
    503 /*! @abstract Test the orientation of two 2d vectors.
    504  *
    505  *  @param __x The first vector.
    506  *  @param __y The second vector.
    507  *
    508  *  @result Positive if (x, y) are positively oriented, zero if they are
    509  *  colinear, and negative if they are negatively oriented.
    510  *
    511  *  @discussion For two-dimensional vectors, "positively oriented" is
    512  *  equivalent to the ordering (0, x, y) proceeding counter- clockwise
    513  *  when viewed down the z axis, or to the cross product of x and y
    514  *  extended to three-dimensions having positive z-component.                 */
    515 static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y);
    516 
    517 /*! @abstract Test the orientation of three 3d vectors.
    518  *
    519  *  @param __x The first vector.
    520  *  @param __y The second vector.
    521  *  @param __z The third vector.
    522  *
    523  *  @result Positive if (x, y, z) are positively oriented, zero if they
    524  *  are coplanar, and negative if they are negatively oriented.
    525  *
    526  *  @discussion For three-dimensional vectors, "positively oriented" is
    527  *  equivalent to the ordering (x, y, z) following the "right hand rule",
    528  *  or to the dot product of z with the cross product of x and y being
    529  *  positive.                                                                 */
    530 static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z);
    531 
    532 /*! @abstract Test the orientation of three 3d vectors.
    533  *
    534  *  @param __x The first vector.
    535  *  @param __y The second vector.
    536  *  @param __z The third vector.
    537  *
    538  *  @result Positive if (x, y, c) are positively oriented, zero if they
    539  *  are coplanar, and negative if they are negatively oriented.
    540  *
    541  *  @discussion For three-dimensional vectors, "positively oriented" is
    542  *  equivalent to the ordering (x, y, z) following the "right hand rule",
    543  *  or to the dot product of z with the cross product of x and y being
    544  *  positive.                                                                 */
    545 static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z);
    546 
    547 /*! @functiongroup point (affine) orientation
    548  *
    549  *  @discussion These functions return a positive value if their ordered
    550  *  arguments determine a positively oriented parallelepiped, zero if it
    551  *  is degenerate, and a negative value if it is negatively oriented.
    552  *
    553  *  simd_orient(a, b, c) is formally equivalent to simd_orient(b-a, c-a),
    554  *  but it is not effected by rounding error from subtraction of points,
    555  *  as that implementation would be.  Care is taken so that the sign of
    556  *  the result is always correct, even if the problem is ill-conditioned.     */
    557 
    558 /*! @abstract Test the orientation of a triangle in 2d.
    559  *
    560  *  @param __a The first point of the triangle.
    561  *  @param __b The second point of the triangle.
    562  *  @param __c The third point of the triangle.
    563  *
    564  *  @result Positive if the triangle is positively oriented, zero if it
    565  *  is degenerate (three points in a line), and negative if it is negatively
    566  *  oriented.
    567  *
    568  *  @discussion "Positively oriented" is equivalent to the ordering
    569  *  (a, b, c) proceeding counter-clockwise when viewed down the z axis,
    570  *  or to the cross product of a-c and b-c extended to three-dimensions
    571  *  having positive z-component.                                              */
    572 static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c);
    573 
    574 /*! @abstract Test the orientation of a triangle in 2d.
    575  *
    576  *  @param __a The first point of the triangle.
    577  *  @param __b The second point of the triangle.
    578  *  @param __c The third point of the triangle.
    579  *
    580  *  @result Positive if the triangle is positively oriented, zero if it
    581  *  is degenerate (three points in a line), and negative if it is negatively
    582  *  oriented.
    583  *
    584  *  @discussion "Positively oriented" is equivalent to the ordering
    585  *  (a, b, c) proceeding counter-clockwise when viewed down the z axis,
    586  *  or to the cross product of a-c and b-c extended to three-dimensions
    587  *  having positive z-component.                                              */
    588 static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c);
    589 
    590 /*! @abstract Test the orientation of a tetrahedron in 3d.
    591  *
    592  *  @param __a The first point of the tetrahedron.
    593  *  @param __b The second point of the tetrahedron.
    594  *  @param __c The third point of the tetrahedron.
    595  *  @param __d The fourth point of the tetrahedron.
    596  *
    597  *  @result Positive if the tetrahedron is positively oriented, zero if it
    598  *  is degenerate (four points in a plane), and negative if it is negatively
    599  *  oriented.
    600  *
    601  *  @discussion "Positively oriented" is equivalent to the vectors
    602  *  (a-d, b-d, c-d) following the "right hand rule", or to the dot product
    603  *  of c-d with the the cross product of a-d and b-d being positive.          */
    604 static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d);
    605 
    606 /*! @abstract Test the orientation of a tetrahedron in 3d.
    607  *
    608  *  @param __a The first point of the tetrahedron.
    609  *  @param __b The second point of the tetrahedron.
    610  *  @param __c The third point of the tetrahedron.
    611  *  @param __d The fourth point of the tetrahedron.
    612  *
    613  *  @result Positive if the tetrahedron is positively oriented, zero if it
    614  *  is degenerate (four points in a plane), and negative if it is negatively
    615  *  oriented.
    616  *
    617  *  @discussion "Positively oriented" is equivalent to the vectors
    618  *  (a-d, b-d, c-d) following the "right hand rule", or to the dot product
    619  *  of c-d with the the cross product of a-d and b-d being positive.          */
    620 static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d);
    621 
    622 /*! @functiongroup incircle (points) tests
    623  *
    624  *  @discussion These functions determine whether the point x is inside, on,
    625  *  or outside the circle or sphere passing through a group of points.  If
    626  *  x is inside the circle, the result is positive; if x is on the circle,
    627  *  the result is zero; if x is outside the circle the result is negative.
    628  *
    629  *  These functions are always exact, even if the problem is ill-
    630  *  conditioned (meaning that the points are nearly co-linear or
    631  *  co-planar).
    632  *
    633  *  If the points are negatively-oriented, the the notions of "inside" and
    634  *  "outside" are flipped.  If the points are degenerate, then the result
    635  *  is undefined.                                                             */
    636 
    637 /*! @abstract Test if x lies inside, on, or outside the circle passing
    638  *  through a, b, and c.
    639  *
    640  *  @param __x The point being tested.
    641  *  @param __a The first point determining the circle.
    642  *  @param __b The second point determining the circle.
    643  *  @param __c The third point determining the circle.
    644  *
    645  *  @result Assuming that (a,b,c) are positively-oriented, positive if x is
    646  *  inside the circle, zero if x is on the circle, and negative if x is
    647  *  outside the circle.  The sign of the result is flipped if (a,b,c) are
    648  *  negatively-oriented.                                                      */
    649 static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c);
    650 
    651 /*! @abstract Test if x lies inside, on, or outside the circle passing
    652  *  through a, b, and c.
    653  *
    654  *  @param __x The point being tested.
    655  *  @param __a The first point determining the circle.
    656  *  @param __b The second point determining the circle.
    657  *  @param __c The third point determining the circle.
    658  *
    659  *  @result Assuming that (a,b,c) are positively-oriented, positive if x is
    660  *  inside the circle, zero if x is on the circle, and negative if x is
    661  *  outside the circle.  The sign of the result is flipped if (a,b,c) are
    662  *  negatively-oriented.                                                      */
    663 static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c);
    664 
    665 /*! @abstract Test if x lies inside, on, or outside the sphere passing
    666  *  through a, b, c, and d.
    667  *
    668  *  @param __x The point being tested.
    669  *  @param __a The first point determining the sphere.
    670  *  @param __b The second point determining the sphere.
    671  *  @param __c The third point determining the sphere.
    672  *  @param __d The fourth point determining the sphere.
    673  *
    674  *  @result Assuming that the points are positively-oriented, positive if x
    675  *  is inside the sphere, zero if x is on the sphere, and negative if x is
    676  *  outside the sphere.  The sign of the result is flipped if the points are
    677  *  negatively-oriented.                                                      */
    678 static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d);
    679 
    680 /*! @abstract Test if x lies inside, on, or outside the sphere passing
    681  *  through a, b, c, and d.
    682  *
    683  *  @param __x The point being tested.
    684  *  @param __a The first point determining the sphere.
    685  *  @param __b The second point determining the sphere.
    686  *  @param __c The third point determining the sphere.
    687  *  @param __d The fourth point determining the sphere.
    688  *
    689  *  @result Assuming that the points are positively-oriented, positive if x
    690  *  is inside the sphere, zero if x is on the sphere, and negative if x is
    691  *  outside the sphere.  The sign of the result is flipped if the points are
    692  *  negatively-oriented.                                                      */
    693 static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d);
    694 #endif /* SIMD_LIBRARY_VERSION */
    695 
    696 #if SIMD_LIBRARY_VERSION >= 6
    697 /*  fp16 support requires that you are building for OS X 15.0 or later,
    698  *  iOS 18.0 or later, watchOS 11.0 or later, and tvOS 18.0 or later.  On
    699  *  earlier OS versions, the library functions that implement these
    700  *  operations are not available.                                             */
    701 
    702   static _Float16 SIMD_CFUNC simd_orient(simd_half2 __x, simd_half2 __y);
    703   static _Float16 SIMD_CFUNC simd_orient(simd_half3 __x, simd_half3 __y, simd_half3 __z);
    704   static _Float16 SIMD_CFUNC simd_orient(simd_half2 __a, simd_half2 __b, simd_half2 __c);
    705   static _Float16 SIMD_CFUNC simd_orient(simd_half3 __a, simd_half3 __b, simd_half3 __c, simd_half3 __d);
    706   static _Float16 SIMD_CFUNC simd_incircle(simd_half2 __x, simd_half2 __a, simd_half2 __b, simd_half2 __c);
    707   static _Float16 SIMD_CFUNC simd_insphere(simd_half3 __x, simd_half3 __a, simd_half3 __b, simd_half3 __c, simd_half3 __d);
    708 #endif /* SIMD_LIBRARY_VERSION */
    709 
    710 #ifdef __cplusplus
    711 } /* extern "C" */
    712 
    713 namespace simd {
    714   static SIMD_CPPFUNC _Float16 dot(const half2  x, const half2  y) { return ::simd_dot(x, y); }
    715   static SIMD_CPPFUNC _Float16 dot(const half3  x, const half3  y) { return ::simd_dot(x, y); }
    716   static SIMD_CPPFUNC _Float16 dot(const half4  x, const half4  y) { return ::simd_dot(x, y); }
    717   static SIMD_CPPFUNC _Float16 dot(const half8  x, const half8  y) { return ::simd_dot(x, y); }
    718   static SIMD_CPPFUNC _Float16 dot(const half16 x, const half16 y) { return ::simd_dot(x, y); }
    719   static SIMD_CPPFUNC _Float16 dot(const half32 x, const half32 y) { return ::simd_dot(x, y); }
    720   static SIMD_CPPFUNC float  dot(const float2  x, const float2  y) { return ::simd_dot(x, y); }
    721   static SIMD_CPPFUNC float  dot(const float3  x, const float3  y) { return ::simd_dot(x, y); }
    722   static SIMD_CPPFUNC float  dot(const float4  x, const float4  y) { return ::simd_dot(x, y); }
    723   static SIMD_CPPFUNC float  dot(const float8  x, const float8  y) { return ::simd_dot(x, y); }
    724   static SIMD_CPPFUNC float  dot(const float16 x, const float16 y) { return ::simd_dot(x, y); }
    725   static SIMD_CPPFUNC double dot(const double2 x, const double2 y) { return ::simd_dot(x, y); }
    726   static SIMD_CPPFUNC double dot(const double3 x, const double3 y) { return ::simd_dot(x, y); }
    727   static SIMD_CPPFUNC double dot(const double4 x, const double4 y) { return ::simd_dot(x, y); }
    728   static SIMD_CPPFUNC double dot(const double8 x, const double8 y) { return ::simd_dot(x, y); }
    729   
    730   static SIMD_CPPFUNC half2   project(const half2   x, const half2   y) { return ::simd_project(x, y); }
    731   static SIMD_CPPFUNC half3   project(const half3   x, const half3   y) { return ::simd_project(x, y); }
    732   static SIMD_CPPFUNC half4   project(const half4   x, const half4   y) { return ::simd_project(x, y); }
    733   static SIMD_CPPFUNC half8   project(const half8   x, const half8   y) { return ::simd_project(x, y); }
    734   static SIMD_CPPFUNC half16  project(const half16  x, const half16  y) { return ::simd_project(x, y); }
    735   static SIMD_CPPFUNC half32  project(const half32  x, const half32  y) { return ::simd_project(x, y); }
    736   static SIMD_CPPFUNC float2  project(const float2  x, const float2  y) { return ::simd_project(x, y); }
    737   static SIMD_CPPFUNC float3  project(const float3  x, const float3  y) { return ::simd_project(x, y); }
    738   static SIMD_CPPFUNC float4  project(const float4  x, const float4  y) { return ::simd_project(x, y); }
    739   static SIMD_CPPFUNC float8  project(const float8  x, const float8  y) { return ::simd_project(x, y); }
    740   static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_project(x, y); }
    741   static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_project(x, y); }
    742   static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_project(x, y); }
    743   static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_project(x, y); }
    744   static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_project(x, y); }
    745   
    746   static SIMD_CPPFUNC _Float16 length_squared(const half2  x) { return ::simd_length_squared(x); }
    747   static SIMD_CPPFUNC _Float16 length_squared(const half3  x) { return ::simd_length_squared(x); }
    748   static SIMD_CPPFUNC _Float16 length_squared(const half4  x) { return ::simd_length_squared(x); }
    749   static SIMD_CPPFUNC _Float16 length_squared(const half8  x) { return ::simd_length_squared(x); }
    750   static SIMD_CPPFUNC _Float16 length_squared(const half16 x) { return ::simd_length_squared(x); }
    751   static SIMD_CPPFUNC _Float16 length_squared(const half32 x) { return ::simd_length_squared(x); }
    752   static SIMD_CPPFUNC float  length_squared(const float2  x) { return ::simd_length_squared(x); }
    753   static SIMD_CPPFUNC float  length_squared(const float3  x) { return ::simd_length_squared(x); }
    754   static SIMD_CPPFUNC float  length_squared(const float4  x) { return ::simd_length_squared(x); }
    755   static SIMD_CPPFUNC float  length_squared(const float8  x) { return ::simd_length_squared(x); }
    756   static SIMD_CPPFUNC float  length_squared(const float16 x) { return ::simd_length_squared(x); }
    757   static SIMD_CPPFUNC double length_squared(const double2 x) { return ::simd_length_squared(x); }
    758   static SIMD_CPPFUNC double length_squared(const double3 x) { return ::simd_length_squared(x); }
    759   static SIMD_CPPFUNC double length_squared(const double4 x) { return ::simd_length_squared(x); }
    760   static SIMD_CPPFUNC double length_squared(const double8 x) { return ::simd_length_squared(x); }
    761   
    762   static SIMD_CPPFUNC _Float16 norm_one(const half2  x) { return ::simd_norm_one(x); }
    763   static SIMD_CPPFUNC _Float16 norm_one(const half3  x) { return ::simd_norm_one(x); }
    764   static SIMD_CPPFUNC _Float16 norm_one(const half4  x) { return ::simd_norm_one(x); }
    765   static SIMD_CPPFUNC _Float16 norm_one(const half8  x) { return ::simd_norm_one(x); }
    766   static SIMD_CPPFUNC _Float16 norm_one(const half16 x) { return ::simd_norm_one(x); }
    767   static SIMD_CPPFUNC _Float16 norm_one(const half32 x) { return ::simd_norm_one(x); }
    768   static SIMD_CPPFUNC float  norm_one(const float2  x) { return ::simd_norm_one(x); }
    769   static SIMD_CPPFUNC float  norm_one(const float3  x) { return ::simd_norm_one(x); }
    770   static SIMD_CPPFUNC float  norm_one(const float4  x) { return ::simd_norm_one(x); }
    771   static SIMD_CPPFUNC float  norm_one(const float8  x) { return ::simd_norm_one(x); }
    772   static SIMD_CPPFUNC float  norm_one(const float16 x) { return ::simd_norm_one(x); }
    773   static SIMD_CPPFUNC double norm_one(const double2 x) { return ::simd_norm_one(x); }
    774   static SIMD_CPPFUNC double norm_one(const double3 x) { return ::simd_norm_one(x); }
    775   static SIMD_CPPFUNC double norm_one(const double4 x) { return ::simd_norm_one(x); }
    776   static SIMD_CPPFUNC double norm_one(const double8 x) { return ::simd_norm_one(x); }
    777   
    778   static SIMD_CPPFUNC _Float16 norm_inf(const half2  x) { return ::simd_norm_inf(x); }
    779   static SIMD_CPPFUNC _Float16 norm_inf(const half3  x) { return ::simd_norm_inf(x); }
    780   static SIMD_CPPFUNC _Float16 norm_inf(const half4  x) { return ::simd_norm_inf(x); }
    781   static SIMD_CPPFUNC _Float16 norm_inf(const half8  x) { return ::simd_norm_inf(x); }
    782   static SIMD_CPPFUNC _Float16 norm_inf(const half16 x) { return ::simd_norm_inf(x); }
    783   static SIMD_CPPFUNC _Float16 norm_inf(const half32 x) { return ::simd_norm_inf(x); }
    784   static SIMD_CPPFUNC float  norm_inf(const float2  x) { return ::simd_norm_inf(x); }
    785   static SIMD_CPPFUNC float  norm_inf(const float3  x) { return ::simd_norm_inf(x); }
    786   static SIMD_CPPFUNC float  norm_inf(const float4  x) { return ::simd_norm_inf(x); }
    787   static SIMD_CPPFUNC float  norm_inf(const float8  x) { return ::simd_norm_inf(x); }
    788   static SIMD_CPPFUNC float  norm_inf(const float16 x) { return ::simd_norm_inf(x); }
    789   static SIMD_CPPFUNC double norm_inf(const double2 x) { return ::simd_norm_inf(x); }
    790   static SIMD_CPPFUNC double norm_inf(const double3 x) { return ::simd_norm_inf(x); }
    791   static SIMD_CPPFUNC double norm_inf(const double4 x) { return ::simd_norm_inf(x); }
    792   static SIMD_CPPFUNC double norm_inf(const double8 x) { return ::simd_norm_inf(x); }
    793   
    794   static SIMD_CPPFUNC _Float16 length(const half2  x) { return ::simd_length(x); }
    795   static SIMD_CPPFUNC _Float16 length(const half3  x) { return ::simd_length(x); }
    796   static SIMD_CPPFUNC _Float16 length(const half4  x) { return ::simd_length(x); }
    797   static SIMD_CPPFUNC _Float16 length(const half8  x) { return ::simd_length(x); }
    798   static SIMD_CPPFUNC _Float16 length(const half16 x) { return ::simd_length(x); }
    799   static SIMD_CPPFUNC _Float16 length(const half32 x) { return ::simd_length(x); }
    800   static SIMD_CPPFUNC float  length(const float2  x) { return ::simd_length(x); }
    801   static SIMD_CPPFUNC float  length(const float3  x) { return ::simd_length(x); }
    802   static SIMD_CPPFUNC float  length(const float4  x) { return ::simd_length(x); }
    803   static SIMD_CPPFUNC float  length(const float8  x) { return ::simd_length(x); }
    804   static SIMD_CPPFUNC float  length(const float16 x) { return ::simd_length(x); }
    805   static SIMD_CPPFUNC double length(const double2 x) { return ::simd_length(x); }
    806   static SIMD_CPPFUNC double length(const double3 x) { return ::simd_length(x); }
    807   static SIMD_CPPFUNC double length(const double4 x) { return ::simd_length(x); }
    808   static SIMD_CPPFUNC double length(const double8 x) { return ::simd_length(x); }
    809   
    810   static SIMD_CPPFUNC _Float16 distance_squared(const half2  x, const half2  y) { return ::simd_distance_squared(x, y); }
    811   static SIMD_CPPFUNC _Float16 distance_squared(const half3  x, const half3  y) { return ::simd_distance_squared(x, y); }
    812   static SIMD_CPPFUNC _Float16 distance_squared(const half4  x, const half4  y) { return ::simd_distance_squared(x, y); }
    813   static SIMD_CPPFUNC _Float16 distance_squared(const half8  x, const half8  y) { return ::simd_distance_squared(x, y); }
    814   static SIMD_CPPFUNC _Float16 distance_squared(const half16 x, const half16 y) { return ::simd_distance_squared(x, y); }
    815   static SIMD_CPPFUNC _Float16 distance_squared(const half32 x, const half32 y) { return ::simd_distance_squared(x, y); }
    816   static SIMD_CPPFUNC float  distance_squared(const float2  x, const float2  y) { return ::simd_distance_squared(x, y); }
    817   static SIMD_CPPFUNC float  distance_squared(const float3  x, const float3  y) { return ::simd_distance_squared(x, y); }
    818   static SIMD_CPPFUNC float  distance_squared(const float4  x, const float4  y) { return ::simd_distance_squared(x, y); }
    819   static SIMD_CPPFUNC float  distance_squared(const float8  x, const float8  y) { return ::simd_distance_squared(x, y); }
    820   static SIMD_CPPFUNC float  distance_squared(const float16 x, const float16 y) { return ::simd_distance_squared(x, y); }
    821   static SIMD_CPPFUNC double distance_squared(const double2 x, const double2 y) { return ::simd_distance_squared(x, y); }
    822   static SIMD_CPPFUNC double distance_squared(const double3 x, const double3 y) { return ::simd_distance_squared(x, y); }
    823   static SIMD_CPPFUNC double distance_squared(const double4 x, const double4 y) { return ::simd_distance_squared(x, y); }
    824   static SIMD_CPPFUNC double distance_squared(const double8 x, const double8 y) { return ::simd_distance_squared(x, y); }
    825   
    826   static SIMD_CPPFUNC _Float16 distance(const half2  x, const half2  y) { return ::simd_distance(x, y); }
    827   static SIMD_CPPFUNC _Float16 distance(const half3  x, const half3  y) { return ::simd_distance(x, y); }
    828   static SIMD_CPPFUNC _Float16 distance(const half4  x, const half4  y) { return ::simd_distance(x, y); }
    829   static SIMD_CPPFUNC _Float16 distance(const half8  x, const half8  y) { return ::simd_distance(x, y); }
    830   static SIMD_CPPFUNC _Float16 distance(const half16 x, const half16 y) { return ::simd_distance(x, y); }
    831   static SIMD_CPPFUNC _Float16 distance(const half32 x, const half32 y) { return ::simd_distance(x, y); }
    832   static SIMD_CPPFUNC float  distance(const float2  x, const float2  y) { return ::simd_distance(x, y); }
    833   static SIMD_CPPFUNC float  distance(const float3  x, const float3  y) { return ::simd_distance(x, y); }
    834   static SIMD_CPPFUNC float  distance(const float4  x, const float4  y) { return ::simd_distance(x, y); }
    835   static SIMD_CPPFUNC float  distance(const float8  x, const float8  y) { return ::simd_distance(x, y); }
    836   static SIMD_CPPFUNC float  distance(const float16 x, const float16 y) { return ::simd_distance(x, y); }
    837   static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_distance(x, y); }
    838   static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_distance(x, y); }
    839   static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_distance(x, y); }
    840   static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_distance(x, y); }
    841   
    842   static SIMD_CPPFUNC half2   normalize(const half2   x) { return ::simd_normalize(x); }
    843   static SIMD_CPPFUNC half3   normalize(const half3   x) { return ::simd_normalize(x); }
    844   static SIMD_CPPFUNC half4   normalize(const half4   x) { return ::simd_normalize(x); }
    845   static SIMD_CPPFUNC half8   normalize(const half8   x) { return ::simd_normalize(x); }
    846   static SIMD_CPPFUNC half16  normalize(const half16  x) { return ::simd_normalize(x); }
    847   static SIMD_CPPFUNC half32  normalize(const half32  x) { return ::simd_normalize(x); }
    848   static SIMD_CPPFUNC float2  normalize(const float2  x) { return ::simd_normalize(x); }
    849   static SIMD_CPPFUNC float3  normalize(const float3  x) { return ::simd_normalize(x); }
    850   static SIMD_CPPFUNC float4  normalize(const float4  x) { return ::simd_normalize(x); }
    851   static SIMD_CPPFUNC float8  normalize(const float8  x) { return ::simd_normalize(x); }
    852   static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_normalize(x); }
    853   static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_normalize(x); }
    854   static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_normalize(x); }
    855   static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_normalize(x); }
    856   static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_normalize(x); }
    857   
    858   static SIMD_CPPFUNC half3   cross(const half2   x, const half2   y) { return ::simd_cross(x,y); }
    859   static SIMD_CPPFUNC half3   cross(const half3   x, const half3   y) { return ::simd_cross(x,y); }
    860   static SIMD_CPPFUNC float3  cross(const float2  x, const float2  y) { return ::simd_cross(x,y); }
    861   static SIMD_CPPFUNC float3  cross(const float3  x, const float3  y) { return ::simd_cross(x,y); }
    862   static SIMD_CPPFUNC double3 cross(const double2 x, const double2 y) { return ::simd_cross(x,y); }
    863   static SIMD_CPPFUNC double3 cross(const double3 x, const double3 y) { return ::simd_cross(x,y); }
    864   
    865   static SIMD_CPPFUNC half2   reflect(const half2   x, const half2   n) { return ::simd_reflect(x,n); }
    866   static SIMD_CPPFUNC half3   reflect(const half3   x, const half3   n) { return ::simd_reflect(x,n); }
    867   static SIMD_CPPFUNC half4   reflect(const half4   x, const half4   n) { return ::simd_reflect(x,n); }
    868   static SIMD_CPPFUNC float2  reflect(const float2  x, const float2  n) { return ::simd_reflect(x,n); }
    869   static SIMD_CPPFUNC float3  reflect(const float3  x, const float3  n) { return ::simd_reflect(x,n); }
    870   static SIMD_CPPFUNC float4  reflect(const float4  x, const float4  n) { return ::simd_reflect(x,n); }
    871   static SIMD_CPPFUNC double2 reflect(const double2 x, const double2 n) { return ::simd_reflect(x,n); }
    872   static SIMD_CPPFUNC double3 reflect(const double3 x, const double3 n) { return ::simd_reflect(x,n); }
    873   static SIMD_CPPFUNC double4 reflect(const double4 x, const double4 n) { return ::simd_reflect(x,n); }
    874 
    875 #if SIMD_LIBRARY_VERSION >= 6
    876   static SIMD_CPPFUNC half2   refract(const half2   x, const half2   n, const _Float16 eta) { return ::simd_refract(x,n,eta); }
    877   static SIMD_CPPFUNC half3   refract(const half3   x, const half3   n, const _Float16 eta) { return ::simd_refract(x,n,eta); }
    878   static SIMD_CPPFUNC half4   refract(const half4   x, const half4   n, const _Float16 eta) { return ::simd_refract(x,n,eta); }
    879 #endif // SIMD_LIBRARY_VERSION >= 6
    880   static SIMD_CPPFUNC float2  refract(const float2  x, const float2  n, const float eta) { return ::simd_refract(x,n,eta); }
    881   static SIMD_CPPFUNC float3  refract(const float3  x, const float3  n, const float eta) { return ::simd_refract(x,n,eta); }
    882   static SIMD_CPPFUNC float4  refract(const float4  x, const float4  n, const float eta) { return ::simd_refract(x,n,eta); }
    883   static SIMD_CPPFUNC double2 refract(const double2 x, const double2 n, const float eta) { return ::simd_refract(x,n,eta); }
    884   static SIMD_CPPFUNC double3 refract(const double3 x, const double3 n, const float eta) { return ::simd_refract(x,n,eta); }
    885   static SIMD_CPPFUNC double4 refract(const double4 x, const double4 n, const float eta) { return ::simd_refract(x,n,eta); }
    886   
    887 #if SIMD_LIBRARY_VERSION >= 2
    888   static SIMD_CPPFUNC float  orient(const float2  x, const float2 y) { return ::simd_orient(x,y); }
    889   static SIMD_CPPFUNC float  orient(const float2  a, const float2 b, const float2 c) { return ::simd_orient(a,b,c); }
    890   static SIMD_CPPFUNC float  orient(const float3  x, const float3 y, const float3 z) { return ::simd_orient(x,y,z); }
    891   static SIMD_CPPFUNC float  orient(const float3  a, const float3 b, const float3 c, const float3 d) { return ::simd_orient(a,b,c,d); }
    892   static SIMD_CPPFUNC double orient(const double2 x, const double2 y) { return ::simd_orient(x,y); }
    893   static SIMD_CPPFUNC double orient(const double2 a, const double2 b, const double2 c) { return ::simd_orient(a,b,c); }
    894   static SIMD_CPPFUNC double orient(const double3 x, const double3 y, const double3 z) { return ::simd_orient(x,y,z); }
    895   static SIMD_CPPFUNC double orient(const double3 a, const double3 b, const double3 c, const double3 d) { return ::simd_orient(a,b,c,d); }
    896 #endif
    897 
    898 #if SIMD_LIBRARY_VERSION >= 6
    899   static SIMD_CPPFUNC _Float16  orient(const half2  x, const half2 y) { return ::simd_orient(x,y); }
    900   static SIMD_CPPFUNC _Float16  orient(const half2  a, const half2 b, const half2 c) { return ::simd_orient(a,b,c); }
    901   static SIMD_CPPFUNC _Float16  orient(const half3  x, const half3 y, const half3 z) { return ::simd_orient(x,y,z); }
    902   static SIMD_CPPFUNC _Float16  orient(const half3  a, const half3 b, const half3 c, const half3 d) { return ::simd_orient(a,b,c,d); }
    903 #endif
    904 
    905   /* precise and fast sub-namespaces                                        */
    906   namespace precise {
    907     static SIMD_CPPFUNC half2   project(const half2   x, const half2   y) { return ::simd_precise_project(x, y); }
    908     static SIMD_CPPFUNC half3   project(const half3   x, const half3   y) { return ::simd_precise_project(x, y); }
    909     static SIMD_CPPFUNC half4   project(const half4   x, const half4   y) { return ::simd_precise_project(x, y); }
    910     static SIMD_CPPFUNC half8   project(const half8   x, const half8   y) { return ::simd_precise_project(x, y); }
    911     static SIMD_CPPFUNC half16  project(const half16  x, const half16  y) { return ::simd_precise_project(x, y); }
    912     static SIMD_CPPFUNC half32  project(const half32  x, const half32  y) { return ::simd_precise_project(x, y); }
    913     static SIMD_CPPFUNC float2  project(const float2  x, const float2  y) { return ::simd_precise_project(x, y); }
    914     static SIMD_CPPFUNC float3  project(const float3  x, const float3  y) { return ::simd_precise_project(x, y); }
    915     static SIMD_CPPFUNC float4  project(const float4  x, const float4  y) { return ::simd_precise_project(x, y); }
    916     static SIMD_CPPFUNC float8  project(const float8  x, const float8  y) { return ::simd_precise_project(x, y); }
    917     static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_precise_project(x, y); }
    918     static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_precise_project(x, y); }
    919     static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_precise_project(x, y); }
    920     static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_precise_project(x, y); }
    921     static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_precise_project(x, y); }
    922 
    923 #if SIMD_LIBRARY_VERSION >= 6
    924     static SIMD_CPPFUNC _Float16 length(const half2  x) { return ::simd_precise_length(x); }
    925     static SIMD_CPPFUNC _Float16 length(const half3  x) { return ::simd_precise_length(x); }
    926     static SIMD_CPPFUNC _Float16 length(const half4  x) { return ::simd_precise_length(x); }
    927     static SIMD_CPPFUNC _Float16 length(const half8  x) { return ::simd_precise_length(x); }
    928     static SIMD_CPPFUNC _Float16 length(const half16 x) { return ::simd_precise_length(x); }
    929     static SIMD_CPPFUNC _Float16 length(const half32 x) { return ::simd_precise_length(x); }
    930 #endif // #if SIMD_LIBRARY_VERSION >= 6
    931     static SIMD_CPPFUNC float  length(const float2  x) { return ::simd_precise_length(x); }
    932     static SIMD_CPPFUNC float  length(const float3  x) { return ::simd_precise_length(x); }
    933     static SIMD_CPPFUNC float  length(const float4  x) { return ::simd_precise_length(x); }
    934     static SIMD_CPPFUNC float  length(const float8  x) { return ::simd_precise_length(x); }
    935     static SIMD_CPPFUNC float  length(const float16 x) { return ::simd_precise_length(x); }
    936     static SIMD_CPPFUNC double length(const double2 x) { return ::simd_precise_length(x); }
    937     static SIMD_CPPFUNC double length(const double3 x) { return ::simd_precise_length(x); }
    938     static SIMD_CPPFUNC double length(const double4 x) { return ::simd_precise_length(x); }
    939     static SIMD_CPPFUNC double length(const double8 x) { return ::simd_precise_length(x); }
    940     
    941     static SIMD_CPPFUNC _Float16 distance(const half2  x, const half2  y) { return ::simd_precise_distance(x, y); }
    942     static SIMD_CPPFUNC _Float16 distance(const half3  x, const half3  y) { return ::simd_precise_distance(x, y); }
    943     static SIMD_CPPFUNC _Float16 distance(const half4  x, const half4  y) { return ::simd_precise_distance(x, y); }
    944     static SIMD_CPPFUNC _Float16 distance(const half8  x, const half8  y) { return ::simd_precise_distance(x, y); }
    945     static SIMD_CPPFUNC _Float16 distance(const half16 x, const half16 y) { return ::simd_precise_distance(x, y); }
    946     static SIMD_CPPFUNC _Float16 distance(const half32 x, const half32 y) { return ::simd_precise_distance(x, y); }
    947     static SIMD_CPPFUNC float  distance(const float2  x, const float2  y) { return ::simd_precise_distance(x, y); }
    948     static SIMD_CPPFUNC float  distance(const float3  x, const float3  y) { return ::simd_precise_distance(x, y); }
    949     static SIMD_CPPFUNC float  distance(const float4  x, const float4  y) { return ::simd_precise_distance(x, y); }
    950     static SIMD_CPPFUNC float  distance(const float8  x, const float8  y) { return ::simd_precise_distance(x, y); }
    951     static SIMD_CPPFUNC float  distance(const float16 x, const float16 y) { return ::simd_precise_distance(x, y); }
    952     static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_precise_distance(x, y); }
    953     static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_precise_distance(x, y); }
    954     static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_precise_distance(x, y); }
    955     static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_precise_distance(x, y); }
    956     
    957     static SIMD_CPPFUNC half2   normalize(const half2   x) { return ::simd_precise_normalize(x); }
    958     static SIMD_CPPFUNC half3   normalize(const half3   x) { return ::simd_precise_normalize(x); }
    959     static SIMD_CPPFUNC half4   normalize(const half4   x) { return ::simd_precise_normalize(x); }
    960     static SIMD_CPPFUNC half8   normalize(const half8   x) { return ::simd_precise_normalize(x); }
    961     static SIMD_CPPFUNC half16  normalize(const half16  x) { return ::simd_precise_normalize(x); }
    962     static SIMD_CPPFUNC half32  normalize(const half32  x) { return ::simd_precise_normalize(x); }
    963     static SIMD_CPPFUNC float2  normalize(const float2  x) { return ::simd_precise_normalize(x); }
    964     static SIMD_CPPFUNC float3  normalize(const float3  x) { return ::simd_precise_normalize(x); }
    965     static SIMD_CPPFUNC float4  normalize(const float4  x) { return ::simd_precise_normalize(x); }
    966     static SIMD_CPPFUNC float8  normalize(const float8  x) { return ::simd_precise_normalize(x); }
    967     static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_precise_normalize(x); }
    968     static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_precise_normalize(x); }
    969     static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_precise_normalize(x); }
    970     static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_precise_normalize(x); }
    971     static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_precise_normalize(x); }
    972   }
    973   
    974   namespace fast {
    975     static SIMD_CPPFUNC half2   project(const half2   x, const half2   y) { return ::simd_fast_project(x, y); }
    976     static SIMD_CPPFUNC half3   project(const half3   x, const half3   y) { return ::simd_fast_project(x, y); }
    977     static SIMD_CPPFUNC half4   project(const half4   x, const half4   y) { return ::simd_fast_project(x, y); }
    978     static SIMD_CPPFUNC half8   project(const half8   x, const half8   y) { return ::simd_fast_project(x, y); }
    979     static SIMD_CPPFUNC half16  project(const half16  x, const half16  y) { return ::simd_fast_project(x, y); }
    980     static SIMD_CPPFUNC half32  project(const half32  x, const half32  y) { return ::simd_fast_project(x, y); }
    981     static SIMD_CPPFUNC float2  project(const float2  x, const float2  y) { return ::simd_fast_project(x, y); }
    982     static SIMD_CPPFUNC float3  project(const float3  x, const float3  y) { return ::simd_fast_project(x, y); }
    983     static SIMD_CPPFUNC float4  project(const float4  x, const float4  y) { return ::simd_fast_project(x, y); }
    984     static SIMD_CPPFUNC float8  project(const float8  x, const float8  y) { return ::simd_fast_project(x, y); }
    985     static SIMD_CPPFUNC float16 project(const float16 x, const float16 y) { return ::simd_fast_project(x, y); }
    986     static SIMD_CPPFUNC double2 project(const double2 x, const double2 y) { return ::simd_fast_project(x, y); }
    987     static SIMD_CPPFUNC double3 project(const double3 x, const double3 y) { return ::simd_fast_project(x, y); }
    988     static SIMD_CPPFUNC double4 project(const double4 x, const double4 y) { return ::simd_fast_project(x, y); }
    989     static SIMD_CPPFUNC double8 project(const double8 x, const double8 y) { return ::simd_fast_project(x, y); }
    990     
    991     static SIMD_CPPFUNC _Float16 length(const half2  x) { return ::simd_fast_length(x); }
    992     static SIMD_CPPFUNC _Float16 length(const half3  x) { return ::simd_fast_length(x); }
    993     static SIMD_CPPFUNC _Float16 length(const half4  x) { return ::simd_fast_length(x); }
    994     static SIMD_CPPFUNC _Float16 length(const half8  x) { return ::simd_fast_length(x); }
    995     static SIMD_CPPFUNC _Float16 length(const half16 x) { return ::simd_fast_length(x); }
    996     static SIMD_CPPFUNC _Float16 length(const half32 x) { return ::simd_fast_length(x); }
    997     static SIMD_CPPFUNC float  length(const float2  x) { return ::simd_fast_length(x); }
    998     static SIMD_CPPFUNC float  length(const float3  x) { return ::simd_fast_length(x); }
    999     static SIMD_CPPFUNC float  length(const float4  x) { return ::simd_fast_length(x); }
   1000     static SIMD_CPPFUNC float  length(const float8  x) { return ::simd_fast_length(x); }
   1001     static SIMD_CPPFUNC float  length(const float16 x) { return ::simd_fast_length(x); }
   1002     static SIMD_CPPFUNC double length(const double2 x) { return ::simd_fast_length(x); }
   1003     static SIMD_CPPFUNC double length(const double3 x) { return ::simd_fast_length(x); }
   1004     static SIMD_CPPFUNC double length(const double4 x) { return ::simd_fast_length(x); }
   1005     static SIMD_CPPFUNC double length(const double8 x) { return ::simd_fast_length(x); }
   1006     
   1007     static SIMD_CPPFUNC _Float16 distance(const half2  x, const half2  y) { return ::simd_fast_distance(x, y); }
   1008     static SIMD_CPPFUNC _Float16 distance(const half3  x, const half3  y) { return ::simd_fast_distance(x, y); }
   1009     static SIMD_CPPFUNC _Float16 distance(const half4  x, const half4  y) { return ::simd_fast_distance(x, y); }
   1010     static SIMD_CPPFUNC _Float16 distance(const half8  x, const half8  y) { return ::simd_fast_distance(x, y); }
   1011     static SIMD_CPPFUNC _Float16 distance(const half16 x, const half16 y) { return ::simd_fast_distance(x, y); }
   1012     static SIMD_CPPFUNC _Float16 distance(const half32 x, const half32 y) { return ::simd_fast_distance(x, y); }
   1013     static SIMD_CPPFUNC float  distance(const float2  x, const float2  y) { return ::simd_fast_distance(x, y); }
   1014     static SIMD_CPPFUNC float  distance(const float3  x, const float3  y) { return ::simd_fast_distance(x, y); }
   1015     static SIMD_CPPFUNC float  distance(const float4  x, const float4  y) { return ::simd_fast_distance(x, y); }
   1016     static SIMD_CPPFUNC float  distance(const float8  x, const float8  y) { return ::simd_fast_distance(x, y); }
   1017     static SIMD_CPPFUNC float  distance(const float16 x, const float16 y) { return ::simd_fast_distance(x, y); }
   1018     static SIMD_CPPFUNC double distance(const double2 x, const double2 y) { return ::simd_fast_distance(x, y); }
   1019     static SIMD_CPPFUNC double distance(const double3 x, const double3 y) { return ::simd_fast_distance(x, y); }
   1020     static SIMD_CPPFUNC double distance(const double4 x, const double4 y) { return ::simd_fast_distance(x, y); }
   1021     static SIMD_CPPFUNC double distance(const double8 x, const double8 y) { return ::simd_fast_distance(x, y); }
   1022     
   1023     static SIMD_CPPFUNC half2   normalize(const half2   x) { return ::simd_fast_normalize(x); }
   1024     static SIMD_CPPFUNC half3   normalize(const half3   x) { return ::simd_fast_normalize(x); }
   1025     static SIMD_CPPFUNC half4   normalize(const half4   x) { return ::simd_fast_normalize(x); }
   1026     static SIMD_CPPFUNC half8   normalize(const half8   x) { return ::simd_fast_normalize(x); }
   1027     static SIMD_CPPFUNC half16  normalize(const half16  x) { return ::simd_fast_normalize(x); }
   1028     static SIMD_CPPFUNC half32  normalize(const half32  x) { return ::simd_fast_normalize(x); }
   1029     static SIMD_CPPFUNC float2  normalize(const float2  x) { return ::simd_fast_normalize(x); }
   1030     static SIMD_CPPFUNC float3  normalize(const float3  x) { return ::simd_fast_normalize(x); }
   1031     static SIMD_CPPFUNC float4  normalize(const float4  x) { return ::simd_fast_normalize(x); }
   1032     static SIMD_CPPFUNC float8  normalize(const float8  x) { return ::simd_fast_normalize(x); }
   1033     static SIMD_CPPFUNC float16 normalize(const float16 x) { return ::simd_fast_normalize(x); }
   1034     static SIMD_CPPFUNC double2 normalize(const double2 x) { return ::simd_fast_normalize(x); }
   1035     static SIMD_CPPFUNC double3 normalize(const double3 x) { return ::simd_fast_normalize(x); }
   1036     static SIMD_CPPFUNC double4 normalize(const double4 x) { return ::simd_fast_normalize(x); }
   1037     static SIMD_CPPFUNC double8 normalize(const double8 x) { return ::simd_fast_normalize(x); }
   1038   }
   1039 }
   1040 
   1041 extern "C" {
   1042 #endif /* __cplusplus */
   1043   
   1044 #pragma mark - Implementation
   1045 
   1046 static _Float16 SIMD_CFUNC simd_dot(simd_half2  __x, simd_half2  __y) { return simd_reduce_add(__x*__y); }
   1047 static _Float16 SIMD_CFUNC simd_dot(simd_half3  __x, simd_half3  __y) { return simd_reduce_add(__x*__y); }
   1048 static _Float16 SIMD_CFUNC simd_dot(simd_half4  __x, simd_half4  __y) { return simd_reduce_add(__x*__y); }
   1049 static _Float16 SIMD_CFUNC simd_dot(simd_half8  __x, simd_half8  __y) { return simd_reduce_add(__x*__y); }
   1050 static _Float16 SIMD_CFUNC simd_dot(simd_half16 __x, simd_half16 __y) { return simd_reduce_add(__x*__y); }
   1051 static _Float16 SIMD_CFUNC simd_dot(simd_half32 __x, simd_half32 __y) { return simd_reduce_add(__x*__y); }
   1052 static float  SIMD_CFUNC simd_dot(simd_float2  __x, simd_float2  __y) { return simd_reduce_add(__x*__y); }
   1053 static float  SIMD_CFUNC simd_dot(simd_float3  __x, simd_float3  __y) { return simd_reduce_add(__x*__y); }
   1054 static float  SIMD_CFUNC simd_dot(simd_float4  __x, simd_float4  __y) { return simd_reduce_add(__x*__y); }
   1055 static float  SIMD_CFUNC simd_dot(simd_float8  __x, simd_float8  __y) { return simd_reduce_add(__x*__y); }
   1056 static float  SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y) { return simd_reduce_add(__x*__y); }
   1057 static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y) { return simd_reduce_add(__x*__y); }
   1058 static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y) { return simd_reduce_add(__x*__y); }
   1059 static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y) { return simd_reduce_add(__x*__y); }
   1060 static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y) { return simd_reduce_add(__x*__y); }
   1061 
   1062 static simd_half2   SIMD_CFUNC simd_precise_project(simd_half2   __x, simd_half2   __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1063 static simd_half3   SIMD_CFUNC simd_precise_project(simd_half3   __x, simd_half3   __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1064 static simd_half4   SIMD_CFUNC simd_precise_project(simd_half4   __x, simd_half4   __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1065 static simd_half8   SIMD_CFUNC simd_precise_project(simd_half8   __x, simd_half8   __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1066 static simd_half16  SIMD_CFUNC simd_precise_project(simd_half16  __x, simd_half16  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1067 static simd_half32  SIMD_CFUNC simd_precise_project(simd_half32  __x, simd_half32  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1068 static simd_float2  SIMD_CFUNC simd_precise_project(simd_float2  __x, simd_float2  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1069 static simd_float3  SIMD_CFUNC simd_precise_project(simd_float3  __x, simd_float3  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1070 static simd_float4  SIMD_CFUNC simd_precise_project(simd_float4  __x, simd_float4  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1071 static simd_float8  SIMD_CFUNC simd_precise_project(simd_float8  __x, simd_float8  __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1072 static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1073 static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1074 static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1075 static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1076 static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
   1077 
   1078 static simd_half2   SIMD_CFUNC simd_fast_project(simd_half2   __x, simd_half2   __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1079 static simd_half3   SIMD_CFUNC simd_fast_project(simd_half3   __x, simd_half3   __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1080 static simd_half4   SIMD_CFUNC simd_fast_project(simd_half4   __x, simd_half4   __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1081 static simd_half8   SIMD_CFUNC simd_fast_project(simd_half8   __x, simd_half8   __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1082 static simd_half16  SIMD_CFUNC simd_fast_project(simd_half16  __x, simd_half16  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1083 static simd_half32  SIMD_CFUNC simd_fast_project(simd_half32  __x, simd_half32  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1084 static simd_float2  SIMD_CFUNC simd_fast_project(simd_float2  __x, simd_float2  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1085 static simd_float3  SIMD_CFUNC simd_fast_project(simd_float3  __x, simd_float3  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1086 static simd_float4  SIMD_CFUNC simd_fast_project(simd_float4  __x, simd_float4  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1087 static simd_float8  SIMD_CFUNC simd_fast_project(simd_float8  __x, simd_float8  __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1088 static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1089 static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1090 static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1091 static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1092 static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y) { return __y*simd_dot(__x,__y)*simd_fast_recip(simd_dot(__y,__y)); }
   1093 
   1094 #if defined __FAST_MATH__
   1095 static simd_half2   SIMD_CFUNC simd_project(simd_half2   __x, simd_half2   __y) { return simd_fast_project(__x,__y); }
   1096 static simd_half3   SIMD_CFUNC simd_project(simd_half3   __x, simd_half3   __y) { return simd_fast_project(__x,__y); }
   1097 static simd_half4   SIMD_CFUNC simd_project(simd_half4   __x, simd_half4   __y) { return simd_fast_project(__x,__y); }
   1098 static simd_half8   SIMD_CFUNC simd_project(simd_half8   __x, simd_half8   __y) { return simd_fast_project(__x,__y); }
   1099 static simd_half16  SIMD_CFUNC simd_project(simd_half16  __x, simd_half16  __y) { return simd_fast_project(__x,__y); }
   1100 static simd_half32  SIMD_CFUNC simd_project(simd_half32  __x, simd_half32  __y) { return simd_fast_project(__x,__y); }
   1101 static simd_float2  SIMD_CFUNC simd_project(simd_float2  __x, simd_float2  __y) { return simd_fast_project(__x,__y); }
   1102 static simd_float3  SIMD_CFUNC simd_project(simd_float3  __x, simd_float3  __y) { return simd_fast_project(__x,__y); }
   1103 static simd_float4  SIMD_CFUNC simd_project(simd_float4  __x, simd_float4  __y) { return simd_fast_project(__x,__y); }
   1104 static simd_float8  SIMD_CFUNC simd_project(simd_float8  __x, simd_float8  __y) { return simd_fast_project(__x,__y); }
   1105 static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_fast_project(__x,__y); }
   1106 static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_fast_project(__x,__y); }
   1107 static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_fast_project(__x,__y); }
   1108 static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_fast_project(__x,__y); }
   1109 static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_fast_project(__x,__y); }
   1110 #else
   1111 static simd_half2   SIMD_CFUNC simd_project(simd_half2   __x, simd_half2   __y) { return simd_precise_project(__x,__y); }
   1112 static simd_half3   SIMD_CFUNC simd_project(simd_half3   __x, simd_half3   __y) { return simd_precise_project(__x,__y); }
   1113 static simd_half4   SIMD_CFUNC simd_project(simd_half4   __x, simd_half4   __y) { return simd_precise_project(__x,__y); }
   1114 static simd_half8   SIMD_CFUNC simd_project(simd_half8   __x, simd_half8   __y) { return simd_precise_project(__x,__y); }
   1115 static simd_half16  SIMD_CFUNC simd_project(simd_half16  __x, simd_half16  __y) { return simd_precise_project(__x,__y); }
   1116 static simd_half32  SIMD_CFUNC simd_project(simd_half32  __x, simd_half32  __y) { return simd_precise_project(__x,__y); }
   1117 static simd_float2  SIMD_CFUNC simd_project(simd_float2  __x, simd_float2  __y) { return simd_precise_project(__x,__y); }
   1118 static simd_float3  SIMD_CFUNC simd_project(simd_float3  __x, simd_float3  __y) { return simd_precise_project(__x,__y); }
   1119 static simd_float4  SIMD_CFUNC simd_project(simd_float4  __x, simd_float4  __y) { return simd_precise_project(__x,__y); }
   1120 static simd_float8  SIMD_CFUNC simd_project(simd_float8  __x, simd_float8  __y) { return simd_precise_project(__x,__y); }
   1121 static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_precise_project(__x,__y); }
   1122 static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_precise_project(__x,__y); }
   1123 static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_precise_project(__x,__y); }
   1124 static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_precise_project(__x,__y); }
   1125 static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_precise_project(__x,__y); }
   1126 #endif
   1127 
   1128 #if SIMD_LIBRARY_VERSION >= 6
   1129 static _Float16 SIMD_CFUNC simd_precise_length(simd_half2  __x) { return __sqrtf16(simd_length_squared(__x)); }
   1130 static _Float16 SIMD_CFUNC simd_precise_length(simd_half3  __x) { return __sqrtf16(simd_length_squared(__x)); }
   1131 static _Float16 SIMD_CFUNC simd_precise_length(simd_half4  __x) { return __sqrtf16(simd_length_squared(__x)); }
   1132 static _Float16 SIMD_CFUNC simd_precise_length(simd_half8  __x) { return __sqrtf16(simd_length_squared(__x)); }
   1133 static _Float16 SIMD_CFUNC simd_precise_length(simd_half16 __x) { return __sqrtf16(simd_length_squared(__x)); }
   1134 static _Float16 SIMD_CFUNC simd_precise_length(simd_half32 __x) { return __sqrtf16(simd_length_squared(__x)); }
   1135 #endif // SIMD_LIBRARY_VERSION >= 6
   1136 static float  SIMD_CFUNC simd_precise_length(simd_float2  __x) { return sqrtf(simd_length_squared(__x)); }
   1137 static float  SIMD_CFUNC simd_precise_length(simd_float3  __x) { return sqrtf(simd_length_squared(__x)); }
   1138 static float  SIMD_CFUNC simd_precise_length(simd_float4  __x) { return sqrtf(simd_length_squared(__x)); }
   1139 static float  SIMD_CFUNC simd_precise_length(simd_float8  __x) { return sqrtf(simd_length_squared(__x)); }
   1140 static float  SIMD_CFUNC simd_precise_length(simd_float16 __x) { return sqrtf(simd_length_squared(__x)); }
   1141 static double SIMD_CFUNC simd_precise_length(simd_double2 __x) { return sqrt(simd_length_squared(__x)); }
   1142 static double SIMD_CFUNC simd_precise_length(simd_double3 __x) { return sqrt(simd_length_squared(__x)); }
   1143 static double SIMD_CFUNC simd_precise_length(simd_double4 __x) { return sqrt(simd_length_squared(__x)); }
   1144 static double SIMD_CFUNC simd_precise_length(simd_double8 __x) { return sqrt(simd_length_squared(__x)); }
   1145 #if SIMD_LIBRARY_VERSION >= 6
   1146 static _Float16 SIMD_CFUNC simd_fast_length(simd_half2  __x) { return simd_precise_length(__x); }
   1147 static _Float16 SIMD_CFUNC simd_fast_length(simd_half3  __x) { return simd_precise_length(__x); }
   1148 static _Float16 SIMD_CFUNC simd_fast_length(simd_half4  __x) { return simd_precise_length(__x); }
   1149 static _Float16 SIMD_CFUNC simd_fast_length(simd_half8  __x) { return simd_precise_length(__x); }
   1150 static _Float16 SIMD_CFUNC simd_fast_length(simd_half16 __x) { return simd_precise_length(__x); }
   1151 static _Float16 SIMD_CFUNC simd_fast_length(simd_half32 __x) { return simd_precise_length(__x); }
   1152 #endif // SIMD_LIBRARY_VERSION >= 6
   1153 static float  SIMD_CFUNC simd_fast_length(simd_float2  __x) { return simd_precise_length(__x); }
   1154 static float  SIMD_CFUNC simd_fast_length(simd_float3  __x) { return simd_precise_length(__x); }
   1155 static float  SIMD_CFUNC simd_fast_length(simd_float4  __x) { return simd_precise_length(__x); }
   1156 static float  SIMD_CFUNC simd_fast_length(simd_float8  __x) { return simd_precise_length(__x); }
   1157 static float  SIMD_CFUNC simd_fast_length(simd_float16 __x) { return simd_precise_length(__x); }
   1158 static double SIMD_CFUNC simd_fast_length(simd_double2 __x) { return simd_precise_length(__x); }
   1159 static double SIMD_CFUNC simd_fast_length(simd_double3 __x) { return simd_precise_length(__x); }
   1160 static double SIMD_CFUNC simd_fast_length(simd_double4 __x) { return simd_precise_length(__x); }
   1161 static double SIMD_CFUNC simd_fast_length(simd_double8 __x) { return simd_precise_length(__x); }
   1162 
   1163 #if defined __FAST_MATH__
   1164 static _Float16 SIMD_CFUNC simd_length(simd_half2  __x) { return simd_fast_length(__x); }
   1165 static _Float16 SIMD_CFUNC simd_length(simd_half3  __x) { return simd_fast_length(__x); }
   1166 static _Float16 SIMD_CFUNC simd_length(simd_half4  __x) { return simd_fast_length(__x); }
   1167 static _Float16 SIMD_CFUNC simd_length(simd_half8  __x) { return simd_fast_length(__x); }
   1168 static _Float16 SIMD_CFUNC simd_length(simd_half16 __x) { return simd_fast_length(__x); }
   1169 static _Float16 SIMD_CFUNC simd_length(simd_half32 __x) { return simd_fast_length(__x); }
   1170 static float  SIMD_CFUNC simd_length(simd_float2  __x) { return simd_fast_length(__x); }
   1171 static float  SIMD_CFUNC simd_length(simd_float3  __x) { return simd_fast_length(__x); }
   1172 static float  SIMD_CFUNC simd_length(simd_float4  __x) { return simd_fast_length(__x); }
   1173 static float  SIMD_CFUNC simd_length(simd_float8  __x) { return simd_fast_length(__x); }
   1174 static float  SIMD_CFUNC simd_length(simd_float16 __x) { return simd_fast_length(__x); }
   1175 static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_fast_length(__x); }
   1176 static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_fast_length(__x); }
   1177 static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_fast_length(__x); }
   1178 static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_fast_length(__x); }
   1179 #else
   1180 #if SIMD_LIBRARY_VERSION >= 6
   1181 static _Float16 SIMD_CFUNC simd_length(simd_half2  __x) { return simd_precise_length(__x); }
   1182 static _Float16 SIMD_CFUNC simd_length(simd_half3  __x) { return simd_precise_length(__x); }
   1183 static _Float16 SIMD_CFUNC simd_length(simd_half4  __x) { return simd_precise_length(__x); }
   1184 static _Float16 SIMD_CFUNC simd_length(simd_half8  __x) { return simd_precise_length(__x); }
   1185 static _Float16 SIMD_CFUNC simd_length(simd_half16 __x) { return simd_precise_length(__x); }
   1186 static _Float16 SIMD_CFUNC simd_length(simd_half32 __x) { return simd_precise_length(__x); }
   1187 #endif // SIMD_LIBRARY_VERSION >= 6
   1188 static float  SIMD_CFUNC simd_length(simd_float2  __x) { return simd_precise_length(__x); }
   1189 static float  SIMD_CFUNC simd_length(simd_float3  __x) { return simd_precise_length(__x); }
   1190 static float  SIMD_CFUNC simd_length(simd_float4  __x) { return simd_precise_length(__x); }
   1191 static float  SIMD_CFUNC simd_length(simd_float8  __x) { return simd_precise_length(__x); }
   1192 static float  SIMD_CFUNC simd_length(simd_float16 __x) { return simd_precise_length(__x); }
   1193 static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_precise_length(__x); }
   1194 static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_precise_length(__x); }
   1195 static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_precise_length(__x); }
   1196 static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_precise_length(__x); }
   1197 #endif
   1198 
   1199 static _Float16 SIMD_CFUNC simd_length_squared(simd_half2  __x) { return simd_dot(__x,__x); }
   1200 static _Float16 SIMD_CFUNC simd_length_squared(simd_half3  __x) { return simd_dot(__x,__x); }
   1201 static _Float16 SIMD_CFUNC simd_length_squared(simd_half4  __x) { return simd_dot(__x,__x); }
   1202 static _Float16 SIMD_CFUNC simd_length_squared(simd_half8  __x) { return simd_dot(__x,__x); }
   1203 static _Float16 SIMD_CFUNC simd_length_squared(simd_half16 __x) { return simd_dot(__x,__x); }
   1204 static _Float16 SIMD_CFUNC simd_length_squared(simd_half32 __x) { return simd_dot(__x,__x); }
   1205 static float  SIMD_CFUNC simd_length_squared(simd_float2  __x) { return simd_dot(__x,__x); }
   1206 static float  SIMD_CFUNC simd_length_squared(simd_float3  __x) { return simd_dot(__x,__x); }
   1207 static float  SIMD_CFUNC simd_length_squared(simd_float4  __x) { return simd_dot(__x,__x); }
   1208 static float  SIMD_CFUNC simd_length_squared(simd_float8  __x) { return simd_dot(__x,__x); }
   1209 static float  SIMD_CFUNC simd_length_squared(simd_float16 __x) { return simd_dot(__x,__x); }
   1210 static double SIMD_CFUNC simd_length_squared(simd_double2 __x) { return simd_dot(__x,__x); }
   1211 static double SIMD_CFUNC simd_length_squared(simd_double3 __x) { return simd_dot(__x,__x); }
   1212 static double SIMD_CFUNC simd_length_squared(simd_double4 __x) { return simd_dot(__x,__x); }
   1213 static double SIMD_CFUNC simd_length_squared(simd_double8 __x) { return simd_dot(__x,__x); }
   1214 
   1215 static _Float16 SIMD_CFUNC simd_norm_one(simd_half2  __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1216 static _Float16 SIMD_CFUNC simd_norm_one(simd_half3  __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1217 static _Float16 SIMD_CFUNC simd_norm_one(simd_half4  __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1218 static _Float16 SIMD_CFUNC simd_norm_one(simd_half8  __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1219 static _Float16 SIMD_CFUNC simd_norm_one(simd_half16 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1220 static _Float16 SIMD_CFUNC simd_norm_one(simd_half32 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1221 static float SIMD_CFUNC simd_norm_one(simd_float2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1222 static float SIMD_CFUNC simd_norm_one(simd_float3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1223 static float SIMD_CFUNC simd_norm_one(simd_float4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1224 static float SIMD_CFUNC simd_norm_one(simd_float8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1225 static float SIMD_CFUNC simd_norm_one(simd_float16 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1226 static double SIMD_CFUNC simd_norm_one(simd_double2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1227 static double SIMD_CFUNC simd_norm_one(simd_double3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1228 static double SIMD_CFUNC simd_norm_one(simd_double4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1229 static double SIMD_CFUNC simd_norm_one(simd_double8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
   1230 
   1231 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half2  __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1232 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half3  __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1233 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half4  __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1234 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half8  __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1235 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half16 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1236 static _Float16 SIMD_CFUNC simd_norm_inf(simd_half32 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1237 static float SIMD_CFUNC simd_norm_inf(simd_float2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1238 static float SIMD_CFUNC simd_norm_inf(simd_float3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1239 static float SIMD_CFUNC simd_norm_inf(simd_float4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1240 static float SIMD_CFUNC simd_norm_inf(simd_float8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1241 static float SIMD_CFUNC simd_norm_inf(simd_float16 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1242 static double SIMD_CFUNC simd_norm_inf(simd_double2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1243 static double SIMD_CFUNC simd_norm_inf(simd_double3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1244 static double SIMD_CFUNC simd_norm_inf(simd_double4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1245 static double SIMD_CFUNC simd_norm_inf(simd_double8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
   1246 
   1247 #if SIMD_LIBRARY_VERSION >= 6
   1248 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half2  __x, simd_half2  __y) { return simd_precise_length(__x - __y); }
   1249 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half3  __x, simd_half3  __y) { return simd_precise_length(__x - __y); }
   1250 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half4  __x, simd_half4  __y) { return simd_precise_length(__x - __y); }
   1251 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half8  __x, simd_half8  __y) { return simd_precise_length(__x - __y); }
   1252 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half16 __x, simd_half16 __y) { return simd_precise_length(__x - __y); }
   1253 static _Float16 SIMD_CFUNC simd_precise_distance(simd_half32 __x, simd_half32 __y) { return simd_precise_length(__x - __y); }
   1254 #endif // SIMD_LIBRARY_VERSION >= 6
   1255 static float  SIMD_CFUNC simd_precise_distance(simd_float2  __x, simd_float2  __y) { return simd_precise_length(__x - __y); }
   1256 static float  SIMD_CFUNC simd_precise_distance(simd_float3  __x, simd_float3  __y) { return simd_precise_length(__x - __y); }
   1257 static float  SIMD_CFUNC simd_precise_distance(simd_float4  __x, simd_float4  __y) { return simd_precise_length(__x - __y); }
   1258 static float  SIMD_CFUNC simd_precise_distance(simd_float8  __x, simd_float8  __y) { return simd_precise_length(__x - __y); }
   1259 static float  SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_length(__x - __y); }
   1260 static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_length(__x - __y); }
   1261 static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_length(__x - __y); }
   1262 static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_length(__x - __y); }
   1263 static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_length(__x - __y); }
   1264 
   1265 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half2  __x, simd_half2  __y) { return simd_fast_length(__x - __y); }
   1266 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half3  __x, simd_half3  __y) { return simd_fast_length(__x - __y); }
   1267 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half4  __x, simd_half4  __y) { return simd_fast_length(__x - __y); }
   1268 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half8  __x, simd_half8  __y) { return simd_fast_length(__x - __y); }
   1269 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half16 __x, simd_half16 __y) { return simd_fast_length(__x - __y); }
   1270 static _Float16 SIMD_CFUNC simd_fast_distance(simd_half32 __x, simd_half32 __y) { return simd_fast_length(__x - __y); }
   1271 static float  SIMD_CFUNC simd_fast_distance(simd_float2  __x, simd_float2  __y) { return simd_fast_length(__x - __y); }
   1272 static float  SIMD_CFUNC simd_fast_distance(simd_float3  __x, simd_float3  __y) { return simd_fast_length(__x - __y); }
   1273 static float  SIMD_CFUNC simd_fast_distance(simd_float4  __x, simd_float4  __y) { return simd_fast_length(__x - __y); }
   1274 static float  SIMD_CFUNC simd_fast_distance(simd_float8  __x, simd_float8  __y) { return simd_fast_length(__x - __y); }
   1275 static float  SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_length(__x - __y); }
   1276 static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_length(__x - __y); }
   1277 static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_length(__x - __y); }
   1278 static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_length(__x - __y); }
   1279 static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_length(__x - __y); }
   1280 
   1281 #if defined __FAST_MATH__
   1282 static _Float16 SIMD_CFUNC simd_distance(simd_half2  __x, simd_half2  __y) { return simd_fast_distance(__x,__y); }
   1283 static _Float16 SIMD_CFUNC simd_distance(simd_half3  __x, simd_half3  __y) { return simd_fast_distance(__x,__y); }
   1284 static _Float16 SIMD_CFUNC simd_distance(simd_half4  __x, simd_half4  __y) { return simd_fast_distance(__x,__y); }
   1285 static _Float16 SIMD_CFUNC simd_distance(simd_half8  __x, simd_half8  __y) { return simd_fast_distance(__x,__y); }
   1286 static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y) { return simd_fast_distance(__x,__y); }
   1287 static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y) { return simd_fast_distance(__x,__y); }
   1288 static float  SIMD_CFUNC simd_distance(simd_float2  __x, simd_float2  __y) { return simd_fast_distance(__x,__y); }
   1289 static float  SIMD_CFUNC simd_distance(simd_float3  __x, simd_float3  __y) { return simd_fast_distance(__x,__y); }
   1290 static float  SIMD_CFUNC simd_distance(simd_float4  __x, simd_float4  __y) { return simd_fast_distance(__x,__y); }
   1291 static float  SIMD_CFUNC simd_distance(simd_float8  __x, simd_float8  __y) { return simd_fast_distance(__x,__y); }
   1292 static float  SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_distance(__x,__y); }
   1293 static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_distance(__x,__y); }
   1294 static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_distance(__x,__y); }
   1295 static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_distance(__x,__y); }
   1296 static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_distance(__x,__y); }
   1297 #else
   1298 static _Float16 SIMD_CFUNC simd_distance(simd_half2  __x, simd_half2  __y) { return simd_precise_distance(__x,__y); }
   1299 static _Float16 SIMD_CFUNC simd_distance(simd_half3  __x, simd_half3  __y) { return simd_precise_distance(__x,__y); }
   1300 static _Float16 SIMD_CFUNC simd_distance(simd_half4  __x, simd_half4  __y) { return simd_precise_distance(__x,__y); }
   1301 static _Float16 SIMD_CFUNC simd_distance(simd_half8  __x, simd_half8  __y) { return simd_precise_distance(__x,__y); }
   1302 static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y) { return simd_precise_distance(__x,__y); }
   1303 static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y) { return simd_precise_distance(__x,__y); }
   1304 static float  SIMD_CFUNC simd_distance(simd_float2  __x, simd_float2  __y) { return simd_precise_distance(__x,__y); }
   1305 static float  SIMD_CFUNC simd_distance(simd_float3  __x, simd_float3  __y) { return simd_precise_distance(__x,__y); }
   1306 static float  SIMD_CFUNC simd_distance(simd_float4  __x, simd_float4  __y) { return simd_precise_distance(__x,__y); }
   1307 static float  SIMD_CFUNC simd_distance(simd_float8  __x, simd_float8  __y) { return simd_precise_distance(__x,__y); }
   1308 static float  SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_distance(__x,__y); }
   1309 static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_distance(__x,__y); }
   1310 static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_distance(__x,__y); }
   1311 static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_distance(__x,__y); }
   1312 static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_distance(__x,__y); }
   1313 #endif
   1314 
   1315 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half2  __x, simd_half2  __y) { return simd_length_squared(__x - __y); }
   1316 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half3  __x, simd_half3  __y) { return simd_length_squared(__x - __y); }
   1317 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half4  __x, simd_half4  __y) { return simd_length_squared(__x - __y); }
   1318 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half8  __x, simd_half8  __y) { return simd_length_squared(__x - __y); }
   1319 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half16 __x, simd_half16 __y) { return simd_length_squared(__x - __y); }
   1320 static _Float16 SIMD_CFUNC simd_distance_squared(simd_half32 __x, simd_half32 __y) { return simd_length_squared(__x - __y); }
   1321 static float  SIMD_CFUNC simd_distance_squared(simd_float2  __x, simd_float2  __y) { return simd_length_squared(__x - __y); }
   1322 static float  SIMD_CFUNC simd_distance_squared(simd_float3  __x, simd_float3  __y) { return simd_length_squared(__x - __y); }
   1323 static float  SIMD_CFUNC simd_distance_squared(simd_float4  __x, simd_float4  __y) { return simd_length_squared(__x - __y); }
   1324 static float  SIMD_CFUNC simd_distance_squared(simd_float8  __x, simd_float8  __y) { return simd_length_squared(__x - __y); }
   1325 static float  SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y) { return simd_length_squared(__x - __y); }
   1326 static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y) { return simd_length_squared(__x - __y); }
   1327 static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y) { return simd_length_squared(__x - __y); }
   1328 static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y) { return simd_length_squared(__x - __y); }
   1329 static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y) { return simd_length_squared(__x - __y); }
   1330 
   1331 static simd_half2   SIMD_CFUNC simd_precise_normalize(simd_half2   __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1332 static simd_half3   SIMD_CFUNC simd_precise_normalize(simd_half3   __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1333 static simd_half4   SIMD_CFUNC simd_precise_normalize(simd_half4   __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1334 static simd_half8   SIMD_CFUNC simd_precise_normalize(simd_half8   __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1335 static simd_half16  SIMD_CFUNC simd_precise_normalize(simd_half16  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1336 static simd_half32  SIMD_CFUNC simd_precise_normalize(simd_half32  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1337 static simd_float2  SIMD_CFUNC simd_precise_normalize(simd_float2  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1338 static simd_float3  SIMD_CFUNC simd_precise_normalize(simd_float3  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1339 static simd_float4  SIMD_CFUNC simd_precise_normalize(simd_float4  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1340 static simd_float8  SIMD_CFUNC simd_precise_normalize(simd_float8  __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1341 static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1342 static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1343 static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1344 static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1345 static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
   1346 
   1347 static simd_half2   SIMD_CFUNC simd_fast_normalize(simd_half2   __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1348 static simd_half3   SIMD_CFUNC simd_fast_normalize(simd_half3   __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1349 static simd_half4   SIMD_CFUNC simd_fast_normalize(simd_half4   __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1350 static simd_half8   SIMD_CFUNC simd_fast_normalize(simd_half8   __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1351 static simd_half16  SIMD_CFUNC simd_fast_normalize(simd_half16  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1352 static simd_half32  SIMD_CFUNC simd_fast_normalize(simd_half32  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1353 static simd_float2  SIMD_CFUNC simd_fast_normalize(simd_float2  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1354 static simd_float3  SIMD_CFUNC simd_fast_normalize(simd_float3  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1355 static simd_float4  SIMD_CFUNC simd_fast_normalize(simd_float4  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1356 static simd_float8  SIMD_CFUNC simd_fast_normalize(simd_float8  __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1357 static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1358 static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1359 static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1360 static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1361 static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
   1362 
   1363 #if defined __FAST_MATH__
   1364 static simd_half2   SIMD_CFUNC simd_normalize(simd_half2   __x) { return simd_fast_normalize(__x); }
   1365 static simd_half3   SIMD_CFUNC simd_normalize(simd_half3   __x) { return simd_fast_normalize(__x); }
   1366 static simd_half4   SIMD_CFUNC simd_normalize(simd_half4   __x) { return simd_fast_normalize(__x); }
   1367 static simd_half8   SIMD_CFUNC simd_normalize(simd_half8   __x) { return simd_fast_normalize(__x); }
   1368 static simd_half16  SIMD_CFUNC simd_normalize(simd_half16  __x) { return simd_fast_normalize(__x); }
   1369 static simd_half32  SIMD_CFUNC simd_normalize(simd_half32  __x) { return simd_fast_normalize(__x); }
   1370 static simd_float2  SIMD_CFUNC simd_normalize(simd_float2  __x) { return simd_fast_normalize(__x); }
   1371 static simd_float3  SIMD_CFUNC simd_normalize(simd_float3  __x) { return simd_fast_normalize(__x); }
   1372 static simd_float4  SIMD_CFUNC simd_normalize(simd_float4  __x) { return simd_fast_normalize(__x); }
   1373 static simd_float8  SIMD_CFUNC simd_normalize(simd_float8  __x) { return simd_fast_normalize(__x); }
   1374 static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_fast_normalize(__x); }
   1375 static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_fast_normalize(__x); }
   1376 static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_fast_normalize(__x); }
   1377 static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_fast_normalize(__x); }
   1378 static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_fast_normalize(__x); }
   1379 #else
   1380 static simd_half2   SIMD_CFUNC simd_normalize(simd_half2   __x) { return simd_precise_normalize(__x); }
   1381 static simd_half3   SIMD_CFUNC simd_normalize(simd_half3   __x) { return simd_precise_normalize(__x); }
   1382 static simd_half4   SIMD_CFUNC simd_normalize(simd_half4   __x) { return simd_precise_normalize(__x); }
   1383 static simd_half8   SIMD_CFUNC simd_normalize(simd_half8   __x) { return simd_precise_normalize(__x); }
   1384 static simd_half16  SIMD_CFUNC simd_normalize(simd_half16  __x) { return simd_precise_normalize(__x); }
   1385 static simd_half32  SIMD_CFUNC simd_normalize(simd_half32  __x) { return simd_precise_normalize(__x); }
   1386 static simd_float2  SIMD_CFUNC simd_normalize(simd_float2  __x) { return simd_precise_normalize(__x); }
   1387 static simd_float3  SIMD_CFUNC simd_normalize(simd_float3  __x) { return simd_precise_normalize(__x); }
   1388 static simd_float4  SIMD_CFUNC simd_normalize(simd_float4  __x) { return simd_precise_normalize(__x); }
   1389 static simd_float8  SIMD_CFUNC simd_normalize(simd_float8  __x) { return simd_precise_normalize(__x); }
   1390 static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_precise_normalize(__x); }
   1391 static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_precise_normalize(__x); }
   1392 static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_precise_normalize(__x); }
   1393 static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_precise_normalize(__x); }
   1394 static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_precise_normalize(__x); }
   1395 #endif
   1396 
   1397 static simd_half3   SIMD_CFUNC simd_cross(simd_half2   __x, simd_half2   __y) { return (simd_half3){ 0, 0, __x.x*__y.y - __x.y*__y.x }; }
   1398 static simd_half3   SIMD_CFUNC simd_cross(simd_half3   __x, simd_half3   __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
   1399 static simd_float3  SIMD_CFUNC simd_cross(simd_float2  __x, simd_float2  __y) { return (simd_float3){ 0, 0, __x.x*__y.y - __x.y*__y.x }; }
   1400 static simd_float3  SIMD_CFUNC simd_cross(simd_float3  __x, simd_float3  __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
   1401 static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y) { return (simd_double3){ 0, 0, __x.x*__y.y - __x.y*__y.x }; }
   1402 static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
   1403 
   1404 static simd_half2   SIMD_CFUNC simd_reflect(simd_half2   __x, simd_half2   __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1405 static simd_half3   SIMD_CFUNC simd_reflect(simd_half3   __x, simd_half3   __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1406 static simd_half4   SIMD_CFUNC simd_reflect(simd_half4   __x, simd_half4   __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1407 static simd_float2  SIMD_CFUNC simd_reflect(simd_float2  __x, simd_float2  __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1408 static simd_float3  SIMD_CFUNC simd_reflect(simd_float3  __x, simd_float3  __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1409 static simd_float4  SIMD_CFUNC simd_reflect(simd_float4  __x, simd_float4  __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1410 static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1411 static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1412 static simd_double4 SIMD_CFUNC simd_reflect(simd_double4 __x, simd_double4 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
   1413 
   1414 #if SIMD_LIBRARY_VERSION >= 6
   1415 static simd_half2  SIMD_CFUNC simd_refract(simd_half2  __x, simd_half2  __n, _Float16 __eta) {
   1416   const _Float16 __k = 1.0f16 - __eta*__eta*(1.0f16 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1417   return (__k >= 0.0f16) ? __eta*__x - (__eta*simd_dot(__x,__n) + __sqrtf16(__k))*__n : (simd_half2)0.0f16;
   1418 }
   1419 static simd_half3  SIMD_CFUNC simd_refract(simd_half3  __x, simd_half3  __n, _Float16 __eta) {
   1420   const _Float16 __k = 1.0f16 - __eta*__eta*(1.0f16 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1421   return (__k >= 0.0f16) ? __eta*__x - (__eta*simd_dot(__x,__n) + __sqrtf16(__k))*__n : (simd_half3)0.0f16;
   1422 }
   1423 static simd_half4  SIMD_CFUNC simd_refract(simd_half4  __x, simd_half4  __n, _Float16 __eta) {
   1424   const _Float16 __k = 1.0f16 - __eta*__eta*(1.0f16 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1425   return (__k >= 0.0f16) ? __eta*__x - (__eta*simd_dot(__x,__n) + __sqrtf16(__k))*__n : (simd_half4)0.0f16;
   1426 }
   1427 #endif // SIMD_LIBRARY_VERSION >= 6
   1428 static simd_float2  SIMD_CFUNC simd_refract(simd_float2  __x, simd_float2  __n, float __eta) {
   1429   const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
   1430   return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float2)0.0f;
   1431 }
   1432 static simd_float3  SIMD_CFUNC simd_refract(simd_float3  __x, simd_float3  __n, float __eta) {
   1433   const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
   1434   return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float3)0.0f;
   1435 }
   1436 static simd_float4  SIMD_CFUNC simd_refract(simd_float4  __x, simd_float4  __n, float __eta) {
   1437   const float __k = 1.0f - __eta*__eta*(1.0f - simd_dot(__x,__n)*simd_dot(__x,__n));
   1438   return (__k >= 0.0f) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_float4)0.0f;
   1439 }
   1440 static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta) {
   1441   const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1442   return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double2)0.0;
   1443 }
   1444 static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta) {
   1445   const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1446   return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double3)0.0;
   1447 }
   1448 static simd_double4 SIMD_CFUNC simd_refract(simd_double4 __x, simd_double4 __n, double __eta) {
   1449   const double __k = 1.0 - __eta*__eta*(1.0 - simd_dot(__x,__n)*simd_dot(__x,__n));
   1450   return (__k >= 0.0) ? __eta*__x - (__eta*simd_dot(__x,__n) + sqrt(__k))*__n : (simd_double4)0.0;
   1451 }
   1452 
   1453 #if SIMD_LIBRARY_VERSION >= 2
   1454 static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y) {
   1455   return _simd_orient_vf2(__x, __y);
   1456 }
   1457 static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y) {
   1458   return _simd_orient_vd2(__x, __y);
   1459 }
   1460 static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z) {
   1461   return _simd_orient_vf3(__x, __y, __z);
   1462 }
   1463 static double SIMD_CFUNC simd_orient(simd_double3 __x, simd_double3 __y, simd_double3 __z) {
   1464   simd_double3 __args[3] = { __x, __y, __z };
   1465   return _simd_orient_vd3((const double *)__args);
   1466 }
   1467 
   1468 static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c) {
   1469   return _simd_orient_pf2(__a, __b, __c);
   1470 }
   1471 static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c) {
   1472   return _simd_orient_pd2(__a, __b, __c);
   1473 }
   1474 static float SIMD_CFUNC simd_orient(simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) {
   1475   return _simd_orient_pf3(__a, __b, __c, __d);
   1476 }
   1477 static double SIMD_CFUNC simd_orient(simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) {
   1478   simd_double3 __args[4] = { __a, __b, __c, __d };
   1479   return _simd_orient_pd3((const double *)__args);
   1480 }
   1481 
   1482 static float SIMD_CFUNC simd_incircle(simd_float2 __x, simd_float2 __a, simd_float2 __b, simd_float2 __c) {
   1483   return _simd_incircle_pf2(__x, __a, __b, __c);
   1484 }
   1485 static double SIMD_CFUNC simd_incircle(simd_double2 __x, simd_double2 __a, simd_double2 __b, simd_double2 __c) {
   1486   return _simd_incircle_pd2(__x, __a, __b, __c);
   1487 }
   1488 static float SIMD_CFUNC simd_insphere(simd_float3 __x, simd_float3 __a, simd_float3 __b, simd_float3 __c, simd_float3 __d) {
   1489   return _simd_insphere_pf3(__x, __a, __b, __c, __d);
   1490 }
   1491 static double SIMD_CFUNC simd_insphere(simd_double3 __x, simd_double3 __a, simd_double3 __b, simd_double3 __c, simd_double3 __d) {
   1492   simd_double3 __args[5] = { __x, __a, __b, __c, __d };
   1493   return _simd_insphere_pd3((const double *)__args);
   1494 }
   1495 #endif /* SIMD_LIBRARY_VERSION */
   1496 
   1497 #if SIMD_LIBRARY_VERSION >= 6
   1498 static _Float16 SIMD_CFUNC simd_orient(simd_half2 __x, simd_half2 __y) {
   1499   return _simd_orient_vh2(__x, __y);
   1500 }
   1501 static _Float16 SIMD_CFUNC simd_orient(simd_half3 __x, simd_half3 __y, simd_half3 __z) {
   1502   return _simd_orient_vh3(__x, __y, __z);
   1503 }
   1504 
   1505 static _Float16 SIMD_CFUNC simd_orient(simd_half2 __a, simd_half2 __b, simd_half2 __c) {
   1506   return _simd_orient_ph2(__a, __b, __c);
   1507 }
   1508 static _Float16 SIMD_CFUNC simd_orient(simd_half3 __a, simd_half3 __b, simd_half3 __c, simd_half3 __d) {
   1509   return _simd_orient_ph3(__a, __b, __c, __d);
   1510 }
   1511 
   1512 static _Float16 SIMD_CFUNC simd_incircle(simd_half2 __x, simd_half2 __a, simd_half2 __b, simd_half2 __c) {
   1513   return _simd_incircle_ph2(__x, __a, __b, __c);
   1514 }
   1515 static _Float16 SIMD_CFUNC simd_insphere(simd_half3 __x, simd_half3 __a, simd_half3 __b, simd_half3 __c, simd_half3 __d) {
   1516   return _simd_insphere_ph3(__x, __a, __b, __c, __d);
   1517 }
   1518 #endif /* SIMD_LIBRARY_VERSION */
   1519 
   1520 #ifdef __cplusplus
   1521 }
   1522 #endif
   1523 #endif /* SIMD_COMPILER_HAS_REQUIRED_FEATURES */
   1524 #endif /* __SIMD_COMMON_HEADER__ */