diff options
author | Tomas Farago <sensej007@email.cz> | 2020-03-06 09:42:07 +0100 |
---|---|---|
committer | Tomas Farago <sensej007@email.cz> | 2020-03-06 09:42:07 +0100 |
commit | 1b14bddbcb3ce51c6fad8334482c3da41256ef19 (patch) | |
tree | a8c9cb98ebcf034e9ccd46badbb14493d28151de /src/kernels/complex.cl | |
parent | 408475f98550c7f92fc46d608a945a2497f4b6a8 (diff) | |
download | ufo-filters-1b14bddbcb3ce51c6fad8334482c3da41256ef19.tar.gz ufo-filters-1b14bddbcb3ce51c6fad8334482c3da41256ef19.tar.bz2 ufo-filters-1b14bddbcb3ce51c6fad8334482c3da41256ef19.tar.xz ufo-filters-1b14bddbcb3ce51c6fad8334482c3da41256ef19.zip |
Add power-spectrum filter
Diffstat (limited to 'src/kernels/complex.cl')
-rw-r--r-- | src/kernels/complex.cl | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/kernels/complex.cl b/src/kernels/complex.cl index 26cc180..d79b182 100644 --- a/src/kernels/complex.cl +++ b/src/kernels/complex.cl @@ -71,16 +71,24 @@ c_conj (global float *data, out[idx+1] = -data[idx+1]; } +/** + * Compute power spectrum. + * + * @data: complex input + * @out: real output + */ kernel void c_abs_squared (global float *data, global float *out) { - int y = get_global_id (1) * 2 * get_global_size (0); - int in_idx = y + 2 * get_global_id(0); - int out_idx = y + get_global_id(0); + int width = get_global_size (0); + int idx = get_global_id (0); + int idy = get_global_id (1); + int out_idx = width * idy + idx; + /* Input data must be complex interleaved, global dimensions are with + * respect to the real output, so multiply width by 2. */ + int in_idx = 2 * width * idy + 2 * idx; - /* Store the results in the horizontally first half of the complex *out* - * array, so the result of this should be cropped to half the input width. */ out[out_idx] = data[in_idx] * data[in_idx] + data[in_idx + 1] * data[in_idx + 1]; } |