10#include <vector_types.h>
12inline __host__ __device__
void zero(float2 &a) { a.x = 0.0f; a.y = 0.0f; }
15inline __host__ __device__ float2 operator-(float2 &a)
17 return make_float2(-a.x, -a.y);
21inline __host__ __device__ float2 conjugate(float2 a)
23 return make_float2(a.x, -a.y);
27inline __host__ __device__ float2 operator+(float2 a, float2 b)
29 return make_float2(a.x + b.x, a.y + b.y);
31inline __host__ __device__
void operator+=(float2 &a, float2 b)
37inline __host__ __device__ float2 operator+(float2 a,
float b)
39 return make_float2(a.x + b, a.y);
41inline __host__ __device__
void operator+=(float2 &a,
float b)
47inline __host__ __device__ float2 operator-(float2 a, float2 b)
49 return make_float2(a.x - b.x, a.y - b.y);
51inline __host__ __device__
void operator-=(float2 &a, float2 b)
56inline __host__ __device__ float2 operator-(float2 a,
float b)
58 return make_float2(a.x - b, a.y);
60inline __host__ __device__
void operator-=(float2 &a,
float b)
66inline __host__ __device__ float2 operator*(float2 a, float2 b)
68 return make_float2(a.x*b.x - a.y*b.y, a.y*b.x + a.x*b.y);
70inline __host__ __device__
void operator*=(float2 &a, float2 b)
72 a.x = a.x*b.x - a.y*b.y;
73 a.y = a.y*b.x + a.x*b.y;
75inline __host__ __device__ float2 operator*(float2 a,
float b)
77 return make_float2(a.x * b, a.y * b);
79inline __host__ __device__
void operator*=(float2 &a,
float b)
84inline __host__ __device__ float2 operator*(float2 a,
int b)
86 return make_float2(a.x * b, a.y * b);
88inline __host__ __device__
void operator*=(float2 &a,
int b)
93inline __host__ __device__ float2 complexMul(float2 a, float2 b)
97inline __host__ __device__ float2 complexMulConj(float2 a, float2 b)
99 return make_float2(a.x*b.x + a.y*b.y, a.y*b.x - a.x*b.y);
102inline __host__ __device__ float2 operator/(float2 a,
float b)
104 return make_float2(a.x / b, a.y / b);
106inline __host__ __device__
void operator/=(float2 &a,
float b)
113inline __host__ __device__
float complexAbs(float2 a)
115 return sqrtf(a.x*a.x+a.y*a.y);
117inline __host__ __device__
float complexArg(float2 a)
119 return atan2f(a.y, a.x);
123inline __host__ __device__ float2 complexExp(
float arg)
125 return make_float2(cosf(arg), sinf(arg));