The R Project SVN R

Rev

Rev 72357 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 72357 Rev 83153
Line 48... Line 48...
48
 
48
 
49
static Int32 seed;
49
static Int32 seed;
50
static double res;
50
static double res;
51
static int nseed = 1;
51
static int nseed = 1;
52
 
52
 
53
double * user_unif_rand()
53
double * user_unif_rand(void)
54
{
54
{
55
    seed = 69069 * seed + 1;
55
    seed = 69069 * seed + 1;
56
    res = seed * 2.32830643653869e-10;
56
    res = seed * 2.32830643653869e-10;
57
    return &res;
57
    return &res;
58
}
58
}
59
 
59
 
60
void  user_unif_init(Int32 seed_in) { seed = seed_in; }
60
void  user_unif_init(Int32 seed_in) { seed = seed_in; }
61
int * user_unif_nseed() { return &nseed; }
61
int * user_unif_nseed(void) { return &nseed; }
62
int * user_unif_seedloc() { return (int *) &seed; }
62
int * user_unif_seedloc(void) { return (int *) &seed; }
63
 
63
 
64
/*  ratio-of-uniforms for normal  */
64
/*  ratio-of-uniforms for normal  */
65
#include <math.h>
65
#include <math.h>
66
static double x;
66
static double x;
67
 
67
 
68
double * user_norm_rand()
68
double * user_norm_rand(void)
69
{
69
{
70
    double u, v, z;
70
    double u, v, z;
71
    do {
71
    do {
72
        u = unif_rand();
72
        u = unif_rand();
73
        v = 0.857764 * (2. * unif_rand() - 1);
73
        v = 0.857764 * (2. * unif_rand() - 1);