X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b745e5b5a5f85947c7e08266c6dbdbbf9f563918..fe9136a55b6fb08018ff5500e7de1ba8e03caf9a:/src/xbt/RngStream.c diff --git a/src/xbt/RngStream.c b/src/xbt/RngStream.c index fb811439bd..a5a33134c6 100644 --- a/src/xbt/RngStream.c +++ b/src/xbt/RngStream.c @@ -4,7 +4,7 @@ * Language: ANSI C * Copyright: Pierre L'Ecuyer, University of Montreal * Date: 14 August 2001 - * License: GPL version 2 or later + * License: GPL version 2 or later * * Notice: Please contact P. L'Ecuyer at * for commercial purposes. @@ -70,19 +70,19 @@ static double A2p0[3][3] = { }; static double A1p76[3][3] = { - { 82758667.0, 1871391091.0, 4127413238.0 }, - { 3672831523.0, 69195019.0, 1871391091.0 }, + { 82758667.0, 1871391091.0, 4127413238.0 }, + { 3672831523.0, 69195019.0, 1871391091.0 }, { 3672091415.0, 3528743235.0, 69195019.0 } }; static double A2p76[3][3] = { - { 1511326704.0, 3759209742.0, 1610795712.0 }, - { 4292754251.0, 1511326704.0, 3889917532.0 }, + { 1511326704.0, 3759209742.0, 1610795712.0 }, + { 4292754251.0, 1511326704.0, 3889917532.0 }, { 3859662829.0, 4292754251.0, 3708466080.0 } }; static double A1p127[3][3] = { - { 2427906178.0, 3580155704.0, 949770784.0 }, + { 2427906178.0, 3580155704.0, 949770784.0 }, { 226153695.0, 1230515664.0, 3580155704.0 }, { 1988835001.0, 986791581.0, 1230515664.0 } }; @@ -269,30 +269,30 @@ static int CheckSeed (unsigned long seed[6]) for (i = 0; i < 3; ++i) { if (seed[i] >= m1) { - fprintf (stderr, "****************************************\n" - "ERROR: Seed[%1d] >= m1, Seed is not set.\n" - "****************************************\n\n", i); - return (-1); + fprintf (stderr, "****************************************\n" + "ERROR: Seed[%1d] >= m1, Seed is not set.\n" + "****************************************\n\n", i); + return (-1); } } for (i = 3; i < 6; ++i) { if (seed[i] >= m2) { - fprintf (stderr, "****************************************\n" - "ERROR: Seed[%1d] >= m1, Seed is not set.\n" - "****************************************\n\n", i); - return (-1); + fprintf (stderr, "****************************************\n" + "ERROR: Seed[%1d] >= m1, Seed is not set.\n" + "****************************************\n\n", i); + return (-1); } } if (seed[0] == 0 && seed[1] == 0 && seed[2] == 0) { fprintf (stderr, "****************************\n" - "ERROR: First 3 seeds = 0.\n" - "****************************\n\n"); + "ERROR: First 3 seeds = 0.\n" + "****************************\n\n"); return (-1); } if (seed[3] == 0 && seed[4] == 0 && seed[5] == 0) { fprintf (stderr, "****************************\n" - "ERROR: Last 3 seeds = 0.\n" - "****************************\n\n"); + "ERROR: Last 3 seeds = 0.\n" + "****************************\n\n"); return (-1); } @@ -346,6 +346,27 @@ void RngStream_DeleteStream (RngStream * p) /*-------------------------------------------------------------------------*/ +RngStream RngStream_CopyStream (const RngStream src) +{ + RngStream g; + + if(src == NULL) { + printf ("RngStream_CopyStream: 'src' not initialized\n\n"); + exit (EXIT_FAILURE); + } + + g = (RngStream) malloc (sizeof (struct RngStream_InfoState)); + if (g == NULL) { + printf ("RngStream_CopyStream: No more memory\n\n"); + exit (EXIT_FAILURE); + } + memcpy((void*) g, (void*) src, sizeof (struct RngStream_InfoState)); + + return g; +} + +/*-------------------------------------------------------------------------*/ + void RngStream_ResetStartStream (RngStream g) { int i; @@ -394,7 +415,7 @@ int RngStream_SetSeed (RngStream g, unsigned long seed[6]) return -1; /* FAILURE */ for (i = 0; i < 6; ++i) g->Cg[i] = g->Bg[i] = g->Ig[i] = seed[i]; - return 0; /* SUCCESS */ + return 0; /* SUCCESS */ } /*-------------------------------------------------------------------------*/ @@ -517,3 +538,15 @@ int RngStream_RandInt (RngStream g, int i, int j) { return i + (int) ((j - i + 1.0) * RngStream_RandU01 (g)); } + +/* Undefine this terms, or supernovae build will fail. */ +#undef norm +#undef m1 +#undef m2 +#undef a12 +#undef a13n +#undef a21 +#undef a23n +#undef two17 +#undef two53 +#undef fact