24 #define INFINITY FLT_MAX
27#define unit unsigned int
50#define _CONVERT(TYPE) convert_ ## TYPE
63#define CONVERT(TYPE, v) _CONVERT(TYPE)(v)
67#define VEC_ZERO ((float2)(0.f,0.f))
70#define VEC_ONE ((float2)(1.f, 1.f))
73#define VEC_ALL_ONE VEC_ONE
76#define VEC_INFINITY ((float2)(INFINITY, INFINITY))
79#define VEC_ALL_INFINITY VEC_INFINITY
82#define VEC_NEG_INFINITY (-VEC_INFINITY)
85#define VEC_ALL_NEG_INFINITY (-VEC_ALL_INFINITY)
89#define MAT_ZERO ((float4)(0.f, 0.f, \
93#define MAT_ONE ((float4)(1.f, 1.f, \
97#define MAT_ALL_ONE MAT_ONE
102#define MAT_EYE ((float4)(1.f, 0.f, \
106#define MAT_ALL_EYE MAT_EYE
128#define ivec_xyz ivec2
139#define uivec_xyz uivec2
156#define C_I() const uint c_i = icell[i]
180#define BEGIN_LOOP_OVER_NEIGHS() \
182 for(int ci = -1; ci <= 1; ci++) { \
183 for(int cj = -1; cj <= 1; cj++) { \
184 const uint c_j = c_i + \
187 uint j = ihoc[c_j]; \
188 while((j < N) && (icell[j] == c_j)) {
194#define END_LOOP_OVER_NEIGHS() \
202#define MATRIX_DOT(_M, _V) \
203 ((float2)(dot(_M.s01, _V), \
208#define MATRIX_DOT_ALL MATRIX_DOT
212#define MATRIX_MUL(_M1, _M2) \
213 ((float4)(dot(_M1.s01, _M2.s02), dot(_M1.s01, _M2.s13), \
214 dot(_M1.s23, _M2.s02), dot(_M1.s23, _M2.s13)))
218#define MATRIX_MUL_ALL MATRIX_MUL
222#define TRANSPOSE s0213
230#define MATRIX_FROM_DIAG(_V) \
231 ((float4)(_V.x, 0.f, \
238#define MATRIX_TRACE(_M) (_M.s0 + _M.s3)
261 return m.s0 * m.s3 - m.s1 * m.s2;
273 const float d = 1.f /
det(m);
274 if(fabs(d) > 1.e16f) {
277 return ((
matrix)( m.s3, -m.s1,
286#define MATRIX_INV(_M) \
287 MATRIX_MUL(inv(MATRIX_MUL(_M.TRANSPOSE, _M)), _M.TRANSPOSE)
float det(const matrix m)
Determinant of a matrix.
Definition: 2D.h:259
#define MAT_ALL_EYE
MAT_EYE.
Definition: 2D.h:106
matrix inv(const matrix m)
Inverse of a matrix.
Definition: 2D.h:271
matrix outer(const vec v1, const vec v2)
Perform the outer product of two vectors.
Definition: 2D.h:246
#define vec
Definition: 2D.h:38
#define matrix
Definition: 2D.h:41