#include <stdio.h>
#include <iostream>
#include <cmath>
#include <cstdlib>
#define WIDTH 400 // Width of image
#define HEIGHT 400 // Width of image
array complex_grid(
int width,
int height,
float zoom,
float center[2])
{
array X = (
iota(
dim4(1, height),
dim4(width , 1)) - (float)height / 2.0) / zoom + center[0];
array Y = (
iota(
dim4(width , 1),
dim4(1, height)) - (float)width / 2.0) / zoom + center[1];
}
array mandelbrot(
const array &in,
int iter,
float maxval)
{
for (int ii = 1; ii < iter; ii++) {
Z = Z * Z + C;
C = C * (1 - cond);
Z = Z * (1 - cond);
Z.eval();
}
return mag / maxval;
}
{
float mx = af::max<float>(a);
float mn = af::min<float>(a);
return (a-mn)/(mx-mn);
}
int main(int argc, char **argv)
{
int device = argc > 1 ? atoi(argv[1]) : 0;
int iter = argc > 2 ? atoi(argv[2]) : 100;
bool console = argc > 2 ? argv[2][0] == '-' : false;
try {
printf("** ArrayFire Fractals Demo **\n");
float center[] = {-0.75, 0.1};
for (int i = 10; i < 400; i++) {
int zoom = i * i;
if(!(i % 10)) printf("iteration: %d zoom: %d\n", i, zoom); fflush(stdout);
array c = complex_grid(WIDTH, HEIGHT, zoom, center);
array mag = mandelbrot(c, iter, 1000);
if(!console) {
array mag_norm = normalize(mag);
}
}
fprintf(stderr,
"%s\n", e.
what());
throw;
}
return 0;
}