You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
517B

  1. #include <cuda_runtime.h>
  2. #include <math.h>
  3. extern "C" __global__ void gpud_freq_shift_kernel(
  4. const float2* __restrict__ in,
  5. float2* __restrict__ out,
  6. int n,
  7. double phase_inc,
  8. double phase_start
  9. ) {
  10. int idx = blockIdx.x * blockDim.x + threadIdx.x;
  11. if (idx >= n) return;
  12. double phase = phase_start + phase_inc * (double)idx;
  13. float si, co;
  14. sincosf((float)phase, &si, &co);
  15. float2 v = in[idx];
  16. out[idx].x = v.x * co - v.y * si;
  17. out[idx].y = v.x * si + v.y * co;
  18. }