   }
 
   if (dir < 0) {
-    LL in = mod_inv(A.size(), prime);
-    for (int i = 0; i < A.size(); i++)
+    LL in = mod_inv(size, prime);
+    for (int i = 0; i < size; i++)
       A[i] = (A[i] * in) % prime;
   }
-
-  return A;
 }
 
 __device__ void d_ext_euclid(LL a, LL b, LL &x, LL &y, LL &g) {

            make_pair(754974721,643797295), make_pair(1107296257,883865065)};

PLL ROU_2[] = {make_pair(1711276033LL, 1223522572LL), make_pair(1790967809LL, 1110378081LL)};

PLL ext_euclid(LL a, LL b) {
  if (b == 0)

  }
}

void fft_con(LL *a, LL *A, int dir, LL prime, LL basew, int size){
  int ln = ceil(log2(float(size)));
  bit_reverse_copy(a, A, ln, size);
  LL *powers = (LL*) malloc (sizeof (LL) * ln);
  compute_powers(powers, ln, basew, prime);

  LL *d_A, *d_powers;
  cudaMalloc(&d_A, size * sizeof(LL));
  cudaMalloc(&d_powers, ln * sizeof(LL));

  cudaMemcpy (d_A, A, size * sizeof (LL), cudaMemcpyHostToDevice);
  cudaMemcpy (d_powers, powers, ln * sizeof (LL), cudaMemcpyHostToDevice);

  dim3 dimGrid(ceil(float(size / 1024.0)), 1, 1);
  dim3 dimBlock(1024, 1, 1);

  fft_kernel<<<dimGrid, dimBlock>>> (d_A, dir, prime, ln, d_powers, size);
  gpuErrchk( cudaPeekAtLastError() );
  gpuErrchk( cudaDeviceSynchronize() );

  cudaDeviceSynchronize();

  cudaMemcpy (A, d_A, size * sizeof (LL), cudaMemcpyDeviceToHost);

  cudaFree(d_A);
  cudaFree(d_powers);
  free(powers);

}

bool cmp_vectors (LL *A, LL *B, int size){
  for (int i = 0; i < size; i++){
    if (A[i] != B[i]){
      cout << A[i] << " " << B[i] << " i: " << i << endl;
      return false;
    }
  }
  return true;
}

int main(){
  LL prime = ROU_2[0].first;
  LL basew = ROU_2[0].second;
  int size = 8192;
  LL *a = (LL*) malloc( sizeof (LL) * size);
  LL *A = (LL*) malloc( sizeof (LL) * size);
  LL *B = (LL*) malloc( sizeof (LL) * size);
  for (int i = 0; i < size; i++){
    a[i] = i;
  }

  fft(a, A, 1, prime, basew, size);
  fft_con(a, B, 1, prime, basew, size);

  if (!cmp_vectors (A, B, size))
    cout << "nay :(" << endl;
  else
    cout << "yay :)" << endl;

  free(a);
  free(A);
  free(B);
  return 0;
}
