1 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
3 /// Compile with -DTYPENAME_MACRO=float2 or -DTYPENAME_MACRO=double2
4 typedef TYPENAME_MACRO T;
6 /// Complex number conjugate
11 /// Complex number multiplication
12 inline T cmul(T a, T b) {
13 return (T)(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x);
17 * Interpret @a a, @a b, and @a dst as vectors of @a N complex numbers
20 * dst(i) = conj(a(i)) * b(i)
22 * This is used when computing a cross correlation via FFTs, as this
23 * expression is the frequency space version of cross-correlation.
25 __kernel void conjugate_and_multiply(
26 __global T* dst, __global T const* a, __global T const* b,
27 unsigned int const N) {
28 // Get our global thread ID
29 int col = get_global_id(0);
32 dst[col] = cmul(cconj(a[col]), b[col]);