#include #include #include #define ITERS 300 #define BIG 1000 #define MAXACOLOR 2048 #define MAXBCOLOR 255 typedef struct { /*Complex number definition*/ double re, im; } complex; complex csum (complex a, complex b){ /*Complex sum*/ complex c; c.re = a.re + b.re; c.im = a.im + b.im; return c; } complex cquad (complex a){ /*Complex square*/ complex c; c.re = a.re*a.re - a.im*a.im; c.im = 2 * a.re * a.im; return c; } double cmod (complex a){ /*Complex module*/ return sqrt(a.re*a.re + a.im*a.im); } complex sucession (complex x, complex c){ /*Mandelbrot set*/ return csum(cquad(x),c); } void rdata(char *myfile, double *x){ /* This function reads the data that provides the range * to construct the complex numbers with format * * Imaginary_part_(minimum) Imaginary_part_(maximum) Imaginary_part_(range_width) * Real_part_(minimum) Real_part_(maximum) Real_part_(range_width) * * Values are stored in array x * */ FILE *f = fopen(myfile,"r"); fscanf(f, "%lf %lf %lf\n", &x[0], &x[1], &x[2]); fscanf(f, "%lf %lf %lf", &x[3], &x[4], &x[5]); fclose(f); return; } int iterate(complex c, complex (*f)(complex, complex)){ /* This function iterates the f function ITERS times or while its value * is lower than BIG. * * It returns the number of iterations done. * */ complex x; int i = 0; x.re = 0; x.im = 0; while (i