Debian Codegraph @

helical/dynphm.c

raw
1 #include <stdio.h>
2 #include <math.h>
3 int
4 main(int argc, char *argv[])
5 {
6 int view, nview;
7 char filename[128];
8
9 float mu1=0. , mu2=6., density, afac, s;
10
11 FILE *fp = (FILE *)NULL;
12 if (argc !=4){
13 fprintf(stderr, "Usage: %s iview nview phmfilename\n", argv[0]);
14 exit (1);
15 }
16
17 view = atoi(argv[1]);
18 nview = atoi(argv[2]);
19 sprintf(filename, "%s", argv[3]);
20
21 s = (float)view/((float)(nview-1));
22
23 if ( s < 7./16. )
24 density = mu1;
25 else if ( s > 9./16. )
26 density = mu2;
27 else {
28 afac = ( (s - 7./16.) / 2./16.);
29 density = log(1/((1-afac)*exp(-mu1) + afac * exp(-mu2)));
30 }
31
32 /*
33 density = mu1 + (mu2-mu1)*s;
34 if (s <=0.5)
35 density = mu1;
36 else
37 density = mu2;
38 */
39 if ( (fp = fopen(filename, "w")) == (FILE *)NULL){
40 fprintf(stderr,"Error, can not open file \"tmpphmfile\"\n");
41 exit(2);
42 }
43 fprintf(fp, "rectangle 0 0 11.5 11.5 0 0\n");
44 fprintf(fp, "ellipse 0 0 11.4 11.4 0 1\n");
45 fprintf(fp, "ellipse 0 0 1.25 1.25 0 %f\n", density);
46
47 fclose(fp);
48 exit(0);
49 }