Questa è una vecchia versione del documento!
#include <iostream>
#include <string>
#include <algorithm>
#include “tbb/parallel_for.h”
#include “tbb/blocked_range.h”
using namespace tbb;
using namespace std;
costanti di default
square area, lower left angle and size
#define DEFAULT_X -2.0
#define DEFAULT_Y -2.0
#define DEFAULT_SIZE 4.0
#define DEFAULT_PIXELS 10
#define DEFAULT_ITERATIONS 1000
we assume a point diverges if quared modulus exceeds this value
#define MAX_SMODULUS = 4
static int maxIter = DEFAULT_ITERATIONS;
funzione per calcolo mandelbrot in un punto
returns the number of iteration until divergence
int mand_compute( double cx, double cy)
{
int i;
double x = cx; double y = cy;
double nx, ny;
for (i=0; i<maxIter; i++)
{
(x,y)^2 + c
nx = x*x - y*y;
ny = 2*x*y
if ( nx*nx + ny*ny > MAX_SMODULUS ) break;
}
return i;
}
class to hold the computation
main
int main () {
inizializza iterazioni
inizializza zona
crea parallel range
parallel for
}