Is there a ready-made function in CUDA used for spectrum multiplication?

i want to multiplied two results of CUFFT_R2C pointwise, is there a ready-made function in CUDA? Can give me some help, thanks

thrust::transform can be used to do pointwise multiplication of 2 complex arrays. Do google searches on thrust::complex and thrust::transform and you will find relevant examples.

Perhaps something like this:

#include <cufft.h>
#include <thrust/transform.h>
#include <thrust/device_ptr.h>
#include <thrust/complex.h>

int main(){
  const int N = 256;
  cufftComplex *d1, *d2, *r;
  cudaMalloc(&d1, N*sizeof(cufftComplex));
  cudaMalloc(&d2, N*sizeof(cufftComplex));
  // fill those device buffers with complex cufft output data
  cudaMalloc(&r, N*sizeof(cufftComplex));
  thrust::device_ptr<thrust::complex<float> > td1 = thrust::device_pointer_cast((thrust::complex<float> *)d1);
  thrust::device_ptr<thrust::complex<float> > td2 = thrust::device_pointer_cast((thrust::complex<float> *)d2);
  thrust::device_ptr<thrust::complex<float> > tr = thrust::device_pointer_cast((thrust::complex<float> *)r);
  thrust::transform(td1, td1+N, td2, tr, thrust::multiplies<thrust::complex<float> >() );
}

thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.