master
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
136extern "C" {
137#endif
138
139static _Float16 SIMD_CFUNC simd_dot(simd_half2 __x, simd_half2 __y);
140static _Float16 SIMD_CFUNC simd_dot(simd_half3 __x, simd_half3 __y);
141static _Float16 SIMD_CFUNC simd_dot(simd_half4 __x, simd_half4 __y);
142static _Float16 SIMD_CFUNC simd_dot(simd_half8 __x, simd_half8 __y);
143static _Float16 SIMD_CFUNC simd_dot(simd_half16 __x, simd_half16 __y);
144static _Float16 SIMD_CFUNC simd_dot(simd_half32 __x, simd_half32 __y);
145static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y);
146static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y);
147static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y);
148static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y);
149static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y);
150static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y);
151static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y);
152static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y);
153static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y);
154#define vector_dot simd_dot
155
156static simd_half2 SIMD_CFUNC simd_precise_project(simd_half2 __x, simd_half2 __y);
157static simd_half3 SIMD_CFUNC simd_precise_project(simd_half3 __x, simd_half3 __y);
158static simd_half4 SIMD_CFUNC simd_precise_project(simd_half4 __x, simd_half4 __y);
159static simd_half8 SIMD_CFUNC simd_precise_project(simd_half8 __x, simd_half8 __y);
160static simd_half16 SIMD_CFUNC simd_precise_project(simd_half16 __x, simd_half16 __y);
161static simd_half32 SIMD_CFUNC simd_precise_project(simd_half32 __x, simd_half32 __y);
162static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y);
163static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y);
164static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y);
165static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y);
166static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y);
167static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y);
168static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y);
169static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y);
170static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y);
171#define vector_precise_project simd_precise_project
172
173static simd_half2 SIMD_CFUNC simd_fast_project(simd_half2 __x, simd_half2 __y);
174static simd_half3 SIMD_CFUNC simd_fast_project(simd_half3 __x, simd_half3 __y);
175static simd_half4 SIMD_CFUNC simd_fast_project(simd_half4 __x, simd_half4 __y);
176static simd_half8 SIMD_CFUNC simd_fast_project(simd_half8 __x, simd_half8 __y);
177static simd_half16 SIMD_CFUNC simd_fast_project(simd_half16 __x, simd_half16 __y);
178static simd_half32 SIMD_CFUNC simd_fast_project(simd_half32 __x, simd_half32 __y);
179static simd_float2 SIMD_CFUNC simd_fast_project(simd_float2 __x, simd_float2 __y);
180static simd_float3 SIMD_CFUNC simd_fast_project(simd_float3 __x, simd_float3 __y);
181static simd_float4 SIMD_CFUNC simd_fast_project(simd_float4 __x, simd_float4 __y);
182static simd_float8 SIMD_CFUNC simd_fast_project(simd_float8 __x, simd_float8 __y);
183static simd_float16 SIMD_CFUNC simd_fast_project(simd_float16 __x, simd_float16 __y);
184static simd_double2 SIMD_CFUNC simd_fast_project(simd_double2 __x, simd_double2 __y);
185static simd_double3 SIMD_CFUNC simd_fast_project(simd_double3 __x, simd_double3 __y);
186static simd_double4 SIMD_CFUNC simd_fast_project(simd_double4 __x, simd_double4 __y);
187static simd_double8 SIMD_CFUNC simd_fast_project(simd_double8 __x, simd_double8 __y);
188#define vector_fast_project simd_fast_project
189
190static simd_half2 SIMD_CFUNC simd_project(simd_half2 __x, simd_half2 __y);
191static simd_half3 SIMD_CFUNC simd_project(simd_half3 __x, simd_half3 __y);
192static simd_half4 SIMD_CFUNC simd_project(simd_half4 __x, simd_half4 __y);
193static simd_half8 SIMD_CFUNC simd_project(simd_half8 __x, simd_half8 __y);
194static simd_half16 SIMD_CFUNC simd_project(simd_half16 __x, simd_half16 __y);
195static simd_half32 SIMD_CFUNC simd_project(simd_half32 __x, simd_half32 __y);
196static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y);
197static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y);
198static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y);
199static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y);
200static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y);
201static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y);
202static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y);
203static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y);
204static 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
208static _Float16 SIMD_CFUNC simd_precise_length(simd_half2 __x);
209static _Float16 SIMD_CFUNC simd_precise_length(simd_half3 __x);
210static _Float16 SIMD_CFUNC simd_precise_length(simd_half4 __x);
211static _Float16 SIMD_CFUNC simd_precise_length(simd_half8 __x);
212static _Float16 SIMD_CFUNC simd_precise_length(simd_half16 __x);
213static _Float16 SIMD_CFUNC simd_precise_length(simd_half32 __x);
214#endif // SIMD_LIBRARY_VERSION >= 6
215static float SIMD_CFUNC simd_precise_length(simd_float2 __x);
216static float SIMD_CFUNC simd_precise_length(simd_float3 __x);
217static float SIMD_CFUNC simd_precise_length(simd_float4 __x);
218static float SIMD_CFUNC simd_precise_length(simd_float8 __x);
219static float SIMD_CFUNC simd_precise_length(simd_float16 __x);
220static double SIMD_CFUNC simd_precise_length(simd_double2 __x);
221static double SIMD_CFUNC simd_precise_length(simd_double3 __x);
222static double SIMD_CFUNC simd_precise_length(simd_double4 __x);
223static double SIMD_CFUNC simd_precise_length(simd_double8 __x);
224#define vector_precise_length simd_precise_length
225
226static _Float16 SIMD_CFUNC simd_fast_length(simd_half2 __x);
227static _Float16 SIMD_CFUNC simd_fast_length(simd_half3 __x);
228static _Float16 SIMD_CFUNC simd_fast_length(simd_half4 __x);
229static _Float16 SIMD_CFUNC simd_fast_length(simd_half8 __x);
230static _Float16 SIMD_CFUNC simd_fast_length(simd_half16 __x);
231static _Float16 SIMD_CFUNC simd_fast_length(simd_half32 __x);
232static float SIMD_CFUNC simd_fast_length(simd_float2 __x);
233static float SIMD_CFUNC simd_fast_length(simd_float3 __x);
234static float SIMD_CFUNC simd_fast_length(simd_float4 __x);
235static float SIMD_CFUNC simd_fast_length(simd_float8 __x);
236static float SIMD_CFUNC simd_fast_length(simd_float16 __x);
237static double SIMD_CFUNC simd_fast_length(simd_double2 __x);
238static double SIMD_CFUNC simd_fast_length(simd_double3 __x);
239static double SIMD_CFUNC simd_fast_length(simd_double4 __x);
240static double SIMD_CFUNC simd_fast_length(simd_double8 __x);
241#define vector_fast_length simd_fast_length
242
243static _Float16 SIMD_CFUNC simd_length(simd_half2 __x);
244static _Float16 SIMD_CFUNC simd_length(simd_half3 __x);
245static _Float16 SIMD_CFUNC simd_length(simd_half4 __x);
246static _Float16 SIMD_CFUNC simd_length(simd_half8 __x);
247static _Float16 SIMD_CFUNC simd_length(simd_half16 __x);
248static _Float16 SIMD_CFUNC simd_length(simd_half32 __x);
249static float SIMD_CFUNC simd_length(simd_float2 __x);
250static float SIMD_CFUNC simd_length(simd_float3 __x);
251static float SIMD_CFUNC simd_length(simd_float4 __x);
252static float SIMD_CFUNC simd_length(simd_float8 __x);
253static float SIMD_CFUNC simd_length(simd_float16 __x);
254static double SIMD_CFUNC simd_length(simd_double2 __x);
255static double SIMD_CFUNC simd_length(simd_double3 __x);
256static double SIMD_CFUNC simd_length(simd_double4 __x);
257static double SIMD_CFUNC simd_length(simd_double8 __x);
258#define vector_length simd_length
259
260static _Float16 SIMD_CFUNC simd_length_squared(simd_half2 __x);
261static _Float16 SIMD_CFUNC simd_length_squared(simd_half3 __x);
262static _Float16 SIMD_CFUNC simd_length_squared(simd_half4 __x);
263static _Float16 SIMD_CFUNC simd_length_squared(simd_half8 __x);
264static _Float16 SIMD_CFUNC simd_length_squared(simd_half16 __x);
265static _Float16 SIMD_CFUNC simd_length_squared(simd_half32 __x);
266static float SIMD_CFUNC simd_length_squared(simd_float2 __x);
267static float SIMD_CFUNC simd_length_squared(simd_float3 __x);
268static float SIMD_CFUNC simd_length_squared(simd_float4 __x);
269static float SIMD_CFUNC simd_length_squared(simd_float8 __x);
270static float SIMD_CFUNC simd_length_squared(simd_float16 __x);
271static double SIMD_CFUNC simd_length_squared(simd_double2 __x);
272static double SIMD_CFUNC simd_length_squared(simd_double3 __x);
273static double SIMD_CFUNC simd_length_squared(simd_double4 __x);
274static double SIMD_CFUNC simd_length_squared(simd_double8 __x);
275#define vector_length_squared simd_length_squared
276
277static _Float16 SIMD_CFUNC simd_norm_one(simd_half2 __x);
278static _Float16 SIMD_CFUNC simd_norm_one(simd_half3 __x);
279static _Float16 SIMD_CFUNC simd_norm_one(simd_half4 __x);
280static _Float16 SIMD_CFUNC simd_norm_one(simd_half8 __x);
281static _Float16 SIMD_CFUNC simd_norm_one(simd_half16 __x);
282static _Float16 SIMD_CFUNC simd_norm_one(simd_half32 __x);
283static float SIMD_CFUNC simd_norm_one(simd_float2 __x);
284static float SIMD_CFUNC simd_norm_one(simd_float3 __x);
285static float SIMD_CFUNC simd_norm_one(simd_float4 __x);
286static float SIMD_CFUNC simd_norm_one(simd_float8 __x);
287static float SIMD_CFUNC simd_norm_one(simd_float16 __x);
288static double SIMD_CFUNC simd_norm_one(simd_double2 __x);
289static double SIMD_CFUNC simd_norm_one(simd_double3 __x);
290static double SIMD_CFUNC simd_norm_one(simd_double4 __x);
291static double SIMD_CFUNC simd_norm_one(simd_double8 __x);
292#define vector_norm_one simd_norm_one
293
294static _Float16 SIMD_CFUNC simd_norm_inf(simd_half2 __x);
295static _Float16 SIMD_CFUNC simd_norm_inf(simd_half3 __x);
296static _Float16 SIMD_CFUNC simd_norm_inf(simd_half4 __x);
297static _Float16 SIMD_CFUNC simd_norm_inf(simd_half8 __x);
298static _Float16 SIMD_CFUNC simd_norm_inf(simd_half16 __x);
299static _Float16 SIMD_CFUNC simd_norm_inf(simd_half32 __x);
300static float SIMD_CFUNC simd_norm_inf(simd_float2 __x);
301static float SIMD_CFUNC simd_norm_inf(simd_float3 __x);
302static float SIMD_CFUNC simd_norm_inf(simd_float4 __x);
303static float SIMD_CFUNC simd_norm_inf(simd_float8 __x);
304static float SIMD_CFUNC simd_norm_inf(simd_float16 __x);
305static double SIMD_CFUNC simd_norm_inf(simd_double2 __x);
306static double SIMD_CFUNC simd_norm_inf(simd_double3 __x);
307static double SIMD_CFUNC simd_norm_inf(simd_double4 __x);
308static double SIMD_CFUNC simd_norm_inf(simd_double8 __x);
309#define vector_norm_inf simd_norm_inf
310
311static _Float16 SIMD_CFUNC simd_precise_distance(simd_half2 __x, simd_half2 __y);
312static _Float16 SIMD_CFUNC simd_precise_distance(simd_half3 __x, simd_half3 __y);
313static _Float16 SIMD_CFUNC simd_precise_distance(simd_half4 __x, simd_half4 __y);
314static _Float16 SIMD_CFUNC simd_precise_distance(simd_half8 __x, simd_half8 __y);
315static _Float16 SIMD_CFUNC simd_precise_distance(simd_half16 __x, simd_half16 __y);
316static _Float16 SIMD_CFUNC simd_precise_distance(simd_half32 __x, simd_half32 __y);
317static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y);
318static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y);
319static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y);
320static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y);
321static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y);
322static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y);
323static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y);
324static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y);
325static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y);
326#define vector_precise_distance simd_precise_distance
327
328static _Float16 SIMD_CFUNC simd_fast_distance(simd_half2 __x, simd_half2 __y);
329static _Float16 SIMD_CFUNC simd_fast_distance(simd_half3 __x, simd_half3 __y);
330static _Float16 SIMD_CFUNC simd_fast_distance(simd_half4 __x, simd_half4 __y);
331static _Float16 SIMD_CFUNC simd_fast_distance(simd_half8 __x, simd_half8 __y);
332static _Float16 SIMD_CFUNC simd_fast_distance(simd_half16 __x, simd_half16 __y);
333static _Float16 SIMD_CFUNC simd_fast_distance(simd_half32 __x, simd_half32 __y);
334static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y);
335static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y);
336static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y);
337static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y);
338static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y);
339static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y);
340static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y);
341static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y);
342static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y);
343#define vector_fast_distance simd_fast_distance
344
345static _Float16 SIMD_CFUNC simd_distance(simd_half2 __x, simd_half2 __y);
346static _Float16 SIMD_CFUNC simd_distance(simd_half3 __x, simd_half3 __y);
347static _Float16 SIMD_CFUNC simd_distance(simd_half4 __x, simd_half4 __y);
348static _Float16 SIMD_CFUNC simd_distance(simd_half8 __x, simd_half8 __y);
349static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y);
350static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y);
351static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y);
352static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y);
353static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y);
354static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y);
355static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y);
356static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y);
357static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y);
358static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y);
359static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y);
360#define vector_distance simd_distance
361
362static _Float16 SIMD_CFUNC simd_distance_squared(simd_half2 __x, simd_half2 __y);
363static _Float16 SIMD_CFUNC simd_distance_squared(simd_half3 __x, simd_half3 __y);
364static _Float16 SIMD_CFUNC simd_distance_squared(simd_half4 __x, simd_half4 __y);
365static _Float16 SIMD_CFUNC simd_distance_squared(simd_half8 __x, simd_half8 __y);
366static _Float16 SIMD_CFUNC simd_distance_squared(simd_half16 __x, simd_half16 __y);
367static _Float16 SIMD_CFUNC simd_distance_squared(simd_half32 __x, simd_half32 __y);
368static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y);
369static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y);
370static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y);
371static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y);
372static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y);
373static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y);
374static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y);
375static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y);
376static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y);
377#define vector_distance_squared simd_distance_squared
378
379static simd_half2 SIMD_CFUNC simd_precise_normalize(simd_half2 __x);
380static simd_half3 SIMD_CFUNC simd_precise_normalize(simd_half3 __x);
381static simd_half4 SIMD_CFUNC simd_precise_normalize(simd_half4 __x);
382static simd_half8 SIMD_CFUNC simd_precise_normalize(simd_half8 __x);
383static simd_half16 SIMD_CFUNC simd_precise_normalize(simd_half16 __x);
384static simd_half32 SIMD_CFUNC simd_precise_normalize(simd_half32 __x);
385static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x);
386static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x);
387static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x);
388static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x);
389static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x);
390static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x);
391static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x);
392static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x);
393static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x);
394#define vector_precise_normalize simd_precise_normalize
395
396static simd_half2 SIMD_CFUNC simd_fast_normalize(simd_half2 __x);
397static simd_half3 SIMD_CFUNC simd_fast_normalize(simd_half3 __x);
398static simd_half4 SIMD_CFUNC simd_fast_normalize(simd_half4 __x);
399static simd_half8 SIMD_CFUNC simd_fast_normalize(simd_half8 __x);
400static simd_half16 SIMD_CFUNC simd_fast_normalize(simd_half16 __x);
401static simd_half32 SIMD_CFUNC simd_fast_normalize(simd_half32 __x);
402static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x);
403static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x);
404static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x);
405static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x);
406static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x);
407static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x);
408static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x);
409static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x);
410static simd_double8 SIMD_CFUNC simd_fast_normalize(simd_double8 __x);
411#define vector_fast_normalize simd_fast_normalize
412
413static simd_half2 SIMD_CFUNC simd_normalize(simd_half2 __x);
414static simd_half3 SIMD_CFUNC simd_normalize(simd_half3 __x);
415static simd_half4 SIMD_CFUNC simd_normalize(simd_half4 __x);
416static simd_half8 SIMD_CFUNC simd_normalize(simd_half8 __x);
417static simd_half16 SIMD_CFUNC simd_normalize(simd_half16 __x);
418static simd_half32 SIMD_CFUNC simd_normalize(simd_half32 __x);
419static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x);
420static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x);
421static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x);
422static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x);
423static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x);
424static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x);
425static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x);
426static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x);
427static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x);
428#define vector_normalize simd_normalize
429
430static simd_half3 SIMD_CFUNC simd_cross(simd_half2 __x, simd_half2 __y);
431static simd_half3 SIMD_CFUNC simd_cross(simd_half3 __x, simd_half3 __y);
432static simd_float3 SIMD_CFUNC simd_cross(simd_float2 __x, simd_float2 __y);
433static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y);
434static simd_double3 SIMD_CFUNC simd_cross(simd_double2 __x, simd_double2 __y);
435static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y);
436#define vector_cross simd_cross
437
438static simd_half2 SIMD_CFUNC simd_reflect(simd_half2 __x, simd_half2 __n);
439static simd_half3 SIMD_CFUNC simd_reflect(simd_half3 __x, simd_half3 __n);
440static simd_half4 SIMD_CFUNC simd_reflect(simd_half4 __x, simd_half4 __n);
441static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n);
442static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n);
443static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n);
444static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n);
445static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n);
446static 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
450static simd_half2 SIMD_CFUNC simd_refract(simd_half2 __x, simd_half2 __n, _Float16 __eta);
451static simd_half3 SIMD_CFUNC simd_refract(simd_half3 __x, simd_half3 __n, _Float16 __eta);
452static simd_half4 SIMD_CFUNC simd_refract(simd_half4 __x, simd_half4 __n, _Float16 __eta);
453#endif // SIMD_LIBRARY_VERSION >= 6
454static simd_float2 SIMD_CFUNC simd_refract(simd_float2 __x, simd_float2 __n, float __eta);
455static simd_float3 SIMD_CFUNC simd_refract(simd_float3 __x, simd_float3 __n, float __eta);
456static simd_float4 SIMD_CFUNC simd_refract(simd_float4 __x, simd_float4 __n, float __eta);
457static simd_double2 SIMD_CFUNC simd_refract(simd_double2 __x, simd_double2 __n, double __eta);
458static simd_double3 SIMD_CFUNC simd_refract(simd_double3 __x, simd_double3 __n, double __eta);
459static 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. */
501static 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. */
515static 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. */
530static 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. */
545static 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. */
572static 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. */
588static 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. */
604static 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. */
620static 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. */
649static 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. */
663static 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. */
678static 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. */
693static 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
713namespace 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
1041extern "C" {
1042#endif /* __cplusplus */
1043
1044#pragma mark - Implementation
1045
1046static _Float16 SIMD_CFUNC simd_dot(simd_half2 __x, simd_half2 __y) { return simd_reduce_add(__x*__y); }
1047static _Float16 SIMD_CFUNC simd_dot(simd_half3 __x, simd_half3 __y) { return simd_reduce_add(__x*__y); }
1048static _Float16 SIMD_CFUNC simd_dot(simd_half4 __x, simd_half4 __y) { return simd_reduce_add(__x*__y); }
1049static _Float16 SIMD_CFUNC simd_dot(simd_half8 __x, simd_half8 __y) { return simd_reduce_add(__x*__y); }
1050static _Float16 SIMD_CFUNC simd_dot(simd_half16 __x, simd_half16 __y) { return simd_reduce_add(__x*__y); }
1051static _Float16 SIMD_CFUNC simd_dot(simd_half32 __x, simd_half32 __y) { return simd_reduce_add(__x*__y); }
1052static float SIMD_CFUNC simd_dot(simd_float2 __x, simd_float2 __y) { return simd_reduce_add(__x*__y); }
1053static float SIMD_CFUNC simd_dot(simd_float3 __x, simd_float3 __y) { return simd_reduce_add(__x*__y); }
1054static float SIMD_CFUNC simd_dot(simd_float4 __x, simd_float4 __y) { return simd_reduce_add(__x*__y); }
1055static float SIMD_CFUNC simd_dot(simd_float8 __x, simd_float8 __y) { return simd_reduce_add(__x*__y); }
1056static float SIMD_CFUNC simd_dot(simd_float16 __x, simd_float16 __y) { return simd_reduce_add(__x*__y); }
1057static double SIMD_CFUNC simd_dot(simd_double2 __x, simd_double2 __y) { return simd_reduce_add(__x*__y); }
1058static double SIMD_CFUNC simd_dot(simd_double3 __x, simd_double3 __y) { return simd_reduce_add(__x*__y); }
1059static double SIMD_CFUNC simd_dot(simd_double4 __x, simd_double4 __y) { return simd_reduce_add(__x*__y); }
1060static double SIMD_CFUNC simd_dot(simd_double8 __x, simd_double8 __y) { return simd_reduce_add(__x*__y); }
1061
1062static simd_half2 SIMD_CFUNC simd_precise_project(simd_half2 __x, simd_half2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1063static simd_half3 SIMD_CFUNC simd_precise_project(simd_half3 __x, simd_half3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1064static simd_half4 SIMD_CFUNC simd_precise_project(simd_half4 __x, simd_half4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1065static simd_half8 SIMD_CFUNC simd_precise_project(simd_half8 __x, simd_half8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1066static simd_half16 SIMD_CFUNC simd_precise_project(simd_half16 __x, simd_half16 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1067static simd_half32 SIMD_CFUNC simd_precise_project(simd_half32 __x, simd_half32 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1068static simd_float2 SIMD_CFUNC simd_precise_project(simd_float2 __x, simd_float2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1069static simd_float3 SIMD_CFUNC simd_precise_project(simd_float3 __x, simd_float3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1070static simd_float4 SIMD_CFUNC simd_precise_project(simd_float4 __x, simd_float4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1071static simd_float8 SIMD_CFUNC simd_precise_project(simd_float8 __x, simd_float8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1072static simd_float16 SIMD_CFUNC simd_precise_project(simd_float16 __x, simd_float16 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1073static simd_double2 SIMD_CFUNC simd_precise_project(simd_double2 __x, simd_double2 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1074static simd_double3 SIMD_CFUNC simd_precise_project(simd_double3 __x, simd_double3 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1075static simd_double4 SIMD_CFUNC simd_precise_project(simd_double4 __x, simd_double4 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1076static simd_double8 SIMD_CFUNC simd_precise_project(simd_double8 __x, simd_double8 __y) { return simd_dot(__x,__y)/simd_dot(__y,__y)*__y; }
1077
1078static 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)); }
1079static 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)); }
1080static 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)); }
1081static 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)); }
1082static 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)); }
1083static 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)); }
1084static 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)); }
1085static 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)); }
1086static 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)); }
1087static 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)); }
1088static 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)); }
1089static 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)); }
1090static 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)); }
1091static 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)); }
1092static 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__
1095static simd_half2 SIMD_CFUNC simd_project(simd_half2 __x, simd_half2 __y) { return simd_fast_project(__x,__y); }
1096static simd_half3 SIMD_CFUNC simd_project(simd_half3 __x, simd_half3 __y) { return simd_fast_project(__x,__y); }
1097static simd_half4 SIMD_CFUNC simd_project(simd_half4 __x, simd_half4 __y) { return simd_fast_project(__x,__y); }
1098static simd_half8 SIMD_CFUNC simd_project(simd_half8 __x, simd_half8 __y) { return simd_fast_project(__x,__y); }
1099static simd_half16 SIMD_CFUNC simd_project(simd_half16 __x, simd_half16 __y) { return simd_fast_project(__x,__y); }
1100static simd_half32 SIMD_CFUNC simd_project(simd_half32 __x, simd_half32 __y) { return simd_fast_project(__x,__y); }
1101static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_fast_project(__x,__y); }
1102static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_fast_project(__x,__y); }
1103static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_fast_project(__x,__y); }
1104static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_fast_project(__x,__y); }
1105static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_fast_project(__x,__y); }
1106static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_fast_project(__x,__y); }
1107static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_fast_project(__x,__y); }
1108static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_fast_project(__x,__y); }
1109static simd_double8 SIMD_CFUNC simd_project(simd_double8 __x, simd_double8 __y) { return simd_fast_project(__x,__y); }
1110#else
1111static simd_half2 SIMD_CFUNC simd_project(simd_half2 __x, simd_half2 __y) { return simd_precise_project(__x,__y); }
1112static simd_half3 SIMD_CFUNC simd_project(simd_half3 __x, simd_half3 __y) { return simd_precise_project(__x,__y); }
1113static simd_half4 SIMD_CFUNC simd_project(simd_half4 __x, simd_half4 __y) { return simd_precise_project(__x,__y); }
1114static simd_half8 SIMD_CFUNC simd_project(simd_half8 __x, simd_half8 __y) { return simd_precise_project(__x,__y); }
1115static simd_half16 SIMD_CFUNC simd_project(simd_half16 __x, simd_half16 __y) { return simd_precise_project(__x,__y); }
1116static simd_half32 SIMD_CFUNC simd_project(simd_half32 __x, simd_half32 __y) { return simd_precise_project(__x,__y); }
1117static simd_float2 SIMD_CFUNC simd_project(simd_float2 __x, simd_float2 __y) { return simd_precise_project(__x,__y); }
1118static simd_float3 SIMD_CFUNC simd_project(simd_float3 __x, simd_float3 __y) { return simd_precise_project(__x,__y); }
1119static simd_float4 SIMD_CFUNC simd_project(simd_float4 __x, simd_float4 __y) { return simd_precise_project(__x,__y); }
1120static simd_float8 SIMD_CFUNC simd_project(simd_float8 __x, simd_float8 __y) { return simd_precise_project(__x,__y); }
1121static simd_float16 SIMD_CFUNC simd_project(simd_float16 __x, simd_float16 __y) { return simd_precise_project(__x,__y); }
1122static simd_double2 SIMD_CFUNC simd_project(simd_double2 __x, simd_double2 __y) { return simd_precise_project(__x,__y); }
1123static simd_double3 SIMD_CFUNC simd_project(simd_double3 __x, simd_double3 __y) { return simd_precise_project(__x,__y); }
1124static simd_double4 SIMD_CFUNC simd_project(simd_double4 __x, simd_double4 __y) { return simd_precise_project(__x,__y); }
1125static 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
1129static _Float16 SIMD_CFUNC simd_precise_length(simd_half2 __x) { return __sqrtf16(simd_length_squared(__x)); }
1130static _Float16 SIMD_CFUNC simd_precise_length(simd_half3 __x) { return __sqrtf16(simd_length_squared(__x)); }
1131static _Float16 SIMD_CFUNC simd_precise_length(simd_half4 __x) { return __sqrtf16(simd_length_squared(__x)); }
1132static _Float16 SIMD_CFUNC simd_precise_length(simd_half8 __x) { return __sqrtf16(simd_length_squared(__x)); }
1133static _Float16 SIMD_CFUNC simd_precise_length(simd_half16 __x) { return __sqrtf16(simd_length_squared(__x)); }
1134static _Float16 SIMD_CFUNC simd_precise_length(simd_half32 __x) { return __sqrtf16(simd_length_squared(__x)); }
1135#endif // SIMD_LIBRARY_VERSION >= 6
1136static float SIMD_CFUNC simd_precise_length(simd_float2 __x) { return sqrtf(simd_length_squared(__x)); }
1137static float SIMD_CFUNC simd_precise_length(simd_float3 __x) { return sqrtf(simd_length_squared(__x)); }
1138static float SIMD_CFUNC simd_precise_length(simd_float4 __x) { return sqrtf(simd_length_squared(__x)); }
1139static float SIMD_CFUNC simd_precise_length(simd_float8 __x) { return sqrtf(simd_length_squared(__x)); }
1140static float SIMD_CFUNC simd_precise_length(simd_float16 __x) { return sqrtf(simd_length_squared(__x)); }
1141static double SIMD_CFUNC simd_precise_length(simd_double2 __x) { return sqrt(simd_length_squared(__x)); }
1142static double SIMD_CFUNC simd_precise_length(simd_double3 __x) { return sqrt(simd_length_squared(__x)); }
1143static double SIMD_CFUNC simd_precise_length(simd_double4 __x) { return sqrt(simd_length_squared(__x)); }
1144static double SIMD_CFUNC simd_precise_length(simd_double8 __x) { return sqrt(simd_length_squared(__x)); }
1145#if SIMD_LIBRARY_VERSION >= 6
1146static _Float16 SIMD_CFUNC simd_fast_length(simd_half2 __x) { return simd_precise_length(__x); }
1147static _Float16 SIMD_CFUNC simd_fast_length(simd_half3 __x) { return simd_precise_length(__x); }
1148static _Float16 SIMD_CFUNC simd_fast_length(simd_half4 __x) { return simd_precise_length(__x); }
1149static _Float16 SIMD_CFUNC simd_fast_length(simd_half8 __x) { return simd_precise_length(__x); }
1150static _Float16 SIMD_CFUNC simd_fast_length(simd_half16 __x) { return simd_precise_length(__x); }
1151static _Float16 SIMD_CFUNC simd_fast_length(simd_half32 __x) { return simd_precise_length(__x); }
1152#endif // SIMD_LIBRARY_VERSION >= 6
1153static float SIMD_CFUNC simd_fast_length(simd_float2 __x) { return simd_precise_length(__x); }
1154static float SIMD_CFUNC simd_fast_length(simd_float3 __x) { return simd_precise_length(__x); }
1155static float SIMD_CFUNC simd_fast_length(simd_float4 __x) { return simd_precise_length(__x); }
1156static float SIMD_CFUNC simd_fast_length(simd_float8 __x) { return simd_precise_length(__x); }
1157static float SIMD_CFUNC simd_fast_length(simd_float16 __x) { return simd_precise_length(__x); }
1158static double SIMD_CFUNC simd_fast_length(simd_double2 __x) { return simd_precise_length(__x); }
1159static double SIMD_CFUNC simd_fast_length(simd_double3 __x) { return simd_precise_length(__x); }
1160static double SIMD_CFUNC simd_fast_length(simd_double4 __x) { return simd_precise_length(__x); }
1161static double SIMD_CFUNC simd_fast_length(simd_double8 __x) { return simd_precise_length(__x); }
1162
1163#if defined __FAST_MATH__
1164static _Float16 SIMD_CFUNC simd_length(simd_half2 __x) { return simd_fast_length(__x); }
1165static _Float16 SIMD_CFUNC simd_length(simd_half3 __x) { return simd_fast_length(__x); }
1166static _Float16 SIMD_CFUNC simd_length(simd_half4 __x) { return simd_fast_length(__x); }
1167static _Float16 SIMD_CFUNC simd_length(simd_half8 __x) { return simd_fast_length(__x); }
1168static _Float16 SIMD_CFUNC simd_length(simd_half16 __x) { return simd_fast_length(__x); }
1169static _Float16 SIMD_CFUNC simd_length(simd_half32 __x) { return simd_fast_length(__x); }
1170static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_fast_length(__x); }
1171static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_fast_length(__x); }
1172static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_fast_length(__x); }
1173static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_fast_length(__x); }
1174static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_fast_length(__x); }
1175static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_fast_length(__x); }
1176static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_fast_length(__x); }
1177static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_fast_length(__x); }
1178static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_fast_length(__x); }
1179#else
1180#if SIMD_LIBRARY_VERSION >= 6
1181static _Float16 SIMD_CFUNC simd_length(simd_half2 __x) { return simd_precise_length(__x); }
1182static _Float16 SIMD_CFUNC simd_length(simd_half3 __x) { return simd_precise_length(__x); }
1183static _Float16 SIMD_CFUNC simd_length(simd_half4 __x) { return simd_precise_length(__x); }
1184static _Float16 SIMD_CFUNC simd_length(simd_half8 __x) { return simd_precise_length(__x); }
1185static _Float16 SIMD_CFUNC simd_length(simd_half16 __x) { return simd_precise_length(__x); }
1186static _Float16 SIMD_CFUNC simd_length(simd_half32 __x) { return simd_precise_length(__x); }
1187#endif // SIMD_LIBRARY_VERSION >= 6
1188static float SIMD_CFUNC simd_length(simd_float2 __x) { return simd_precise_length(__x); }
1189static float SIMD_CFUNC simd_length(simd_float3 __x) { return simd_precise_length(__x); }
1190static float SIMD_CFUNC simd_length(simd_float4 __x) { return simd_precise_length(__x); }
1191static float SIMD_CFUNC simd_length(simd_float8 __x) { return simd_precise_length(__x); }
1192static float SIMD_CFUNC simd_length(simd_float16 __x) { return simd_precise_length(__x); }
1193static double SIMD_CFUNC simd_length(simd_double2 __x) { return simd_precise_length(__x); }
1194static double SIMD_CFUNC simd_length(simd_double3 __x) { return simd_precise_length(__x); }
1195static double SIMD_CFUNC simd_length(simd_double4 __x) { return simd_precise_length(__x); }
1196static double SIMD_CFUNC simd_length(simd_double8 __x) { return simd_precise_length(__x); }
1197#endif
1198
1199static _Float16 SIMD_CFUNC simd_length_squared(simd_half2 __x) { return simd_dot(__x,__x); }
1200static _Float16 SIMD_CFUNC simd_length_squared(simd_half3 __x) { return simd_dot(__x,__x); }
1201static _Float16 SIMD_CFUNC simd_length_squared(simd_half4 __x) { return simd_dot(__x,__x); }
1202static _Float16 SIMD_CFUNC simd_length_squared(simd_half8 __x) { return simd_dot(__x,__x); }
1203static _Float16 SIMD_CFUNC simd_length_squared(simd_half16 __x) { return simd_dot(__x,__x); }
1204static _Float16 SIMD_CFUNC simd_length_squared(simd_half32 __x) { return simd_dot(__x,__x); }
1205static float SIMD_CFUNC simd_length_squared(simd_float2 __x) { return simd_dot(__x,__x); }
1206static float SIMD_CFUNC simd_length_squared(simd_float3 __x) { return simd_dot(__x,__x); }
1207static float SIMD_CFUNC simd_length_squared(simd_float4 __x) { return simd_dot(__x,__x); }
1208static float SIMD_CFUNC simd_length_squared(simd_float8 __x) { return simd_dot(__x,__x); }
1209static float SIMD_CFUNC simd_length_squared(simd_float16 __x) { return simd_dot(__x,__x); }
1210static double SIMD_CFUNC simd_length_squared(simd_double2 __x) { return simd_dot(__x,__x); }
1211static double SIMD_CFUNC simd_length_squared(simd_double3 __x) { return simd_dot(__x,__x); }
1212static double SIMD_CFUNC simd_length_squared(simd_double4 __x) { return simd_dot(__x,__x); }
1213static double SIMD_CFUNC simd_length_squared(simd_double8 __x) { return simd_dot(__x,__x); }
1214
1215static _Float16 SIMD_CFUNC simd_norm_one(simd_half2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1216static _Float16 SIMD_CFUNC simd_norm_one(simd_half3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1217static _Float16 SIMD_CFUNC simd_norm_one(simd_half4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1218static _Float16 SIMD_CFUNC simd_norm_one(simd_half8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1219static _Float16 SIMD_CFUNC simd_norm_one(simd_half16 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1220static _Float16 SIMD_CFUNC simd_norm_one(simd_half32 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1221static float SIMD_CFUNC simd_norm_one(simd_float2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1222static float SIMD_CFUNC simd_norm_one(simd_float3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1223static float SIMD_CFUNC simd_norm_one(simd_float4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1224static float SIMD_CFUNC simd_norm_one(simd_float8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1225static float SIMD_CFUNC simd_norm_one(simd_float16 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1226static double SIMD_CFUNC simd_norm_one(simd_double2 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1227static double SIMD_CFUNC simd_norm_one(simd_double3 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1228static double SIMD_CFUNC simd_norm_one(simd_double4 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1229static double SIMD_CFUNC simd_norm_one(simd_double8 __x) { return simd_reduce_add(__tg_fabs(__x)); }
1230
1231static _Float16 SIMD_CFUNC simd_norm_inf(simd_half2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1232static _Float16 SIMD_CFUNC simd_norm_inf(simd_half3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1233static _Float16 SIMD_CFUNC simd_norm_inf(simd_half4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1234static _Float16 SIMD_CFUNC simd_norm_inf(simd_half8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1235static _Float16 SIMD_CFUNC simd_norm_inf(simd_half16 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1236static _Float16 SIMD_CFUNC simd_norm_inf(simd_half32 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1237static float SIMD_CFUNC simd_norm_inf(simd_float2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1238static float SIMD_CFUNC simd_norm_inf(simd_float3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1239static float SIMD_CFUNC simd_norm_inf(simd_float4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1240static float SIMD_CFUNC simd_norm_inf(simd_float8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1241static float SIMD_CFUNC simd_norm_inf(simd_float16 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1242static double SIMD_CFUNC simd_norm_inf(simd_double2 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1243static double SIMD_CFUNC simd_norm_inf(simd_double3 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1244static double SIMD_CFUNC simd_norm_inf(simd_double4 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1245static double SIMD_CFUNC simd_norm_inf(simd_double8 __x) { return simd_reduce_max(__tg_fabs(__x)); }
1246
1247#if SIMD_LIBRARY_VERSION >= 6
1248static _Float16 SIMD_CFUNC simd_precise_distance(simd_half2 __x, simd_half2 __y) { return simd_precise_length(__x - __y); }
1249static _Float16 SIMD_CFUNC simd_precise_distance(simd_half3 __x, simd_half3 __y) { return simd_precise_length(__x - __y); }
1250static _Float16 SIMD_CFUNC simd_precise_distance(simd_half4 __x, simd_half4 __y) { return simd_precise_length(__x - __y); }
1251static _Float16 SIMD_CFUNC simd_precise_distance(simd_half8 __x, simd_half8 __y) { return simd_precise_length(__x - __y); }
1252static _Float16 SIMD_CFUNC simd_precise_distance(simd_half16 __x, simd_half16 __y) { return simd_precise_length(__x - __y); }
1253static _Float16 SIMD_CFUNC simd_precise_distance(simd_half32 __x, simd_half32 __y) { return simd_precise_length(__x - __y); }
1254#endif // SIMD_LIBRARY_VERSION >= 6
1255static float SIMD_CFUNC simd_precise_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_length(__x - __y); }
1256static float SIMD_CFUNC simd_precise_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_length(__x - __y); }
1257static float SIMD_CFUNC simd_precise_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_length(__x - __y); }
1258static float SIMD_CFUNC simd_precise_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_length(__x - __y); }
1259static float SIMD_CFUNC simd_precise_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_length(__x - __y); }
1260static double SIMD_CFUNC simd_precise_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_length(__x - __y); }
1261static double SIMD_CFUNC simd_precise_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_length(__x - __y); }
1262static double SIMD_CFUNC simd_precise_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_length(__x - __y); }
1263static double SIMD_CFUNC simd_precise_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_length(__x - __y); }
1264
1265static _Float16 SIMD_CFUNC simd_fast_distance(simd_half2 __x, simd_half2 __y) { return simd_fast_length(__x - __y); }
1266static _Float16 SIMD_CFUNC simd_fast_distance(simd_half3 __x, simd_half3 __y) { return simd_fast_length(__x - __y); }
1267static _Float16 SIMD_CFUNC simd_fast_distance(simd_half4 __x, simd_half4 __y) { return simd_fast_length(__x - __y); }
1268static _Float16 SIMD_CFUNC simd_fast_distance(simd_half8 __x, simd_half8 __y) { return simd_fast_length(__x - __y); }
1269static _Float16 SIMD_CFUNC simd_fast_distance(simd_half16 __x, simd_half16 __y) { return simd_fast_length(__x - __y); }
1270static _Float16 SIMD_CFUNC simd_fast_distance(simd_half32 __x, simd_half32 __y) { return simd_fast_length(__x - __y); }
1271static float SIMD_CFUNC simd_fast_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_length(__x - __y); }
1272static float SIMD_CFUNC simd_fast_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_length(__x - __y); }
1273static float SIMD_CFUNC simd_fast_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_length(__x - __y); }
1274static float SIMD_CFUNC simd_fast_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_length(__x - __y); }
1275static float SIMD_CFUNC simd_fast_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_length(__x - __y); }
1276static double SIMD_CFUNC simd_fast_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_length(__x - __y); }
1277static double SIMD_CFUNC simd_fast_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_length(__x - __y); }
1278static double SIMD_CFUNC simd_fast_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_length(__x - __y); }
1279static double SIMD_CFUNC simd_fast_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_length(__x - __y); }
1280
1281#if defined __FAST_MATH__
1282static _Float16 SIMD_CFUNC simd_distance(simd_half2 __x, simd_half2 __y) { return simd_fast_distance(__x,__y); }
1283static _Float16 SIMD_CFUNC simd_distance(simd_half3 __x, simd_half3 __y) { return simd_fast_distance(__x,__y); }
1284static _Float16 SIMD_CFUNC simd_distance(simd_half4 __x, simd_half4 __y) { return simd_fast_distance(__x,__y); }
1285static _Float16 SIMD_CFUNC simd_distance(simd_half8 __x, simd_half8 __y) { return simd_fast_distance(__x,__y); }
1286static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y) { return simd_fast_distance(__x,__y); }
1287static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y) { return simd_fast_distance(__x,__y); }
1288static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_fast_distance(__x,__y); }
1289static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_fast_distance(__x,__y); }
1290static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_fast_distance(__x,__y); }
1291static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_fast_distance(__x,__y); }
1292static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_fast_distance(__x,__y); }
1293static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_fast_distance(__x,__y); }
1294static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_fast_distance(__x,__y); }
1295static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_fast_distance(__x,__y); }
1296static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_fast_distance(__x,__y); }
1297#else
1298static _Float16 SIMD_CFUNC simd_distance(simd_half2 __x, simd_half2 __y) { return simd_precise_distance(__x,__y); }
1299static _Float16 SIMD_CFUNC simd_distance(simd_half3 __x, simd_half3 __y) { return simd_precise_distance(__x,__y); }
1300static _Float16 SIMD_CFUNC simd_distance(simd_half4 __x, simd_half4 __y) { return simd_precise_distance(__x,__y); }
1301static _Float16 SIMD_CFUNC simd_distance(simd_half8 __x, simd_half8 __y) { return simd_precise_distance(__x,__y); }
1302static _Float16 SIMD_CFUNC simd_distance(simd_half16 __x, simd_half16 __y) { return simd_precise_distance(__x,__y); }
1303static _Float16 SIMD_CFUNC simd_distance(simd_half32 __x, simd_half32 __y) { return simd_precise_distance(__x,__y); }
1304static float SIMD_CFUNC simd_distance(simd_float2 __x, simd_float2 __y) { return simd_precise_distance(__x,__y); }
1305static float SIMD_CFUNC simd_distance(simd_float3 __x, simd_float3 __y) { return simd_precise_distance(__x,__y); }
1306static float SIMD_CFUNC simd_distance(simd_float4 __x, simd_float4 __y) { return simd_precise_distance(__x,__y); }
1307static float SIMD_CFUNC simd_distance(simd_float8 __x, simd_float8 __y) { return simd_precise_distance(__x,__y); }
1308static float SIMD_CFUNC simd_distance(simd_float16 __x, simd_float16 __y) { return simd_precise_distance(__x,__y); }
1309static double SIMD_CFUNC simd_distance(simd_double2 __x, simd_double2 __y) { return simd_precise_distance(__x,__y); }
1310static double SIMD_CFUNC simd_distance(simd_double3 __x, simd_double3 __y) { return simd_precise_distance(__x,__y); }
1311static double SIMD_CFUNC simd_distance(simd_double4 __x, simd_double4 __y) { return simd_precise_distance(__x,__y); }
1312static double SIMD_CFUNC simd_distance(simd_double8 __x, simd_double8 __y) { return simd_precise_distance(__x,__y); }
1313#endif
1314
1315static _Float16 SIMD_CFUNC simd_distance_squared(simd_half2 __x, simd_half2 __y) { return simd_length_squared(__x - __y); }
1316static _Float16 SIMD_CFUNC simd_distance_squared(simd_half3 __x, simd_half3 __y) { return simd_length_squared(__x - __y); }
1317static _Float16 SIMD_CFUNC simd_distance_squared(simd_half4 __x, simd_half4 __y) { return simd_length_squared(__x - __y); }
1318static _Float16 SIMD_CFUNC simd_distance_squared(simd_half8 __x, simd_half8 __y) { return simd_length_squared(__x - __y); }
1319static _Float16 SIMD_CFUNC simd_distance_squared(simd_half16 __x, simd_half16 __y) { return simd_length_squared(__x - __y); }
1320static _Float16 SIMD_CFUNC simd_distance_squared(simd_half32 __x, simd_half32 __y) { return simd_length_squared(__x - __y); }
1321static float SIMD_CFUNC simd_distance_squared(simd_float2 __x, simd_float2 __y) { return simd_length_squared(__x - __y); }
1322static float SIMD_CFUNC simd_distance_squared(simd_float3 __x, simd_float3 __y) { return simd_length_squared(__x - __y); }
1323static float SIMD_CFUNC simd_distance_squared(simd_float4 __x, simd_float4 __y) { return simd_length_squared(__x - __y); }
1324static float SIMD_CFUNC simd_distance_squared(simd_float8 __x, simd_float8 __y) { return simd_length_squared(__x - __y); }
1325static float SIMD_CFUNC simd_distance_squared(simd_float16 __x, simd_float16 __y) { return simd_length_squared(__x - __y); }
1326static double SIMD_CFUNC simd_distance_squared(simd_double2 __x, simd_double2 __y) { return simd_length_squared(__x - __y); }
1327static double SIMD_CFUNC simd_distance_squared(simd_double3 __x, simd_double3 __y) { return simd_length_squared(__x - __y); }
1328static double SIMD_CFUNC simd_distance_squared(simd_double4 __x, simd_double4 __y) { return simd_length_squared(__x - __y); }
1329static double SIMD_CFUNC simd_distance_squared(simd_double8 __x, simd_double8 __y) { return simd_length_squared(__x - __y); }
1330
1331static simd_half2 SIMD_CFUNC simd_precise_normalize(simd_half2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1332static simd_half3 SIMD_CFUNC simd_precise_normalize(simd_half3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1333static simd_half4 SIMD_CFUNC simd_precise_normalize(simd_half4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1334static simd_half8 SIMD_CFUNC simd_precise_normalize(simd_half8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1335static simd_half16 SIMD_CFUNC simd_precise_normalize(simd_half16 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1336static simd_half32 SIMD_CFUNC simd_precise_normalize(simd_half32 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1337static simd_float2 SIMD_CFUNC simd_precise_normalize(simd_float2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1338static simd_float3 SIMD_CFUNC simd_precise_normalize(simd_float3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1339static simd_float4 SIMD_CFUNC simd_precise_normalize(simd_float4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1340static simd_float8 SIMD_CFUNC simd_precise_normalize(simd_float8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1341static simd_float16 SIMD_CFUNC simd_precise_normalize(simd_float16 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1342static simd_double2 SIMD_CFUNC simd_precise_normalize(simd_double2 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1343static simd_double3 SIMD_CFUNC simd_precise_normalize(simd_double3 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1344static simd_double4 SIMD_CFUNC simd_precise_normalize(simd_double4 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1345static simd_double8 SIMD_CFUNC simd_precise_normalize(simd_double8 __x) { return __x * simd_precise_rsqrt(simd_length_squared(__x)); }
1346
1347static simd_half2 SIMD_CFUNC simd_fast_normalize(simd_half2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1348static simd_half3 SIMD_CFUNC simd_fast_normalize(simd_half3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1349static simd_half4 SIMD_CFUNC simd_fast_normalize(simd_half4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1350static simd_half8 SIMD_CFUNC simd_fast_normalize(simd_half8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1351static simd_half16 SIMD_CFUNC simd_fast_normalize(simd_half16 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1352static simd_half32 SIMD_CFUNC simd_fast_normalize(simd_half32 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1353static simd_float2 SIMD_CFUNC simd_fast_normalize(simd_float2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1354static simd_float3 SIMD_CFUNC simd_fast_normalize(simd_float3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1355static simd_float4 SIMD_CFUNC simd_fast_normalize(simd_float4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1356static simd_float8 SIMD_CFUNC simd_fast_normalize(simd_float8 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1357static simd_float16 SIMD_CFUNC simd_fast_normalize(simd_float16 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1358static simd_double2 SIMD_CFUNC simd_fast_normalize(simd_double2 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1359static simd_double3 SIMD_CFUNC simd_fast_normalize(simd_double3 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1360static simd_double4 SIMD_CFUNC simd_fast_normalize(simd_double4 __x) { return __x * simd_fast_rsqrt(simd_length_squared(__x)); }
1361static 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__
1364static simd_half2 SIMD_CFUNC simd_normalize(simd_half2 __x) { return simd_fast_normalize(__x); }
1365static simd_half3 SIMD_CFUNC simd_normalize(simd_half3 __x) { return simd_fast_normalize(__x); }
1366static simd_half4 SIMD_CFUNC simd_normalize(simd_half4 __x) { return simd_fast_normalize(__x); }
1367static simd_half8 SIMD_CFUNC simd_normalize(simd_half8 __x) { return simd_fast_normalize(__x); }
1368static simd_half16 SIMD_CFUNC simd_normalize(simd_half16 __x) { return simd_fast_normalize(__x); }
1369static simd_half32 SIMD_CFUNC simd_normalize(simd_half32 __x) { return simd_fast_normalize(__x); }
1370static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_fast_normalize(__x); }
1371static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_fast_normalize(__x); }
1372static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_fast_normalize(__x); }
1373static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_fast_normalize(__x); }
1374static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_fast_normalize(__x); }
1375static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_fast_normalize(__x); }
1376static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_fast_normalize(__x); }
1377static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_fast_normalize(__x); }
1378static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_fast_normalize(__x); }
1379#else
1380static simd_half2 SIMD_CFUNC simd_normalize(simd_half2 __x) { return simd_precise_normalize(__x); }
1381static simd_half3 SIMD_CFUNC simd_normalize(simd_half3 __x) { return simd_precise_normalize(__x); }
1382static simd_half4 SIMD_CFUNC simd_normalize(simd_half4 __x) { return simd_precise_normalize(__x); }
1383static simd_half8 SIMD_CFUNC simd_normalize(simd_half8 __x) { return simd_precise_normalize(__x); }
1384static simd_half16 SIMD_CFUNC simd_normalize(simd_half16 __x) { return simd_precise_normalize(__x); }
1385static simd_half32 SIMD_CFUNC simd_normalize(simd_half32 __x) { return simd_precise_normalize(__x); }
1386static simd_float2 SIMD_CFUNC simd_normalize(simd_float2 __x) { return simd_precise_normalize(__x); }
1387static simd_float3 SIMD_CFUNC simd_normalize(simd_float3 __x) { return simd_precise_normalize(__x); }
1388static simd_float4 SIMD_CFUNC simd_normalize(simd_float4 __x) { return simd_precise_normalize(__x); }
1389static simd_float8 SIMD_CFUNC simd_normalize(simd_float8 __x) { return simd_precise_normalize(__x); }
1390static simd_float16 SIMD_CFUNC simd_normalize(simd_float16 __x) { return simd_precise_normalize(__x); }
1391static simd_double2 SIMD_CFUNC simd_normalize(simd_double2 __x) { return simd_precise_normalize(__x); }
1392static simd_double3 SIMD_CFUNC simd_normalize(simd_double3 __x) { return simd_precise_normalize(__x); }
1393static simd_double4 SIMD_CFUNC simd_normalize(simd_double4 __x) { return simd_precise_normalize(__x); }
1394static simd_double8 SIMD_CFUNC simd_normalize(simd_double8 __x) { return simd_precise_normalize(__x); }
1395#endif
1396
1397static 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 }; }
1398static simd_half3 SIMD_CFUNC simd_cross(simd_half3 __x, simd_half3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
1399static 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 }; }
1400static simd_float3 SIMD_CFUNC simd_cross(simd_float3 __x, simd_float3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
1401static 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 }; }
1402static simd_double3 SIMD_CFUNC simd_cross(simd_double3 __x, simd_double3 __y) { return (__x.zxy*__y - __x*__y.zxy).zxy; }
1403
1404static simd_half2 SIMD_CFUNC simd_reflect(simd_half2 __x, simd_half2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1405static simd_half3 SIMD_CFUNC simd_reflect(simd_half3 __x, simd_half3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1406static simd_half4 SIMD_CFUNC simd_reflect(simd_half4 __x, simd_half4 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1407static simd_float2 SIMD_CFUNC simd_reflect(simd_float2 __x, simd_float2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1408static simd_float3 SIMD_CFUNC simd_reflect(simd_float3 __x, simd_float3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1409static simd_float4 SIMD_CFUNC simd_reflect(simd_float4 __x, simd_float4 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1410static simd_double2 SIMD_CFUNC simd_reflect(simd_double2 __x, simd_double2 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1411static simd_double3 SIMD_CFUNC simd_reflect(simd_double3 __x, simd_double3 __n) { return __x - 2*simd_dot(__x,__n)*__n; }
1412static 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
1415static 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}
1419static 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}
1423static 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
1428static 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}
1432static 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}
1436static 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}
1440static 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}
1444static 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}
1448static 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
1454static float SIMD_CFUNC simd_orient(simd_float2 __x, simd_float2 __y) {
1455 return _simd_orient_vf2(__x, __y);
1456}
1457static double SIMD_CFUNC simd_orient(simd_double2 __x, simd_double2 __y) {
1458 return _simd_orient_vd2(__x, __y);
1459}
1460static float SIMD_CFUNC simd_orient(simd_float3 __x, simd_float3 __y, simd_float3 __z) {
1461 return _simd_orient_vf3(__x, __y, __z);
1462}
1463static 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
1468static float SIMD_CFUNC simd_orient(simd_float2 __a, simd_float2 __b, simd_float2 __c) {
1469 return _simd_orient_pf2(__a, __b, __c);
1470}
1471static double SIMD_CFUNC simd_orient(simd_double2 __a, simd_double2 __b, simd_double2 __c) {
1472 return _simd_orient_pd2(__a, __b, __c);
1473}
1474static 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}
1477static 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
1482static 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}
1485static 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}
1488static 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}
1491static 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
1498static _Float16 SIMD_CFUNC simd_orient(simd_half2 __x, simd_half2 __y) {
1499 return _simd_orient_vh2(__x, __y);
1500}
1501static _Float16 SIMD_CFUNC simd_orient(simd_half3 __x, simd_half3 __y, simd_half3 __z) {
1502 return _simd_orient_vh3(__x, __y, __z);
1503}
1504
1505static _Float16 SIMD_CFUNC simd_orient(simd_half2 __a, simd_half2 __b, simd_half2 __c) {
1506 return _simd_orient_ph2(__a, __b, __c);
1507}
1508static _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
1512static _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}
1515static _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__ */