INGOR
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ytRNG Struct Reference

Structure for encapsulating the random number generator. More...

#include <ytRNG.h>

Public Member Functions

ytRNGytRNG_new ()
 Generates an ytRNG instance.
 
void ytRNG_delete (ytRNG *rng)
 Releases the resources allocated for the ytRNG instance.
 
void ytRNG_setSeed (ytRNG *rng, int seed)
 Initializes the random number generator.
 
void ytRNG_normal (ytRNG *rng, double *ar, int n, double mean, double sigma)
 Generates the normally distributed random numbers.
 
void ytRNG_uniform (ytRNG *rng, double *ar, int n, double min, double max)
 Generates the normally distributed random numbers.
 
void ytRNG_integer (ytRNG *rng, int *ar, int n, int min, int max)
 Generates integer random numbers.
 
void ytRNG_perm (ytRNG *rng, int *ar, int n)
 Generates an integer random permuation vector.
 
void ytRNG_shuffle (ytRNG *rng, int *ar, int n)
 Shuffles the elements of the integer array.
 

Public Attributes

ytRNG_dSFMTdsfmt
 
double work [DSFMT_N64]
 

Detailed Description

Structure for encapsulating the random number generator.

Depending on the environment, this uses the appropriate implementation / library to generate random numbers. The following is the list of supported environment (C macro) and its math library.


ytLib Programming API Document

Member Function Documentation

◆ ytRNG_delete()

void ytRNG_delete ( ytRNG rng)

Releases the resources allocated for the ytRNG instance.

Parameters
rngytRNG instance to be deleted.
Go to Top

◆ ytRNG_integer()

void ytRNG_integer ( ytRNG rng,
int *  ar,
int  n,
int  min,
int  max 
)

Generates integer random numbers.

This generates integer random numbers ranging [min,max).

Parameters
rngIntitialized ytRNG instance.
arArray in which the generated random numbers are stored.
nNumbers of random number to generate.
minLower bound of the random values (inclusive).
maxUpper bound of the random values (exclusive).

◆ ytRNG_new()

ytRNG * ytRNG_new ( )

Generates an ytRNG instance.

Call ytRNG_set_seed() to initialize the random number generator.

Call ytRNG_delete() to release the resources allocated by this routine.

Returns
Newly generated ytRNG instance.
Go to Top

◆ ytRNG_normal()

void ytRNG_normal ( ytRNG rng,
double *  ar,
int  n,
double  mean,
double  sigma 
)

Generates the normally distributed random numbers.

The appropriate algorithm is selected based on the environment.

  • Fujitsu C Compiler + SSL II Math Libarary : c_dvran3().
  • Others: Original routine based on random() in the standard C library.
Parameters
rngInitialized ytRNG instance.
arArray in which the generated random numbers are stored.
nNumber of random numbers to generate.
meanMean of the normal distribution.
sigmaStandard deviation of the normal distribution.
Go to Top

◆ ytRNG_perm()

void ytRNG_perm ( ytRNG rng,
int *  ar,
int  n 
)

Generates an integer random permuation vector.

This generates an random permutation ranging from 0 to n − 1.

Parameters
[in]rngInitialized ytRNG instance.
[out]arArray in which the generated random permuation vector is stored.
[int]n Length of the permutation vector.

◆ ytRNG_setSeed()

void ytRNG_setSeed ( ytRNG rng,
int  seed 
)

Initializes the random number generator.

The appropriate algorithm is selected based on the environment.

  • Fujitsu C Compiler + SSL II Math Libarary : c_dvrau4() and c_dvran3().
  • Others: random() in the standard C library.

In Fujitsu SSL II library, 0 cannot be specified as the seed. Thus, if 0 is specified, it is regarded as 1.

Parameters
rngytRNG instance to be initialized.
seedSeed of the random number generator.
Go to Top

◆ ytRNG_shuffle()

void ytRNG_shuffle ( ytRNG rng,
int *  ar,
int  n 
)

Shuffles the elements of the integer array.

This shuffles the order of elements in the given integer array.

Parameters
[in]rngInitialized ytRNG instance.
[in,out]arArray in which the order of the elements are shuffled.
[in]nLength of the array.

◆ ytRNG_uniform()

void ytRNG_uniform ( ytRNG rng,
double *  ar,
int  n,
double  min,
double  max 
)

Generates the normally distributed random numbers.

The appropriate algorithm is selected based on the environment.

  • Fujitsu C Compiler + SSL II Math Libarary : c_dvran3().
  • Intel MKL : vdRngUniform().
  • Others: dSFMT.
Parameters
rngInitialized ytRNG instance.
arArray in which the generated random numbers are stored.
nNumber of random numbers to generate.
minLower bound of the uniform distribution.
maxUpper bound of the uniform distribution.
Go to Top

The documentation for this struct was generated from the following files: