                                                                       (cuDoubleComplex*)psi_it,
                                                                       wt,
                                                                       it_density_matrix);
-        }
-    }
-}
-
-
+            cuda_check_last_error(__FILE__, __LINE__);
+        }
+    }
+}
+
+


extern "C" void cufft_set_work_area(void* work_area)
{
    if (cufftSetWorkArea(plan, work_area) != CUFFT_SUCCESS)
    {
        printf("failed to execute cufftSetWorkArea()\n");
        exit(0);
    }
}

extern "C" void cufft_destroy_batch_plan()
{
    cufftDestroy(plan);
}

//= __global__ void cufft_batch_apply_v_kernel(int fft_size, cuDoubleComplex* v_r, cuDoubleComplex* fft_buffer)

                                                                  map, 
                                                                  (cuDoubleComplex*)fft_buffer,
                                                                  (cuDoubleComplex*)data);
    cuda_check_last_error(__FILE__, __LINE__);
}

//== __global__ void cufft_normalize(int size, cuDoubleComplex* buffer)
//== {
//==     int i = blockIdx.y;
//==     int ir = blockDim.x * blockIdx.x + threadIdx.x;
//== 
//==     if (ir < size) 
//==     {
//==         buffer[array2D_offset(ir, i, size)] = 
//==             cuCdiv(buffer[array2D_offset(ir, i, size)], make_cuDoubleComplex(double(size), 0));
//==     }
//== }

extern "C" void cufft_forward_transform(void* fft_buffer)
{
