PSCF v1.5.0
Pscf::VecRandom< CUT > Class Reference

Random number generator on GPU. More...

#include <VecRandom.h>

Public Member Functions

 VecRandom ()
 Constructor.
virtual ~VecRandom ()
 Destructor.
void setSeed (unsigned long long seed)
 Set value of random seed (private member variable seed_).
void uniform (BackendArray< float, CUT > &data)
 Populate array with uniform random floats in (0, 1].
void uniform (BackendArray< double, CUT > &data)
 Populate array with uniform random doubles in (0, 1].
void uniform (BackendArray< float, CUT > &data, float min, float max)
 Populate array with uniform random floats in (min, max].
void uniform (BackendArray< double, CUT > &data, double min, double max)
 Populate array with uniform random doubles in (min, max].
void normal (BackendArray< float, CUT > &data, float stddev, float mean=0.0)
 Populate array on device with normal-distributed random floats.
void normal (BackendArray< double, CUT > &data, double stddev, double mean=0.0)
 Populate array on device with normal-distributed random doubles.
long seed ()
 Returns value of random seed (private member variable seed_).

Detailed Description

Random number generator on GPU.

The generator may be seeded either by reading a long in seed from a file, using the readParam() method, or by using setSeed() method to set the seed. In either case, inputing a positive integer causes that value to be used as a seed, but inputting a value of 0 causes the use of a seed that is generated from the system clock.

Definition at line 47 of file cuda/VecRandom.h.

Constructor & Destructor Documentation

◆ VecRandom()

Pscf::VecRandom< CUT >::VecRandom ( )

Constructor.

Definition at line 79 of file VecRandom.cu.

References VecRandom().

Referenced by normal(), normal(), seed(), setSeed(), uniform(), uniform(), uniform(), uniform(), VecRandom(), and ~VecRandom().

◆ ~VecRandom()

Pscf::VecRandom< CUT >::~VecRandom ( )
virtual

Destructor.

Definition at line 93 of file VecRandom.cu.

References VecRandom().

Member Function Documentation

◆ setSeed()

void Pscf::VecRandom< CUT >::setSeed ( unsigned long long seed)

Set value of random seed (private member variable seed_).

Parameters
seedvalue of random number generator seed.

Definition at line 101 of file VecRandom.cu.

References seed(), and VecRandom().

Referenced by normal(), normal(), uniform(), and uniform().

◆ uniform() [1/4]

void Pscf::VecRandom< CUT >::uniform ( BackendArray< float, CUT > & data)

Populate array with uniform random floats in (0, 1].

Parameters
dataarray to populate

Definition at line 120 of file VecRandom.cu.

References setSeed(), UTIL_CHECK, and VecRandom().

Referenced by uniform(), and uniform().

◆ uniform() [2/4]

void Pscf::VecRandom< CUT >::uniform ( BackendArray< double, CUT > & data)

Populate array with uniform random doubles in (0, 1].

Parameters
dataarray to populate

Definition at line 136 of file VecRandom.cu.

References setSeed(), UTIL_CHECK, and VecRandom().

◆ uniform() [3/4]

void Pscf::VecRandom< CUT >::uniform ( BackendArray< float, CUT > & data,
float min,
float max )

Populate array with uniform random floats in (min, max].

Parameters
dataarray to populate
minminimum of range
maxmaximum of range

Definition at line 152 of file VecRandom.cu.

References uniform(), UTIL_CHECK, and VecRandom().

◆ uniform() [4/4]

void Pscf::VecRandom< CUT >::uniform ( BackendArray< double, CUT > & data,
double min,
double max )

Populate array with uniform random doubles in (min, max].

Parameters
dataarray to populate
minminimum of range
maxmaximum of range

Definition at line 163 of file VecRandom.cu.

References uniform(), UTIL_CHECK, and VecRandom().

◆ normal() [1/2]

void Pscf::VecRandom< CUT >::normal ( BackendArray< float, CUT > & data,
float stddev,
float mean = 0.0 )

Populate array on device with normal-distributed random floats.

Parameters
dataarray to populate
stddevstandard deviation (input)
meanmean value (input, default = 0.0)

Definition at line 174 of file VecRandom.cu.

References setSeed(), UTIL_CHECK, and VecRandom().

◆ normal() [2/2]

void Pscf::VecRandom< CUT >::normal ( BackendArray< double, CUT > & data,
double stddev,
double mean = 0.0 )

Populate array on device with normal-distributed random doubles.

Parameters
dataarray to populate
stddevstandard deviation (input)
meanmean value (input, default = 0.0)

Definition at line 212 of file VecRandom.cu.

References setSeed(), UTIL_CHECK, and VecRandom().

◆ seed()

long Pscf::VecRandom< CUT >::seed ( )
inline

Returns value of random seed (private member variable seed_).

Returns
value of random number generator seed.

Definition at line 154 of file cuda/VecRandom.h.

References VecRandom().

Referenced by setSeed().


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