X-Git-Url: https://hackdaworld.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=nlsop.c;h=10a3f2f067d1638fd07c69417e1729586da4ae33;hb=f74b482d7bd66fe861621276c6564c55e394f209;hp=0104695126c699b150adb0db0d3d2951dcd56ff9;hpb=de3ae9b29a64eaf297b44665022665962eba4a14;p=physik%2Fnlsop.git diff --git a/nlsop.c b/nlsop.c index 0104695..10a3f2f 100644 --- a/nlsop.c +++ b/nlsop.c @@ -694,17 +694,26 @@ int get_c_ratio(double *c_ratio,char *pfile,info *my_info,d3_lattice *d3_l) return 1; } -int get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { +u32 get_reject_graph(info *my_info,d3_lattice *d3_l,char *file,u32 *graph) { double a,b; int i,j,k; int fd; char buf[32],*p; + unsigned char *flag; + u32 max; + max=0; 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,12 +731,30 @@ 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; + a=0; + while(imax_z) + { + /* graph[0] is 0! */ + j=i; + i++; + while(flag[i]==0&&imax_z) i++; + printf("debug: i = %d j = %d\n",i,j); + for(k=j+1;kmax) max=graph[i]; + } - return 1; + free(flag); + + return max; } int main(int argc,char **argv) @@ -771,6 +798,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; @@ -805,6 +834,7 @@ int main(int argc,char **argv) convert=0; strcpy(r_file,""); mode=0; + u32 ne_max; for(i=1;i