From: hackbard Date: Mon, 14 Jun 2004 11:54:52 +0000 (+0000) Subject: anfaenge random rejection stuff X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=9a424ed8a83609409d67b28890475f81581f501e;p=physik%2Fnlsop.git anfaenge random rejection stuff --- diff --git a/nlsop.c b/nlsop.c index 0104695..58f19f7 100644 --- a/nlsop.c +++ b/nlsop.c @@ -699,12 +699,19 @@ int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { int i,j,k; int fd; char buf[32],*p; + unsigned char *flag; if((fd=open(file,O_RDONLY))<0) { puts("cannot open file to calculate rejection graph"); return -1; } + if((flag=(unsigned char *)malloc(d3_l->max_z))==NULL) + { + puts("cannot malloc flag memory for rejection graph"); + return -1; + } + memset(flag,0,d3_l->max_z); memset(graph,0,d3_l->max_z*sizeof(u32)); /* get fixpoints */ k=1; @@ -722,10 +729,25 @@ int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { p=strtok(NULL," "); b=atof(p); if(a>d3_l->max_z*CELL_LENGTH) k=0; - else graph[(int)(a/CELL_LENGTH)]=(int)(URAND_MAX*b); + else + { + graph[(int)(a/CELL_LENGTH)]=(int)(URAND_MAX*b); + flag[(int)(a/CELL_LENGTH)]=1; + } } } - /* do interpolation here! */ + /* do (linear) interpolation here! */ + i=0; + while(imax_z) + { + a=0; + + // WEITER HIER !! + + } + + printf("%s graph:\n",file); + for(i=0;imax_z;i++) printf("%02d | %d\n",i,graph[i]); return 1; } @@ -771,6 +793,8 @@ int main(int argc,char **argv) #ifdef USE_DFB_API int max_extra; #endif + u32 *c_profile; + u32 *n_e_loss; d3_l.max_x=X; d3_l.max_y=Y; @@ -1004,11 +1028,32 @@ int main(int argc,char **argv) if((!strcmp(l_file,""))||(c_step)) { + /* calculate ratio of c_simwindow / c_total */ if(get_c_ratio(&c_ratio,p_file,&my_info,&d3_l)!=1) { puts("failed calculating ratio"); return -1; } + /* compute graphs for random number rejection method */ + if((c_profile=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL) + { + puts("failed allocating memory for carbon profile graph"); + return -1; + } + if((n_e_loss=(u32 *)malloc(d3_l.max_z*sizeof(unsigned int)))==NULL) + { + puts("failed allocating memory for nuclear energy loss graph"); + return -1; + } + if(get_reject_graph(&my_info,&d3_l,p_file,c_profile)!=1) + { + puts("failed to get reject graph"); + return -1; + } + + /* break here for testing ... */ + return 23; + i=(c_step?c_step:0); while((i