urand.c File Reference

#include <math.h>
#include "machine.h"
#include "sciprint.h"

Include dependency graph for urand.c:

Go to the source code of this file.

Functions

unsigned long urandc ()
int set_state_urand (double g)
void get_state_urand (double g[])

Variables

static unsigned long s = 0


Function Documentation

void get_state_urand ( double  g[]  ) 

Definition at line 51 of file urand.c.

References s.

Referenced by RandI().

00052 {
00053   g[0] = (double) s;
00054 }

Here is the caller graph for this function:

int set_state_urand ( double  g  ) 

Definition at line 37 of file urand.c.

References long, s, and sciprint().

Referenced by RandI().

00038 {
00039   if ( g == floor(g) &&  0 <= g && g <= 2147483647 )
00040     {
00041       s = (unsigned long) g;
00042       return ( 1 );
00043     }
00044   else
00045     {
00046       sciprint("\n\r bad seed for urand, must be an integer in [0,  2147483647]\n\r");
00047       return ( 0 );
00048     }
00049 }

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned long urandc (  ) 

Definition at line 27 of file urand.c.

References s.

00028 {
00029   s = 843314861ul * s + 453816693ul;  /* => on obtient ici un resultat modulo 2^32 */
00030 
00031   /* il suffit du test suivant pour obtenir le modulo 2^31 */
00032   if (s >= 2147483648ul) s -= 2147483648ul;
00033 
00034   return ( s );
00035 }


Variable Documentation

unsigned long s = 0 [static]

Definition at line 25 of file urand.c.


Generated on Sun Mar 4 16:11:29 2007 for Scilab [trunk] by  doxygen 1.5.1