Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96791437
random_lt.c
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 30, 21:35
Size
1 KB
Mime Type
text/x-c
Expires
Wed, Jan 1, 21:35 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23226458
Attached To
R1448 Lenstool-HPC
random_lt.c
View Options
#include <stdio.h>
#include <stdlib.h>
#include <fonction.h>
/* tire des nombres entre 0 et 1 selon une loi uniforme*/
#define M1 259200
#define IA1 7141
#define IC1 54773
#define RM1 (1.0/M1)
#define M2 134456
#define IA2 8121
#define IC2 28841
#define RM2 (1.0/M2)
#define M3 243000
#define IA3 4561
#define IC3 51349
double d_random(int *idum)
{
static long ix1, ix2, ix3;
static double r[98];
double temp;
static int iff = 0;
int j;
if (*idum < 0 || iff == 0)
{
iff = 1;
ix1 = (IC1 - (*idum)) % M1;
ix1 = (IA1 * ix1 + IC1) % M1;
ix2 = ix1 % M2;
ix1 = (IA1 * ix1 + IC1) % M1;
ix3 = ix1 % M3;
for (j = 1; j <= 97; j++)
{
ix1 = (IA1 * ix1 + IC1) % M1;
ix2 = (IA2 * ix2 + IC2) % M2;
r[j] = (ix1 + ix2 * RM2) * RM1;
}
*idum = 1;
}
ix1 = (IA1 * ix1 + IC1) % M1;
ix2 = (IA2 * ix2 + IC2) % M2;
ix3 = (IA3 * ix3 + IC3) % M3;
j = 1 + ((97 * ix3) / M3);
if (j > 97 || j < 1)
{
printf("je me suis plantee\n");
j = abs(*idum);
};
temp = r[j];
r[j] = (ix1 + ix2 * RM2) * RM1;
return temp;
}
Event Timeline
Log In to Comment