-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.h
36 lines (31 loc) · 877 Bytes
/
utils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef UTILS_H
#define UTILS_H
#include <stdlib.h>
#include <math.h>
#include <gmp.h>
#include "point.h"
#define ASSERT_MSG(expression, msg, code)\
if (!(expression)) {\
fprintf(stderr, "Assertion error at %s:%d: %s\n", __FILE__, __LINE__, (msg));\
exit(code);\
}
#define RANDMAX(max) (random() % max)
#define WHERE_AM_I() printf("%s:%u\n", __FILE__, __LINE__)
/**
* Returns a floating-point pseudo-random value contained within min and max,
* storing it into result.
*
* Returns:
* 0 on success;
* -1 if max is not strictly greater than min.
*/
int frandom(long double min, long double max, long double *result);
/**
* Sets rop to a randomly-computed value between min and max.
*
* Returns:
* 0 on success;
* -1 if max is equal or less than min.
*/
int mpf_urandomb_between(mpf_t rop, gmp_randstate_t rstate, const char *min, const char *max);
#endif