Cytnx v1.0.0
Loading...
Searching...
No Matches
Functions | Variables
cytnx::random Namespace Reference

The randomization related functions. More...

Functions

void normal_ (cytnx::Storage &Sin, const double &mean, const double &std, const unsigned int &seed=__static_random_device())
 Randomize the memory of a Storage with normal distributon.
 
void uniform_ (cytnx::Storage &Sin, const double &low=0, const double &high=1, const unsigned int &seed=__static_random_device())
 Randomize the memory of a Storage with uniform distributon.
 
void normal_ (cytnx::Tensor &Tin, const double &mean, const double &std, const unsigned int &seed=__static_random_device())
 Randomize the memory of a Tensor with normal distributon.
 
void uniform_ (cytnx::Tensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=__static_random_device())
 Randomize the memory of a Tensor with uniform distributon.
 
void normal_ (cytnx::UniTensor &Tin, const double &mean, const double &std, const unsigned int &seed=__static_random_device())
 Randomize the memory of a UniTensor with normal distributon.
 
void uniform_ (cytnx::UniTensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=__static_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=__static_random_device(), const unsigned int &dtype=Type.Double)
 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=__static_random_device(), const unsigned int &dtype=Type.Double)
 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=__static_random_device(), const unsigned int &dtype=Type.Double)
 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=__static_random_device(), const unsigned int &dtype=Type.Double)
 create an Tensor with all the elements are initialized with uniform distribution
 

Variables

std::random_device __static_random_device
 

Detailed Description

The randomization related functions.

Function Documentation

◆ 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 = __static_random_device(),
const unsigned int &  dtype = Type.Double 
)

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

Parameters
[in]Nelemthe number of elements
[in]meanthe mean of the normal distribution
[in]stdthe standard deviation \( \sigma \) of a normal distribution.
[in]devicethe device that the Tensor is put on. It can be any device defined in
[in]seedthe seed for the random generator. [Default] using device entropy
[in]dtypethe data type of the Tensor. [Default] cytnx::Type.Double 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 = __static_random_device(),
const unsigned int &  dtype = Type.Double 
)

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

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

◆ normal_() [1/3]

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

Randomize the memory of a Storage with normal distributon.

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

◆ normal_() [2/3]

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

Randomize the memory of a Tensor with normal distributon.

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

◆ normal_() [3/3]

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

Randomize the memory of a UniTensor with normal distributon.

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

◆ 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 = __static_random_device(),
const unsigned int &  dtype = Type.Double 
)

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

Parameters
[in]Nelemthe number of elements
[in]lowthe lower-bound of range
[in]highthe upper-bound of range
[in]devicethe device that the Tensor is put on. It can be any device defined in cytnx::Device
[in]seedthe seed for the random generator. [Default] using device entropy
[in]dtypethe data type of the Tensor. [Default] cytnx::Type.Double
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 = __static_random_device(),
const unsigned int &  dtype = Type.Double 
)

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

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

◆ uniform_() [1/3]

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

Randomize the memory of a Storage with uniform distributon.

Parameters
[in]Sina Storage
[in]lowthe lower-bound of the uniform distribution
[in]highthe higher-bound of the uniform distribution
[in]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)

◆ uniform_() [2/3]

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

Randomize the memory of a Tensor with uniform distributon.

Parameters
[in]Tina Tensor
[in]lowthe lower-bound of the uniform distribution
[in]highthe higher-bound of the uniform distribution
[in]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)

◆ uniform_() [3/3]

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

Randomize the memory of a UniTensor with uniform distributon.

Parameters
[in]Tina UniTensor
[in]lowthe lower-bound of the uniform distribution
[in]highthe higher-bound of the uniform distribution
[in]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)

Variable Documentation

◆ __static_random_device

std::random_device cytnx::random::__static_random_device
extern