 
   thrust::device_vector<cufftComplex> d_complexSpace(FY * FX);
   thrust::device_vector<float> dPattern(FY * FX);
-  cufftHandle plan;  
+  cufftHandle plan;
   cufftPlan2d(&plan, FX, FY, CUFFT_C2C);
+  cufftHandle sizePlan[4097];
+  for (int k = 1; k <= 4096; k++)
+    {
+      cufftPlan2d(&sizePlan[k], FX, FY, CUFFT_C2C);
+    }
 
   idealsphere spherer(dPhotons, dLambdas);
   char* taskid = getenv("SLURM_ARRAY_TASK_ID");

#include <thrust/device_vector.h>
#include <thrust/copy.h>
#include <string>
#include "math_constants.h"

using boost::multi_array;


const int FX = 2048;
const int FY = 2048;
const int BS = 2;

__device__ __host__ float sinc(float val)
{
