diff options
| author | tomsmeding <tom.smeding@gmail.com> | 2017-04-05 15:58:57 +0200 | 
|---|---|---|
| committer | tomsmeding <tom.smeding@gmail.com> | 2017-04-05 15:58:57 +0200 | 
| commit | 3c845bf493856da2de260f56f60d11a6c746ccef (patch) | |
| tree | a03b3d270d44fb0905e3b22c77543ef118bf08bb | |
| parent | 3cbc229cde5e4bb455fae3158d7d658c0036e23d (diff) | |
Make exponent variable
| -rw-r--r-- | attract.c | 19 | 
1 files changed, 10 insertions, 9 deletions
| @@ -15,7 +15,7 @@  const int MAXITER=200;  const double EPS=1e-1; -static double complex att_func(double complex x){ +static double complex att_func(double complex x,double exponent){  #if 0  	static const int N=9; @@ -27,8 +27,7 @@ static double complex att_func(double complex x){  	r+=y;  	return clog(r);  #else -	static const double N=8.5; -	return clog((1-cpow(x,N+1))/(1-x)); +	return clog((1-cpow(x,exponent+1))/(1-x));  #endif  } @@ -49,8 +48,9 @@ static struct colour make_colour(int index){  }  struct config{ -	const double unitsz; -	const int width,height; +	double unitsz; +	int width,height; +	double exponent;  };  struct thread_info{ @@ -86,7 +86,7 @@ static void* thread_entry(void *arg_vp){  					(double)(iy-cfg.height/2)/cfg.unitsz);  			double complex z=start;  			for(int i=0;i<MAXITER;i++){ -				z=att_func(z); +				z=att_func(z,cfg.exponent);  			}  			if(do_basins){  				int bi; @@ -121,8 +121,9 @@ static void* thread_entry(void *arg_vp){  int main(void){  	struct config cfg={ -		200, -		500, 500 +		.unitsz=200, +		.width=500, .height=500, +		.exponent=8.5  	};  	unsigned char img[cfg.width*cfg.height*3]; @@ -145,7 +146,7 @@ int main(void){  		ths[i].yend=(i+1)*cfg.height/nthreads;  		ths[i].img=img;  		ths[i].do_basins=nthreads==1; -		memcpy(&ths[i].cfg,&cfg,sizeof(struct config)); +		ths[i].cfg=cfg;  		int ret=pthread_create(&ths[i].th,&attr,thread_entry,&ths[i]);  		if(ret!=0){  			perror("pthread_create"); | 
