2005-07-01 21:00:04 +00:00
|
|
|
/* Test/example program for the base library
|
|
|
|
|
|
|
|
Copyright (C) 2005 Free Software Foundation, Inc.
|
|
|
|
|
2005-07-15 22:51:23 +00:00
|
|
|
Copying and distribution of this file, with or without modification,
|
|
|
|
are permitted in any medium without royalty provided the copyright
|
|
|
|
notice and this notice are preserved.
|
|
|
|
|
2005-07-01 21:00:04 +00:00
|
|
|
This file is part of the GNUstep Base Library.
|
|
|
|
*/
|
1996-04-17 00:41:50 +00:00
|
|
|
|
2003-07-31 23:49:32 +00:00
|
|
|
#include <GNUstepBase/Random.h>
|
|
|
|
#include <GNUstepBase/RNGBerkeley.h>
|
|
|
|
#include <GNUstepBase/RNGAdditiveCongruential.h>
|
1996-04-17 00:41:50 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
id r;
|
|
|
|
id rng;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
r = [[Random alloc] init];
|
|
|
|
printf("float\n");
|
|
|
|
for (i = 0; i < 20; i++)
|
|
|
|
printf("%f\n", [r randomFloat]);
|
|
|
|
printf("doubles\n");
|
|
|
|
for (i = 0; i < 20; i++)
|
|
|
|
printf("%f\n", [r randomDouble]);
|
|
|
|
|
|
|
|
rng = [[RNGBerkeley alloc] init];
|
2005-02-22 11:22:44 +00:00
|
|
|
printf("%s chi^2 = %f\n",
|
1996-04-17 00:41:50 +00:00
|
|
|
[rng name], [Random chiSquareOfRandomGenerator:rng]);
|
|
|
|
[r release];
|
|
|
|
|
|
|
|
rng = [[RNGAdditiveCongruential alloc] init];
|
|
|
|
/*
|
|
|
|
for (i = 0; i < 50; i++)
|
|
|
|
printf("%ld\n", [r nextRandom]);
|
|
|
|
*/
|
2005-02-22 11:22:44 +00:00
|
|
|
printf("%s chi^2 = %f\n",
|
1996-04-17 00:41:50 +00:00
|
|
|
[rng name], [Random chiSquareOfRandomGenerator:rng]);
|
|
|
|
[rng release];
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|