#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "mtgp32-fast.h"
Functions | |
| static uint32_t | ini_func1 (uint32_t x) |
| This function represents a function used in the initialization by mtgp32_init_by_array() and mtgp32_init_by_str(). | |
| static uint32_t | ini_func2 (uint32_t x) |
| This function represents a function used in the initialization by mtgp32_init_by_array() and mtgp32_init_by_str(). | |
| static int | alloc_state (mtgp32_fast_t *mtgp32, const mtgp32_params_fast_t *para) |
| This function allocates the internal state vector. | |
| int | mtgp32_init (mtgp32_fast_t *mtgp32, const mtgp32_params_fast_t *para, uint32_t seed) |
| This function allocates and initializes the internal state array with a 32-bit integer seed. | |
| void | mtgp32_init_state (uint32_t array[], const mtgp32_params_fast_t *para, uint32_t seed) |
| This function initializes the internal state array with a 32-bit integer seed. | |
| int | mtgp32_init_by_array (mtgp32_fast_t *mtgp32, const mtgp32_params_fast_t *para, uint32_t *array, int length) |
| This function allocates and initializes the internal state array with a 32-bit integer array. | |
| int | mtgp32_init_by_str (mtgp32_fast_t *mtgp32, const mtgp32_params_fast_t *para, char *array) |
| This function allocates and initializes the internal state array with a character array. | |
| void | mtgp32_free (mtgp32_fast_t *mtgp32) |
| This releases the memory allocated by mtgp32_init(), mtgp32_init_by_array(), mtgp32_init_by_str(). | |
| void | mtgp32_print_idstring (const mtgp32_fast_t *mtgp32, FILE *fp) |
| This function prints the Mersenne exponent and SHA1 of characteristic polynomial of generators state transition function. | |
Variables | |
| static const uint32_t | non_zero = 0x4d544750 |
Copyright (C) 2009 Mutsuo Saito, Makoto Matsumoto and Hiroshima University. All rights reserved.
The new BSD License is applied to this software, see LICENSE.txt
| static int alloc_state | ( | mtgp32_fast_t * | mtgp32, | |
| const mtgp32_params_fast_t * | para | |||
| ) | [static] |
This function allocates the internal state vector.
| [in,out] | mtgp32 | MTGP all in one structure. |
| [in] | para | a parameter structure. |
References MTGP32_STATUS_FAST_T::large_mask, MTGP32_STATUS_FAST_T::large_size, MTGP32_PARAMS_FAST_T::mexp, MTGP32_FAST_T::params, MTGP32_STATUS_FAST_T::size, and MTGP32_FAST_T::status.
Referenced by mtgp32_init(), mtgp32_init_by_array(), and mtgp32_init_by_str().
| static uint32_t ini_func1 | ( | uint32_t | x | ) | [static] |
This function represents a function used in the initialization by mtgp32_init_by_array() and mtgp32_init_by_str().
| [in] | x | 32-bit integer |
Referenced by mtgp32_init_by_array(), and mtgp32_init_by_str().
| static uint32_t ini_func2 | ( | uint32_t | x | ) | [static] |
This function represents a function used in the initialization by mtgp32_init_by_array() and mtgp32_init_by_str().
| [in] | x | 32-bit integer |
Referenced by mtgp32_init_by_array(), and mtgp32_init_by_str().
| void mtgp32_free | ( | mtgp32_fast_t * | mtgp32 | ) |
This releases the memory allocated by mtgp32_init(), mtgp32_init_by_array(), mtgp32_init_by_str().
| [in,out] | mtgp32 | MTGP all in one structure. |
References MTGP32_FAST_T::status.
| int mtgp32_init | ( | mtgp32_fast_t * | mtgp32, | |
| const mtgp32_params_fast_t * | para, | |||
| uint32_t | seed | |||
| ) |
This function allocates and initializes the internal state array with a 32-bit integer seed.
The allocated memory should be freed by calling mtgp32_free(). para should be one of the elements in the parameter table (mtgp32-param-ref.c).
| [out] | mtgp32 | MTGP structure. |
| [in] | para | parameter structure |
| [in] | seed | a 32-bit integer used as the seed. |
References alloc_state(), MTGP32_STATUS_FAST_T::array, MTGP32_STATUS_FAST_T::idx, mtgp32_init_state(), MTGP32_STATUS_FAST_T::size, and MTGP32_FAST_T::status.
| int mtgp32_init_by_array | ( | mtgp32_fast_t * | mtgp32, | |
| const mtgp32_params_fast_t * | para, | |||
| uint32_t * | array, | |||
| int | length | |||
| ) |
This function allocates and initializes the internal state array with a 32-bit integer array.
The allocated memory should be freed by calling mtgp32_free(). para should be one of the elements in the parameter table (mtgp32-param-ref.c).
| [out] | mtgp32 | MTGP structure. |
| [in] | para | parameter structure |
| [in] | array | a 32-bit integer array used as a seed. |
| [in] | length | length of the array. |
References alloc_state(), MTGP32_STATUS_FAST_T::array, MTGP32_STATUS_FAST_T::idx, ini_func1(), ini_func2(), MTGP32_PARAMS_FAST_T::mexp, non_zero, MTGP32_FAST_T::params, MTGP32_STATUS_FAST_T::size, MTGP32_FAST_T::status, and MTGP32_PARAMS_FAST_T::tbl.
| int mtgp32_init_by_str | ( | mtgp32_fast_t * | mtgp32, | |
| const mtgp32_params_fast_t * | para, | |||
| char * | array | |||
| ) |
This function allocates and initializes the internal state array with a character array.
The allocated memory should be freed by calling mtgp32_free(). para should be one of the elements in the parameter table (mtgp32-param-ref.c). This is the same algorithm with mtgp32_init_by_array(), but hope to be more useful.
| [out] | mtgp32 | MTGP structure. |
| [in] | para | parameter structure |
| [in] | array | a character array used as a seed. (terminated by zero.) |
References alloc_state(), MTGP32_STATUS_FAST_T::array, MTGP32_STATUS_FAST_T::idx, ini_func1(), ini_func2(), MTGP32_PARAMS_FAST_T::mexp, non_zero, MTGP32_FAST_T::params, MTGP32_STATUS_FAST_T::size, MTGP32_FAST_T::status, and MTGP32_PARAMS_FAST_T::tbl.
| void mtgp32_init_state | ( | uint32_t | array[], | |
| const mtgp32_params_fast_t * | para, | |||
| uint32_t | seed | |||
| ) |
This function initializes the internal state array with a 32-bit integer seed.
The allocated memory should be freed by calling mtgp32_free(). para should be one of the elements in the parameter table (mtgp32-param-ref.c).
This function is call by cuda program, because cuda program uses another structure and another allocation method.
| [out] | array | MTGP internal status vector. |
| [in] | para | parameter structure |
| [in] | seed | a 32-bit integer used as the seed. |
References MTGP32_PARAMS_FAST_T::mexp, and MTGP32_PARAMS_FAST_T::tbl.
Referenced by make_kernel_data(), and mtgp32_init().
| void mtgp32_print_idstring | ( | const mtgp32_fast_t * | mtgp32, | |
| FILE * | fp | |||
| ) |
This function prints the Mersenne exponent and SHA1 of characteristic polynomial of generators state transition function.
| [in] | mtgp32 | MTGP all in one structure. |
| [in,out] | fp | FILE pointer. |
References MTGP32_PARAMS_FAST_T::mexp, MTGP32_FAST_T::params, and MTGP32_PARAMS_FAST_T::poly_sha1.
const uint32_t non_zero = 0x4d544750 [static] |
Referenced by mtgp32_init_by_array(), and mtgp32_init_by_str().
1.5.9