Пример #1
0
void Julia(double  xmin,double  xmax,double  ymin,double  ymax, double  resolution,
		int maxsteps,int* matrix,int height,int width,double  compp1,double  compp2,int lines,int rank,int notask){
	
	int i = rank * lines,j = 0;
	double  x = xmin;
	double  y = ymin + resolution*rank*lines;
//	cout<<"Am aici commp1 si compp2"<<compp1<<" "<<compp2<<"\n";	
	Complex *c = new Complex(compp1,compp2);
//	cout<<"\t Julia sunt in threadul"<<rank<<"si am x de inceput: "<<x<<" si y de inceput "<<y<<"\n";
	
	Complex *z;
	int k = 0;
	if(rank != notask -1){
		while(i < (rank*lines + lines)){
			x = xmin;
			j = 0;
		
			while(j < width){
			
			
				z = new Complex(x,y);
				int step = 0;
			
				while( z->modul() < 4 && step < maxsteps){
					z->inmultire(z);
					z->plus(c);
					step++;
				}
				int color = step % 256;
				matrix[k] = color;
				x += resolution;
				j++;
				k++;
			
			}
			y+= resolution;
			i++;
		}
	}else{
		while(i < height){
			x = xmin;
			j = 0;
		
			while(j < width){
			
			
				z = new Complex(x,y);
				int step = 0;
			
				while( z->modul() < 4 && step < maxsteps){
					z->inmultire(z);
					z->plus(c);
					step++;
				}
				int color = step % 256;
				matrix[k] = color;
				x += resolution;
				j++;
				k++;
			
			}
			
			y+= resolution;
			i++;
		}
	}
//	cout<<"Si am scris aici in Julia "<< k <<" chestii \n";	
}