Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
SFMT.h File Reference

SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom number generator using C structure. More...

#include <stdio.h>
#include <assert.h>
#include <inttypes.h>
#include "SFMT-params.h"
Include dependency graph for SFMT.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  W128_T
struct  SFMT_T

Macros

#define SFMTST_H
#define PRIu64   "llu"
#define PRIx64   "llx"

Typedefs

typedef union W128_T w128_t
typedef struct SFMT_T sfmt_t

Functions

void sfmt_fill_array32 (sfmt_t *sfmt, uint32_t *array, int size)
void sfmt_fill_array64 (sfmt_t *sfmt, uint64_t *array, int size)
void sfmt_init_gen_rand (sfmt_t *sfmt, uint32_t seed)
void sfmt_init_by_array (sfmt_t *sfmt, uint32_t *init_key, int key_length)
const char * sfmt_get_idstring (sfmt_t *sfmt)
int sfmt_get_min_array_size32 (sfmt_t *sfmt)
int sfmt_get_min_array_size64 (sfmt_t *sfmt)
void sfmt_gen_rand_all (sfmt_t *sfmt)
static uint32_t sfmt_genrand_uint32 (sfmt_t *sfmt)
static uint64_t sfmt_genrand_uint64 (sfmt_t *sfmt)
static double sfmt_to_real1 (uint32_t v)
static double sfmt_genrand_real1 (sfmt_t *sfmt)
static double sfmt_to_real2 (uint32_t v)
static double sfmt_genrand_real2 (sfmt_t *sfmt)
static double sfmt_to_real3 (uint32_t v)
static double sfmt_genrand_real3 (sfmt_t *sfmt)
static double sfmt_to_res53 (uint64_t v)
static double sfmt_genrand_res53 (sfmt_t *sfmt)
static double sfmt_to_res53_mix (uint32_t x, uint32_t y)
static double sfmt_genrand_res53_mix (sfmt_t *sfmt)

Detailed Description

SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom number generator using C structure.

Author
Mutsuo Saito (Hiroshima University)
Makoto Matsumoto (The University of Tokyo)

Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, Hiroshima University and The University of Tokyo. All rights reserved.

The 3-clause BSD License is applied to this software, see LICENSE.txt

Note
We assume that your system has inttypes.h. If your system doesn't have inttypes.h, you have to typedef uint32_t and uint64_t, and you have to define PRIu64 and PRIx64 in this file as follows:
 typedef unsigned int uint32_t
 typedef unsigned long long uint64_t
 #define PRIu64 "llu"
 #define PRIx64 "llx"
uint32_t must be exactly 32-bit unsigned integer type (no more, no less), and uint64_t must be exactly 64-bit unsigned integer type. PRIu64 and PRIx64 are used for printf function to print 64-bit unsigned int and 64-bit unsigned int in hexadecimal format.

Macro Definition Documentation

◆ PRIu64

#define PRIu64   "llu"

◆ PRIx64

#define PRIx64   "llx"

◆ SFMTST_H

#define SFMTST_H

Typedef Documentation

◆ sfmt_t

typedef struct SFMT_T sfmt_t

◆ w128_t

typedef union W128_T w128_t

128-bit data type

Function Documentation

◆ sfmt_fill_array32()

void sfmt_fill_array32 ( sfmt_t * sfmt,
uint32_t * array,
int size )

◆ sfmt_fill_array64()

void sfmt_fill_array64 ( sfmt_t * sfmt,
uint64_t * array,
int size )

◆ sfmt_gen_rand_all()

void sfmt_gen_rand_all ( sfmt_t * sfmt)
Here is the caller graph for this function:

◆ sfmt_genrand_real1()

double sfmt_genrand_real1 ( sfmt_t * sfmt)
inlinestatic

generates a random number on [0,1]-real-interval

Parameters
sfmtSFMT internal state
Returns
double on [0,1]-real-interval
Here is the call graph for this function:

◆ sfmt_genrand_real2()

double sfmt_genrand_real2 ( sfmt_t * sfmt)
inlinestatic

generates a random number on [0,1)-real-interval

Parameters
sfmtSFMT internal state
Returns
double on [0,1)-real-interval
Here is the call graph for this function:

◆ sfmt_genrand_real3()

double sfmt_genrand_real3 ( sfmt_t * sfmt)
inlinestatic

generates a random number on (0,1)-real-interval

Parameters
sfmtSFMT internal state
Returns
double on (0,1)-real-interval
Here is the call graph for this function:

◆ sfmt_genrand_res53()

double sfmt_genrand_res53 ( sfmt_t * sfmt)
inlinestatic

generates a random number on [0,1) with 53-bit resolution

Parameters
sfmtSFMT internal state
Returns
double on [0,1) with 53-bit resolution
Here is the call graph for this function:

◆ sfmt_genrand_res53_mix()

double sfmt_genrand_res53_mix ( sfmt_t * sfmt)
inlinestatic

generates a random number on [0,1) with 53-bit resolution using two 32bit integers.

Parameters
sfmtSFMT internal state
Returns
double on [0,1) with 53-bit resolution
Here is the call graph for this function:

◆ sfmt_genrand_uint32()

uint32_t sfmt_genrand_uint32 ( sfmt_t * sfmt)
inlinestatic

This function generates and returns 32-bit pseudorandom number. init_gen_rand or init_by_array must be called before this function.

Parameters
sfmtSFMT internal state
Returns
32-bit pseudorandom number
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sfmt_genrand_uint64()

uint64_t sfmt_genrand_uint64 ( sfmt_t * sfmt)
inlinestatic

This function generates and returns 64-bit pseudorandom number. init_gen_rand or init_by_array must be called before this function. The function gen_rand64 should not be called after gen_rand32, unless an initialization is again executed.

Parameters
sfmtSFMT internal state
Returns
64-bit pseudorandom number
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sfmt_get_idstring()

const char * sfmt_get_idstring ( sfmt_t * sfmt)

◆ sfmt_get_min_array_size32()

int sfmt_get_min_array_size32 ( sfmt_t * sfmt)

◆ sfmt_get_min_array_size64()

int sfmt_get_min_array_size64 ( sfmt_t * sfmt)

◆ sfmt_init_by_array()

void sfmt_init_by_array ( sfmt_t * sfmt,
uint32_t * init_key,
int key_length )

◆ sfmt_init_gen_rand()

void sfmt_init_gen_rand ( sfmt_t * sfmt,
uint32_t seed )
Here is the caller graph for this function:

◆ sfmt_to_real1()

double sfmt_to_real1 ( uint32_t v)
inlinestatic

converts an unsigned 32-bit number to a double on [0,1]-real-interval.

Parameters
v32-bit unsigned integer
Returns
double on [0,1]-real-interval
Here is the caller graph for this function:

◆ sfmt_to_real2()

double sfmt_to_real2 ( uint32_t v)
inlinestatic

converts an unsigned 32-bit integer to a double on [0,1)-real-interval.

Parameters
v32-bit unsigned integer
Returns
double on [0,1)-real-interval
Here is the caller graph for this function:

◆ sfmt_to_real3()

double sfmt_to_real3 ( uint32_t v)
inlinestatic

converts an unsigned 32-bit integer to a double on (0,1)-real-interval.

Parameters
v32-bit unsigned integer
Returns
double on (0,1)-real-interval
Here is the caller graph for this function:

◆ sfmt_to_res53()

double sfmt_to_res53 ( uint64_t v)
inlinestatic

converts an unsigned 32-bit integer to double on [0,1) with 53-bit resolution.

Parameters
v32-bit unsigned integer
Returns
double on [0,1)-real-interval with 53-bit resolution.
Here is the caller graph for this function:

◆ sfmt_to_res53_mix()

double sfmt_to_res53_mix ( uint32_t x,
uint32_t y )
inlinestatic

generates a random number on [0,1) with 53-bit resolution from two 32 bit integers

Here is the call graph for this function:
Here is the caller graph for this function: