Ejemplo n.º 1
0
int main (int argc, char * const argv[]) {    
    dependency_test1();
    //dependency_test2();
    dependency_test3();
    mandelbrot_test();
    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	image_meta image;
	image = image_meta_gen(argc, argv);
	
	FILE *file;
	colour *rgb;
	double xdiff, ydiff, a, b;
	int ypx, xpx;
	
	if(!(rgb = malloc(image.width * image.height * sizeof(colour)))) {
		fprintf(stderr, "Memory allocation error!\n");
		exit(MEM_ERROR);
	}
	
	if(!(file = fopen(image.file_name, "w"))) {
		fprintf(stderr, "File access error!\n");
		free(rgb);
		exit(FILE_ERROR);
	} else {
		printf("Generating image...\n");
		fprintf(file, "P6 %d %d 255\n", image.width, image.height);
		xdiff = image.xmax - image.xmin;
		ydiff = image.ymax - image.ymin;
		
		#pragma omp parallel 
		{
			#pragma omp for schedule(dynamic)
			for(ypx = 0; ypx < image.height; ypx++) {
				for(xpx = 0; xpx < image.width; xpx++) {
					double a = image.xmin + xpx * xdiff / image.width;
					double b = image.ymax - ypx * ydiff / image.height;
					double complex num = a + b * I;
					rgb[ypx * image.width + xpx] = rgb_gen(mandelbrot_test(num));
				}
			}
		}
		
		fwrite(rgb, sizeof(colour), image.width * image.height, file);
		fclose(file);
	}
	exit(EXEC_SUCCESS);
}