vector.h (2041B) - Raw
1 /* Copyright (c) 2014 Apple, Inc. All rights reserved. 2 * 3 * This header provides small vector (simd) types and basic arithmetic and 4 * math functions that operate on them. 5 * 6 * A wide assortment of vector types are provided in <simd/vector_types.h>, 7 * which is included by this header. The most important (as far as the rest 8 * of this library is concerned) are vector_floatN (where N is 2, 3, 4, 8, or 9 * 16), and vector_doubleN (where N is 2, 3, 4, or 8). 10 * 11 * All of the vector types are based on what clang call "OpenCL vectors", 12 * defined with the __ext_vector_type__ attribute. Many C operators "just 13 * work" with these types, so it is not necessary to make function calls 14 * to do basic arithmetic: 15 * 16 * simd_float4 x, y; 17 * x = x + y; // vector sum of x and y. 18 * 19 * scalar values are implicitly promoted to vectors (with a "splat"), so it 20 * is possible to easily write expressions involving scalars as well: 21 * 22 * simd_float4 x; 23 * x = 2*x; // scale x by 2. 24 * 25 * Besides the basic operations provided by the compiler, this header provides 26 * a set of mathematical and geometric primitives for use with these types. 27 * In C and Objective-C, these functions are prefixed with vector_; in C++, 28 * unprefixed names are available within the simd:: namespace. 29 * 30 * simd_float3 x, y; 31 * vector_max(x,y) // elementwise maximum of x and y 32 * fabs(x) // same as vector_abs(x) 33 * vector_clamp(x,0,1) // x clamped to the range [0,1]. This has no 34 * // standard-library analogue, so there is no 35 * // alternate name. 36 * 37 * Matrix and matrix-vector operations are also available in <simd/matrix.h>. 38 */ 39 40 #ifndef __SIMD_VECTOR_HEADER__ 41 #define __SIMD_VECTOR_HEADER__ 42 43 #include <simd/vector_types.h> 44 #include <simd/packed.h> 45 #include <simd/vector_make.h> 46 #include <simd/logic.h> 47 #include <simd/math.h> 48 #include <simd/common.h> 49 #include <simd/geometry.h> 50 #include <simd/conversion.h> 51 52 #endif