|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T g
Length: 1570 (0x622) Types: TextFile Names: »gau.c«
└─⟦db229ac7e⟧ Bits:30007240 EUUGD20: SSBA 1.2 / AFW Benchmarks └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21E/bsd/gau.c« └─⟦this⟧ »EUUGD20/AFUU-ssba1.21/ssba1.21F/bsd/gau.c«
#define MULTIPLIER 25173 #define MODULUS 65536 #define INCREMENT 13849 #define FLOATING_MODULUS 65536.0 #define NITER 30000 float sqrt(), log(), rnd(), gauss(); char *malloc(); main(argc, argv) char *argv[]; { register int pn, i, niter, delta; register char *pages; float sd = 10.0; int npages = 4096,pagesize; char *name; double atof(); name = argv[0]; argc--, argv++; again: if (argc < 1) goto suite; if (strcmp(*argv, "-s") == 0){ argc--, argv++; if(argc < 1) goto suite; sd= (double) atof(*argv); if (sd <= 0){ printf("%s: Bad standard deviation.\n",*argv); exit(2); } argc--,argv++; goto again; } if (strcmp(*argv, "-p") == 0) { argc--,argv++; if(argc < 1) goto suite; npages = atoi(*argv); if(npages <= 0){ printf("%s: Bad page count.\n",*argv); exit(2); } argc--,argv++; goto again; } suite: niter = NITER; pagesize = 1024; pages = malloc(npages * pagesize); if(pages == (char *) 0){ printf("Can't allocate %d pages ( %2.1f megabytes).\n", npages, (npages * pagesize) / (1024. * 1024.)); exit(3); } pn = 0; for(i= 0; i < niter; i++){ delta = gauss(sd, 0.0); while(pn + delta < 0 || pn + delta > npages) delta = gauss(sd, 0.0); pn += delta; pages[pn * pagesize ] = 1; } } float gauss(sd, mean) float sd, mean; { register float qa, qb; qa = sqrt(log(rnd()) * -2.0); qb = 3.14159 * rnd(); return (qa * (1.0 - (qb*qb)/2.0) * sd + mean); } float rnd() { static int seed ; seed = (MULTIPLIER * seed + INCREMENT) % MODULUS; return (seed/FLOATING_MODULUS); }