File: shared.h

package info (click to toggle)
python-thinc 6.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,388 kB
  • sloc: python: 7,120; ansic: 6,257; makefile: 19; sh: 11
file content (19 lines) | stat: -rw-r--r-- 656 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* shared.h: a set of simple functions used by both exponential.h and normal.h */
#pragma once

#include <stdlib.h>
#include <math.h>
#include "MT19937.h"

/* All of the arrays are scaled by 2**63 (not 2**64), so this operation is used 
* to draw uniform values in the ziggurat overhangs*/

#define MAX_INT64   0x7fffffffffffffff
#define RANDOM_INT63() ( Rand++->sl & MAX_INT64 )

/* Test to see if rejection sampling is required in the overhang. See Fig. 2
 * in main text. */

#define _FAST_PRNG_SAMPLE_X(X_j, U) (   *(X_j)*pow(2, 63) + ((X_j)[-1] - *(X_j) )*(U) )
#define _FAST_PRNG_SAMPLE_Y(i,   U) ( Y[(i)-1]*pow(2, 63) + (Y[(i)  ] - Y[(i)-1])*(U) )