Macaulay2 Engine
Loading...
Searching...
No Matches

◆ rawRandomInt()

int32_t rawRandomInt ( int32_t max)

Definition at line 44 of file random.cpp.

46{
47 if (max <= 0) return 0;
48 int32_t k = RandomSeed / IQ;
50 IA * (RandomSeed - k * IQ) - IR * k; /* Schrage algorithm to compute
51 idum = (IA*idum) mod IM */
52 if (RandomSeed < 0) RandomSeed += IM;
53 return RandomSeed % max;
54}
#define max(a, b)
Definition polyroots.cpp:52
static int32_t RandomSeed
Definition random.cpp:19
#define IM
Definition random.cpp:12
#define IR
Definition random.cpp:14
#define IQ
Definition random.cpp:13
#define IA
Definition random.cpp:11

References IA, IM, IQ, IR, max, and RandomSeed.

Referenced by getElement< M2::ARingGFFlint >(), GF::random(), M2::ARingGFM2::random(), M2::ARingZZp::random(), Matrix::random(), Z_mod::random(), rawMutableMatrixFillRandom(), rawMutableMatrixFillRandomDensity(), system_randomint(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), TEST(), testRingPower(), and ZZp_RANDOM().