/******************************************************************* cell.c - started 6/18/95 - Eric Weeks just a quick program to make sure my a2ps program is working also I'm killing time v02: 6-19-95 taken from "cell1bak.c"; changed to do real numbers v03: 8-30-96: cleaned up a little bit. email: weeks@physics.emory.edu web: http://www.physics.emory.edu/~weeks/ to compile: cc -o cell cell3.c -lm *******************************************************************/ #include #include #include #include #define PI 3.14159265358979323846264338328 #define EE 2.71828182845904523536 #define SIZE 1000 void rand_init(); double drnd(); char *prgname; main(argc,argv) int argc; char **argv; { int t,r,bit; double array[SIZE][2],newcell; int a,b,c,num; extern int optind; extern char *optarg; double gamma,alpha[3]; num = 500; rand_init(); alpha[0] = 2.0*drnd()-1.0; alpha[1] = 2.0*drnd()-1.0; alpha[2] = 2.0*drnd()-1.0; gamma = drnd()*1.0-0.5; while ((c = getopt(argc, argv, "hn:u:a:b:c:d:")) != EOF) switch (c) { case 'h': fprintf(stderr,"Usage: %s [options]\n",argv[0]); fprintf(stderr,"Options:\n"); fprintf(stderr,"x_n new = A x_{n-1} + B x_n + C x_{n+1} + D\n\n"); fprintf(stderr," -n # : number of cells [%d]\n",num); fprintf(stderr," -a # : change A, coefficient of a_{n-1}\n"); fprintf(stderr," -b # : change B, coefficient of a_n\n"); fprintf(stderr," -c # : change C, coefficient of a_{n+1}\n"); fprintf(stderr," -d # : change D, the constant\n"); fprintf(stderr,"\nOutput suitable for programs a2ps or a2ppm\n"); exit(1); break; case 'n': num = atoi(optarg); if (num>SIZE) { fprintf(stderr,"ERROR: -n is too large\n"); fprintf(stderr," change value of SIZE in program\n"); fprintf(stderr," currently SIZE = %d\n",SIZE); exit(1); } break; case 'a': alpha[0] = atof(optarg); break; case 'b': alpha[1] = atof(optarg); break; case 'c': alpha[2] = atof(optarg); break; case 'd': gamma = atof(optarg); break; } fprintf(stderr,"%f %f %f %f\n",gamma,alpha[0],alpha[1],alpha[2]); /* random initial conditions */ for (t=0;t