 #include <png.h>
+#include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
-#include <complex>
+#include <cuComplex.h>
 #include <iostream>
 #include <cmath>
-#include <thrust/complex.h>
-#include <unistd.h>
-#include <string>
-
-using std::string;
-using thrust::complex;
-using thrust::exp;
-using thrust::norm;
 
 // A coloured pixel.
 struct Pixel {

}

__device__
int iteration(complex<double> c, int limit = 1000) {
  int i = 0;
  double n;
  complex<double> z(0, 0);
  while ((n = norm(z)) < 4 && i < limit) {
    // z = z * z + c;
    // z = exp(z) - c;
    z = c * exp(-z) + z * z;
    ++i;
  }


  int xStride = gridDim.x * blockDim.x;
  int yStride = gridDim.y * blockDim.y;

  cuDoubleComplex t;
  int iter;
  Pixel* pixel;
  int width = bitmap.width;
  int height = bitmap.height;
  for (y = blockIdx.y * blockDim.y + threadIdx.y; y < height; y += yStride) {
    for (x = blockIdx.x * blockDim.x + threadIdx.x; x < width; x += xStride) {
      t = make_cuDoubleComplex(lowerX + (upperX - lowerX) * x / (width - 1),
                               lowerY + (upperY - lowerY) * y / (height - 1));
      iter = iteration(t);
      pixel = pixel_at(bitmap, x, y);
      pixel->red = rgb_value(1000 - iter, 1000);
