Cytnx v0.7.4
Loading...
Searching...
No Matches
Functions
cytnx::random Namespace Reference

Functions

void Make_normal (Storage &Sin, const double &mean, const double &std, const unsigned int &seed=std::random_device()())
 Randomize the memory of a Storage with normal distributon.
 
void Make_uniform (Storage &Sin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()())
 Randomize the memory of a Storage with uniform distributon.
 
void Make_normal (Tensor &Tin, const double &mean, const double &std, const unsigned int &seed=std::random_device()())
 Randomize the memory of a Tensor with normal distributon.
 
void Make_uniform (Tensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()())
 Randomize the memory of a Tensor with uniform distributon.
 
void Make_normal (UniTensor &Tin, const double &mean, const double &std, const unsigned int &seed=std::random_device()())
 Randomize the memory of a UniTensor with normal distributon.
 
void Make_uniform (UniTensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()())
 Randomize the memory of a UniTensor with uniform distributon.
 
Tensor normal (const cytnx_uint64 &Nelem, const double &mean, const double &std, const int &device=Device.cpu, const unsigned int &seed=std::random_device()())
 create an Tensor with all the elements are initialized with normal distribution
 
Tensor normal (const std::vector< cytnx_uint64 > &Nelem, const double &mean, const double &std, const int &device=Device.cpu, const unsigned int &seed=std::random_device()())
 create an Tensor with all the elements are initialized with normal distribution
 
Tensor uniform (const cytnx_uint64 &Nelem, const double &low, const double &high, const int &device=Device.cpu, const unsigned int &seed=std::random_device()())
 create an Tensor with all the elements are initialized with uniform distribution
 
Tensor uniform (const std::vector< cytnx_uint64 > &Nelem, const double &low, const double &high, const int &device=Device.cpu, const unsigned int &seed=std::random_device()())
 create an Tensor with all the elements are initialized with uniform distribution
 

Function Documentation

◆ Make_normal() [1/3]

void cytnx::random::Make_normal ( Storage Sin,
const double &  mean,
const double &  std,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a Storage with normal distributon.

Parameters
Sina Storage
meanthe mean of a normal distribution
stdthe standard deviation (sigma) of a normal distribution.
seedthe seed for the random generator. [Default] Using device entropy.
[Note] The Storage sould be real floating type or complex type.  

◆ Make_normal() [2/3]

void cytnx::random::Make_normal ( Tensor Tin,
const double &  mean,
const double &  std,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a Tensor with normal distributon.

Parameters
Tina Tensor
meanthe mean of a normal distribution
stdthe standard deviation (sigma) of a normal distribution.
seedthe seed for the random generator. [Default] Using device entropy.
[Note] The Tensor sould be real floating type or complex type.  

◆ Make_normal() [3/3]

void cytnx::random::Make_normal ( UniTensor Tin,
const double &  mean,
const double &  std,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a UniTensor with normal distributon.

Parameters
Tina UniTensor
meanthe mean of a normal distribution
stdthe standard deviation (sigma) of a normal distribution.
seedthe seed for the random generator. [Default] Using device entropy.
[Note] The UniTensor sould be real floating type or complex type.  

◆ Make_uniform() [1/3]

void cytnx::random::Make_uniform ( Storage Sin,
const double &  low = 0,
const double &  high = 1,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a Storage with uniform distributon.

Parameters
Sina Storage
lowthe lower-bound of the uniform distribution
highthe higher-bound of the uniform distribution
seedthe seed for the random generator. [Default] Using device entropy.
[Note] 

    1. The Storage sould be real floating type or complex type.  
    2. In cpu, it generate random number in domain [low,high); but in gpu(cuda), it generate random number in domain (low,high]; (cuRandv10)

◆ Make_uniform() [2/3]

void cytnx::random::Make_uniform ( Tensor Tin,
const double &  low = 0,
const double &  high = 1,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a Tensor with uniform distributon.

Parameters
Tina Tensor
lowthe lower-bound of the uniform distribution
highthe higher-bound of the uniform distribution
seedthe seed for the random generator. [Default] Using device entropy.
[Note] 

    1. The Tensor sould be real floating type or complex type.  
    2. In cpu, it generate random number in domain [low,high); but in gpu(cuda), it generate random number in domain (low,high]; (cuRandv10)

◆ Make_uniform() [3/3]

void cytnx::random::Make_uniform ( UniTensor Tin,
const double &  low = 0,
const double &  high = 1,
const unsigned int &  seed = std::random_device()() 
)

Randomize the memory of a UniTensor with uniform distributon.

Parameters
Tina UniTensor
lowthe lower-bound of the uniform distribution
highthe higher-bound of the uniform distribution
seedthe seed for the random generator. [Default] Using device entropy.
[Note] 

    1. The UniTensor sould be real floating type or complex type.  
    2. In cpu, it generate random number in domain [low,high); but in gpu(cuda), it generate random number in domain (low,high]; (cuRandv10)

◆ normal() [1/2]

Tensor cytnx::random::normal ( const cytnx_uint64 Nelem,
const double &  mean,
const double &  std,
const int &  device = Device.cpu,
const unsigned int &  seed = std::random_device()() 
)

create an Tensor with all the elements are initialized with normal distribution

Parameters
Nelemthe number of elements
meanthe mean of the normal distribution
stdthe standard deviation (sigma) of the normal distribution
devicethe device that the Tensor is put on. It can be any device defined in cytnx::Device
seedthe seed for the random generator. [Default] using device entropy
Returns
[Tensor]

◆ normal() [2/2]

Tensor cytnx::random::normal ( const std::vector< cytnx_uint64 > &  Nelem,
const double &  mean,
const double &  std,
const int &  device = Device.cpu,
const unsigned int &  seed = std::random_device()() 
)

create an Tensor with all the elements are initialized with normal distribution

Parameters
Nelemthe shape of the Tensor
meanthe mean of the normal distribution
stdthe standard deviation (sigma) of the normal distribution
devicethe device that the Tensor is put on. It can be any device defined in cytnx::Device
seedthe seed for the random generator. [Default] using device entropy
Returns
[Tensor]

◆ uniform() [1/2]

Tensor cytnx::random::uniform ( const cytnx_uint64 Nelem,
const double &  low,
const double &  high,
const int &  device = Device.cpu,
const unsigned int &  seed = std::random_device()() 
)

create an Tensor with all the elements are initialized with uniform distribution

Parameters
Nelemthe number of elements
lowthe lower-bound of range
highthe upper-bound of range
devicethe device that the Tensor is put on. It can be any device defined in cytnx::Device
seedthe seed for the random generator. [Default] using device entropy
Returns
[Tensor]

◆ uniform() [2/2]

Tensor cytnx::random::uniform ( const std::vector< cytnx_uint64 > &  Nelem,
const double &  low,
const double &  high,
const int &  device = Device.cpu,
const unsigned int &  seed = std::random_device()() 
)

create an Tensor with all the elements are initialized with uniform distribution

Parameters
Nelemthe number of elements
lowthe lower-bound of range
highthe upper-bound of range
devicethe device that the Tensor is put on. It can be any device defined in cytnx::Device
seedthe seed for the random generator. [Default] using device entropy
Returns
[Tensor]