Macaulay2 Engine
Loading...
Searching...
No Matches
random.h
Go to the documentation of this file.
1// Copyright 2008 by Michael Stillman
2
3#ifndef _rand_h_
4# define _rand_h_
5
46
47# include "engine-includes.hpp"
48
52
53# if defined(__cplusplus)
54extern "C" {
55# endif
56
58
59void rawSetRandomSeed(gmp_ZZ newseed);
60
62
63unsigned long rawRandomULong(unsigned long max);
64/* generate a random number in the range 0..max-1 */
65
66int32_t rawRandomInt(int32_t max);
67/* generate a random number in the range 0..max-1 */
68
69void rawSetRandomInteger(mpz_ptr result, gmp_ZZ maxN);
70/* if height is the null pointer, use the default height */
71/* doesn't deal w/ garbage collection */
72
74/* if height is the null pointer, use the default height */
75/* returns garbage-collected memory */
76
77void rawSetFareyApproximation(mpq_ptr result, gmp_RR x, gmp_ZZ height);
78/* sets result = the nearest rational to x w/ denominator <= height */
79
81/* returns the nearest rational to x w/ denominator <= height */
82
84/* returns random a/b, where 1 <= b <= height, 1 <= a <= height */
85/* if height is the null pointer, use the default height */
86
87void rawSetRandomQQ(mpq_ptr result, gmp_ZZ height);
88/* sets result = random a/b, where 1 <= b <= height, 1 <= a <= height */
89/* if height is the null pointer, use the default height */
90
91gmp_RR rawRandomRRUniform(unsigned long prec);
92/* returns a uniformly distributed random real with the given precision, in
93 * range [0.0,1.0] */
94
95gmp_RR rawRandomRRNormal(unsigned long prec);
96/* returns a normally distributed random real with the given precision */
97
98gmp_CC rawRandomCC(unsigned long prec);
99
100void randomMpfr(mpfr_t result);
101
102gmp_RRi rawRandomRRi(unsigned long prec);
103void rawSetRandomRRi(mpfi_ptr result);
104/* returns an interval with the given precision containing two random
105 * variates from the uniform distribution on [0, 1] */
106
107gmp_CCi rawRandomCCi(unsigned long prec);
108/* returns a complex interval with the given precision whose real and imaginary
109 * parts each contain two random variates from the uniform distribution on
110 * [0, 1] */
111
112double randomDouble();
113
114int system_randomint();
115
116# if defined(__cplusplus)
117}
118# endif
119
120#endif
121
122// Local Variables:
123// indent-tabs-mode: nil
124// End:
Engine-wide include prelude — a single point of truth for portability shims.
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpfr_srcptr gmp_RR
Definition m2-types.h:148
struct gmp_CC_struct * gmp_CC
Definition m2-types.h:156
mpfi_srcptr gmp_RRi
Definition m2-types.h:153
mpz_srcptr gmp_ZZ
Definition m2-types.h:141
mpq_srcptr gmp_QQ
Definition m2-types.h:145
struct gmp_CCi_struct * gmp_CCi
Definition m2-types.h:162
volatile int x
#define max(a, b)
Definition polyroots.cpp:52
gmp_RR rawRandomRRNormal(unsigned long prec)
Definition random.cpp:221
double randomDouble()
Definition random.cpp:248
void rawSetRandomMax(gmp_ZZ)
Definition random.cpp:38
gmp_CCi rawRandomCCi(unsigned long prec)
Definition random.cpp:281
unsigned long rawRandomULong(unsigned long max)
Definition random.cpp:39
void rawSetFareyApproximation(mpq_ptr result, gmp_RR x, gmp_ZZ height)
Definition random.cpp:83
void rawSetRandomSeed(gmp_ZZ newseed)
Definition random.cpp:28
void rawSetRandomRRi(mpfi_ptr result)
Definition random.cpp:258
int32_t rawRandomInt(int32_t max)
Definition random.cpp:44
void rawSetRandomInteger(mpz_ptr result, gmp_ZZ maxN)
Definition random.cpp:56
gmp_CC rawRandomCC(unsigned long prec)
Definition random.cpp:230
void rawSetRandomQQ(mpq_ptr result, gmp_ZZ height)
Definition random.cpp:170
void rawRandomInitialize()
Definition random.cpp:21
void randomMpfr(mpfr_t result)
Definition random.cpp:240
gmp_ZZ rawRandomInteger(gmp_ZZ maxN)
Definition random.cpp:66
gmp_RR rawRandomRRUniform(unsigned long prec)
Definition random.cpp:211
gmp_QQ rawRandomQQ(gmp_ZZ height)
Definition random.cpp:194
gmp_QQ rawFareyApproximation(gmp_RR x, gmp_ZZ height)
Definition random.cpp:161
gmp_RRi rawRandomRRi(unsigned long prec)
Definition random.cpp:270
int system_randomint()
Definition random.cpp:290