MTToolBox
0.2.10
|
name space for MTToolBox More...
Data Structures | |
class | AbstractGenerator |
pseudo random number generator. More... | |
class | AlgorithmBestBits |
Algorithm which searches tempering parameters. More... | |
class | AlgorithmCalculateParity |
Calculate the parity check vector of reducible generator. More... | |
class | AlgorithmEquidistribution |
Calculate dimension of equi-distribution of output of pseudo random number generators. More... | |
class | AlgorithmPartialBitPattern |
Algorithm that search tempering parameters to improve dimension of equi-distribution of output of pseudo random number generator. More... | |
class | AlgorithmPrimitivity |
Algorithm which check if given polynomial is primitive. More... | |
class | AlgorithmRecursionAndTempering |
class | AlgorithmRecursionSearch |
Search parameters of state transition function of pseudo random number generator so that the characteristic polynomial of the function will have max degree and will be primitive. More... | |
class | AlgorithmReducibleEquidistribution |
Calculate dimension of equi-distribution of reducible generator in worst case. More... | |
class | AlgorithmReducibleRecursionAndTempering |
class | AlgorithmReducibleRecursionSearch |
Search parameters of state transition function of pseudo random number generator so that the characteristic polynomial of the function will have max degree and will be primitive. More... | |
class | AlgorithmTempering |
Algorithm that search tempering parameters to improve dimension of equi-distribution of output of pseudo random number generator. More... | |
class | EquidistributionCalculatable |
This class is an Abstract class for calculating dimension of equi-distribution for GF(2)-linear pseudo random number generators. More... | |
class | linear_generator_vector |
GF(2) pseudo random number generator as a GF(2) vector. More... | |
class | MersenneTwister |
Mersenne Twister pseudo random number generator. More... | |
class | MersenneTwister64 |
Mersenne Twister pseudo random number generator. More... | |
class | RecursionSearchable |
class | ReducibleGenerator |
This class is an Abstract class for reducible generator. More... | |
class | ReducibleTemperingCalculatable |
class | Sequential |
Counting down number generator. More... | |
class | temper_params |
class which keeps tempering parameters More... | |
class | TemperingCalculatable |
Users can search tempering parameters by making GF(2)-linear pseudo random generator class which inherits from this class. More... | |
class | TestLinearity |
Checks if a pseudo random number generator is GF(2)-linear. More... | |
Functions | |
template<typename U , typename V = U> | |
void | calcCharacteristicPolynomial (RecursionSearchable< U, V > *rand, NTL::GF2X &poly) |
template<typename U , typename V = U> | |
void | calcCharacteristicPolynomial (ReducibleGenerator< U, V > *rand, NTL::GF2X &poly) |
Calculate the characteristic polynomial of reducible generator. More... | |
template<typename U > | |
void | minpoly (NTL::GF2X &poly, AbstractGenerator< U > &generator, int pos=0, int stateSize=0) |
Calculate minimal polynomial of output sequence. More... | |
bool | isMexp (uint32_t degree) |
Returns if 2degree-1 is prime number. More... | |
bool | isIrreducible (const NTL::GF2X &poly) |
Check if polynomial is irreducible. More... | |
bool | isPrime (const NTL::GF2X &poly) |
Check if polynomial is primitive. More... | |
bool | isPrime (const NTL::GF2X &poly, int degree, const NTL::Vec< NTL::ZZ > &prime_factors) |
Check if polynomial is primitive. More... | |
bool | isPrime (const NTL::GF2X &poly, int degree, const char *prime_factors[]) |
Check if polynomial is primitive. More... | |
bool | hasFactorOfDegree (NTL::GF2X &poly, long degree) |
Check if primitive polynomial of given degree appears in factorization of poly. More... | |
template<typename U , typename V = U> | |
void | annihilate (EquidistributionCalculatable< U, V > *rg, const NTL::GF2X &poly) |
Annihilate internal state of generator by given polynomial. More... | |
static int | count_bit (uint16_t x) |
Counts number of 1s. More... | |
static int | count_bit (uint32_t x) |
Counts number of 1s. More... | |
static int | count_bit (uint64_t x) |
Counts number of 1s. More... | |
static uint32_t | reverse_bit (uint32_t x) |
Reverse bits. More... | |
static uint64_t | reverse_bit (uint64_t x) |
Counts number of 1s. More... | |
template<typename T > | |
int | bit_size () |
Returns bit size of T. More... | |
static void | UNUSED_VARIABLE (void *x) |
Stop warning of unused variable. More... | |
template<typename T > | |
T | floor2p (T n) |
Return greatest power of two not greater than n. More... | |
static void | print_binary (std::ostream &os, NTL::GF2X &poly, bool breakline=true) |
Outputs coefficients of poly to os. More... | |
template<typename T > | |
int | get_range (T input, int start, int end) |
Changes input to number between start and end. More... | |
template<typename T > | |
void | fill_table (T dist_tbl[], T src_tbl[], int size) |
Makes a fast and redundant lookup table from a tabale of GF(2) vectors. More... | |
static int | calc_1pos (uint16_t x) |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero. More... | |
static int | calc_1pos (uint32_t x) |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero. More... | |
static int | calc_1pos (uint64_t x) |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero. More... | |
static void | LCM (NTL::GF2X &lcm, const NTL::GF2X &x, const NTL::GF2X &y) |
Calculate the Least Common Multiple of x and y. More... | |
template<typename U > | |
static void | toGF2Vec (NTL::vec_GF2 &result, U value) |
convert unsigned integer to GF(2) vector MSB of unsigned integer becomes first element of the vector. More... | |
template<typename U > | |
U | getOne () |
return one of specified type More... | |
template<typename U > | |
void | setZero (U &x) |
set zero More... | |
template<typename U > | |
unsigned int | getBitOfPos (U bits, int pos) |
set zero More... | |
template<typename U > | |
void | setBitOfPos (U *bits, int pos, unsigned int b) |
set zero or 1 to specified bit of specified type variable. More... | |
template<typename U > | |
static U | fromGF2Vec (NTL::vec_GF2 &value) |
convert GF(2) vector to unsigned integer the first element of vector becomes the MSB of the result integer. More... | |
template<typename U > | |
bool | isZero (U x) |
check if varible is zero or not More... | |
template<typename U , typename V > | |
U | convert (V x) |
convert to type U from type V More... | |
const char * | get_mttoolbox_version () |
returns library version More... | |
Variables | |
const AlgorithmPrimitivity | MersennePrimitivity |
An algorithm which checks if given polynomial is a primitive polynomial of given degree for pseudo random number generator whose internal state size is Mersenne exponent. More... | |
const char * | prime_factors2_128_1 [] |
List of prime numbers appear in the factorization of 2128-1. More... | |
const char * | prime_factors2_160_1 [] |
List of prime numbers appear in the factorization of 2160-1. More... | |
const char * | prime_factors2_192_1 [] |
List of prime numbers appear in the factorization of 2192-1. More... | |
const char * | prime_factors2_224_1 [] |
List of prime numbers appear in the factorization of 2224-1. More... | |
const char * | prime_factors2_256_1 [] |
List of prime numbers appear in the factorization of 2256-1. More... | |
const char * | prime_factors2_288_1 [] |
List of prime numbers appear in the factorization of 2288-1. More... | |
const char * | prime_factors2_320_1 [] |
List of prime numbers appear in the factorization of 2320-1. More... | |
const char * | prime_factors2_352_1 [] |
List of prime numbers appear in the factorization of 2352-1. More... | |
const char * | prime_factors2_384_1 [] |
List of prime numbers appear in the factorization of 2384-1. More... | |
const char * | prime_factors2_416_1 [] |
List of prime numbers appear in the factorization of 2416-1. More... | |
const char * | prime_factors2_448_1 [] |
List of prime numbers appear in the factorization of 2448-1. More... | |
const char * | prime_factors2_480_1 [] |
List of prime numbers appear in the factorization of 2480-1. More... | |
const char * | prime_factors2_512_1 [] |
List of prime numbers appear in the factorization of 2512-1. More... | |
const char * | prime_factors2_544_1 [] |
List of prime numbers appear in the factorization of 2544-1. More... | |
name space for MTToolBox
void MTToolBox::annihilate | ( | EquidistributionCalculatable< U, V > * | rg, |
const NTL::GF2X & | poly | ||
) |
Annihilate internal state of generator by given polynomial.
U | output type of the generator. |
V | output type of the generator used for parameter generating. |
[in,out] | rg | reducible generator |
[in] | poly | annihilator polynomial |
References MTToolBox::EquidistributionCalculatable< U, V >::add(), MTToolBox::EquidistributionCalculatable< U, V >::clone(), MTToolBox::EquidistributionCalculatable< U, V >::generate(), and MTToolBox::EquidistributionCalculatable< U, V >::setZero().
Referenced by MTToolBox::AlgorithmReducibleRecursionAndTempering< U, G >::search().
int MTToolBox::bit_size | ( | ) |
Returns bit size of T.
This is not correct because just multiply sizeof(T) by eight.
T | type |
|
inlinestatic |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero.
Algorithm to search position of 1 is from this page;
[in] | x | input |
References count_bit().
|
inlinestatic |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero.
Algorithm to search position of 1 is from this page;
[in] | x | input |
[in] | x | input |
References count_bit().
|
inlinestatic |
Returns the position of 1 which appears lowest (most right side) in x, where the position of MSB becomes zero.
Algorithm to search position of 1 is from this page;
[in] | x | input |
[in] | x | input |
References count_bit().
void MTToolBox::calcCharacteristicPolynomial | ( | RecursionSearchable< U, V > * | rand, |
NTL::GF2X & | poly | ||
) |
void MTToolBox::calcCharacteristicPolynomial | ( | ReducibleGenerator< U, V > * | rand, |
NTL::GF2X & | poly | ||
) |
Calculate the characteristic polynomial of reducible generator.
U | type of return value of random number generator. |
V | type of return value of parameter generator. |
[in,out] | rand | pseudo random number generator. |
[in,out] | poly | calculated characteristic polynomial. |
References MTToolBox::AbstractGenerator< U >::bitSize(), LCM(), and minpoly().
|
inline |
convert to type U from type V
U | type convert to |
V | type convert from |
[in] | x | variable |
|
inlinestatic |
Counts number of 1s.
SIMD within a Register algorithm citing from a website http://aggregate.org/MAGIC/
[in] | x | bit pattern |
Referenced by calc_1pos().
|
inlinestatic |
Counts number of 1s.
SIMD within a Register algorithm citing from a website http://aggregate.org/MAGIC/
[in] | x | bit pattern |
[in] | x | bit pattern |
|
inlinestatic |
Counts number of 1s.
SIMD within a Register algorithm citing from a website http://aggregate.org/MAGIC/
[in] | x | bit pattern |
[in] | x | bit pattern |
void MTToolBox::fill_table | ( | T | dist_tbl[], |
T | src_tbl[], | ||
int | size | ||
) |
Makes a fast and redundant lookup table from a tabale of GF(2) vectors.
T | type of elements in tables. |
[out] | dist_tbl | a lookup table to be made |
[in] | src_tbl | table of GF(2) vectors. |
[in] | size | size of dist_tbl |
T MTToolBox::floor2p | ( | T | n | ) |
Return greatest power of two not greater than n.
T | type of n |
[in] | n | integer |
|
inlinestatic |
convert GF(2) vector to unsigned integer the first element of vector becomes the MSB of the result integer.
[in] | value | source vector |
References setBitOfPos(), and setZero().
const char* MTToolBox::get_mttoolbox_version | ( | ) |
returns library version
int MTToolBox::get_range | ( | T | input, |
int | start, | ||
int | end | ||
) |
Changes input to number between start and end.
This conversion may not be uniformly distributed.
[in] | input | input |
[in] | start | start of range |
[in] | end | end of range |
|
inline |
set zero
U | type to get bit |
[in] | bits | variable to get bit |
[in] | pos | bit position |
Referenced by minpoly().
|
inline |
return one of specified type
U | type of one |
bool MTToolBox::hasFactorOfDegree | ( | NTL::GF2X & | poly, |
long | degree | ||
) |
Check if primitive polynomial of given degree appears in factorization of poly.
This function will be used by SFMT and dSFMT.
[in,out] | poly | polynomial over GF(2) |
[in] | degree | if poly has primitive polynomial with degree in its factors. |
Referenced by MTToolBox::AlgorithmReducibleRecursionSearch< U, V >::start().
bool MTToolBox::isIrreducible | ( | const NTL::GF2X & | poly | ) |
Check if polynomial is irreducible.
[in] | poly | polynomial whose coefficients are GF(2) |
bool MTToolBox::isMexp | ( | uint32_t | degree | ) |
Returns if 2degree-1 is prime number.
This is checked by fixed list of exponents of Mersenne Prime, therefore this check is not complete.
[in] | degree | number to be checked |
bool MTToolBox::isPrime | ( | const NTL::GF2X & | poly | ) |
Check if polynomial is primitive.
This check is lazy check. Only if degree of polynomial is Mersenne Exponent, the result is correct. This check should not be used, when bit size of internal state is not Mersenne Exponent.
[in] | poly | polynomial over GF(2) |
Referenced by MTToolBox::AlgorithmRecursionSearch< U, V >::AlgorithmRecursionSearch(), MTToolBox::AlgorithmRecursionAndTempering< U, V >::search(), and MTToolBox::AlgorithmRecursionSearch< U, V >::start().
bool MTToolBox::isPrime | ( | const NTL::GF2X & | poly, |
int | degree, | ||
const NTL::Vec< NTL::ZZ > & | prime_factors | ||
) |
Check if polynomial is primitive.
This function returns false if degree of polynomial is not degree. Users should give a list of primes which appear in integer factorization of 2degree-1.
[in] | poly | polynomial over GF(2) |
[in] | degree | poly expected to have degree. |
[in] | prime_factors | a list of primes which appear in integer factorization of 2degree-1. |
bool MTToolBox::isPrime | ( | const NTL::GF2X & | poly, |
int | degree, | ||
const char * | prime_factors[] | ||
) |
Check if polynomial is primitive.
This function returns false if degree of polynomial is not degree. Users should give a list of primes which app-er in integer factorization of 2degree-1.
[in] | poly | polynomial over GF(2) |
[in] | degree | poly expected to have degree. |
[in] | prime_factors | a list of primes which appear in integer factorization of 2degree-1. |
|
inline |
check if varible is zero or not
U | type of variable |
[in] | x | variable to be checked |
Referenced by MTToolBox::linear_generator_vector< U, V >::next_state(), and MTToolBox::AlgorithmCalculateParity< U, G >::searchParity().
|
inlinestatic |
Calculate the Least Common Multiple of x and y.
[out] | lcm | the Least Common Multiple of x and y. |
[in] | x | a polynomial |
[in] | y | a polynomial |
Referenced by calcCharacteristicPolynomial().
void MTToolBox::minpoly | ( | NTL::GF2X & | poly, |
AbstractGenerator< U > & | generator, | ||
int | pos = 0 , |
||
int | stateSize = 0 |
||
) |
Calculate minimal polynomial of output sequence.
U | type of output of pseudo random number generator |
[out] | poly | minimal polynomial |
[in] | generator | GF(2)-linear pseudo random number generator |
[in] | pos | specifies how manieth bit from LSB is checked, zero means LSB. |
[in] | stateSize | bit size of internal state. |
References MTToolBox::AbstractGenerator< U >::bitSize(), MTToolBox::AbstractGenerator< U >::generate(), and getBitOfPos().
Referenced by calcCharacteristicPolynomial(), MTToolBox::AlgorithmReducibleRecursionSearch< U, V >::start(), and MTToolBox::AlgorithmRecursionSearch< U, V >::start().
|
inlinestatic |
Outputs coefficients of poly to os.
Coefficients of low degree terms are outputted first.
[in,out] | os | output stream |
[in] | poly | polynomial to be outputted |
[in] | breakline | if true, line break after every 32 terms. |
|
inlinestatic |
Reverse bits.
Reverse upper side and lower side in input. The MSB bocomes the LSB. SIMD within a Register algorithm citing from a website http://aggregate.org/MAGIC/
[in] | x | bit pattern |
|
inlinestatic |
Counts number of 1s.
SIMD within a Register algorithm citing from a website http://aggregate.org/MAGIC/
[in] | x | bit pattern |
[in] | x | bit pattern |
[in] | x | bit pattern |
|
inline |
set zero or 1 to specified bit of specified type variable.
U | type of variable |
[in,out] | bits | variable |
[in] | pos | position of bit, LSB is 0 |
[in] | b | bit to set |
Referenced by fromGF2Vec().
|
inline |
set zero
U | type to set zero |
[out] | x | variable set to be zero |
Referenced by fromGF2Vec(), MTToolBox::linear_generator_vector< U, V >::linear_generator_vector(), and MTToolBox::AlgorithmCalculateParity< U, G >::searchParity().
|
inlinestatic |
convert unsigned integer to GF(2) vector MSB of unsigned integer becomes first element of the vector.
U | type of conversion source |
[out] | result | The result vector |
[in] | value | source integer |
|
inlinestatic |
Stop warning of unused variable.
[in] | x | pointer to unused variable |
const AlgorithmPrimitivity MTToolBox::MersennePrimitivity |
An algorithm which checks if given polynomial is a primitive polynomial of given degree for pseudo random number generator whose internal state size is Mersenne exponent.
Referenced by MTToolBox::AlgorithmRecursionSearch< U, V >::AlgorithmRecursionSearch().
const char* MTToolBox::prime_factors2_128_1[] |
List of prime numbers appear in the factorization of 2128-1.
const char* MTToolBox::prime_factors2_160_1[] |
List of prime numbers appear in the factorization of 2160-1.
const char* MTToolBox::prime_factors2_192_1[] |
List of prime numbers appear in the factorization of 2192-1.
const char* MTToolBox::prime_factors2_224_1[] |
List of prime numbers appear in the factorization of 2224-1.
const char* MTToolBox::prime_factors2_256_1[] |
List of prime numbers appear in the factorization of 2256-1.
const char* MTToolBox::prime_factors2_288_1[] |
List of prime numbers appear in the factorization of 2288-1.
const char* MTToolBox::prime_factors2_320_1[] |
List of prime numbers appear in the factorization of 2320-1.
const char* MTToolBox::prime_factors2_352_1[] |
List of prime numbers appear in the factorization of 2352-1.
const char* MTToolBox::prime_factors2_384_1[] |
List of prime numbers appear in the factorization of 2384-1.
const char* MTToolBox::prime_factors2_416_1[] |
List of prime numbers appear in the factorization of 2416-1.
const char* MTToolBox::prime_factors2_448_1[] |
List of prime numbers appear in the factorization of 2448-1.
const char* MTToolBox::prime_factors2_480_1[] |
List of prime numbers appear in the factorization of 2480-1.
const char* MTToolBox::prime_factors2_512_1[] |
List of prime numbers appear in the factorization of 2512-1.
const char* MTToolBox::prime_factors2_544_1[] |
List of prime numbers appear in the factorization of 2544-1.