Cytnx v0.9.1
Loading...
Searching...
No Matches
random.hpp
Go to the documentation of this file.
1#ifndef _random_H_
2#define _random_H_
3#include "Type.hpp"
4#include "Device.hpp"
5#include "cytnx_error.hpp"
6#include "Tensor.hpp"
7#include "Storage.hpp"
8#include "UniTensor.hpp"
9#include <vector>
10#include <initializer_list>
11#include <random>
12
13namespace cytnx {
18 namespace random {
19
20 // [Storage]
21 // =============================================================================================================
22 // =============================================================================================================
23 // Make_normal:
24 //--------------------------------------------------
33 void Make_normal(Storage &Sin, const double &mean, const double &std,
34 const unsigned int &seed = std::random_device()());
35
36 // Make_uniform:
37 //--------------------------------------------------
49 void Make_uniform(Storage &Sin, const double &low = 0, const double &high = 1,
50 const unsigned int &seed = std::random_device()());
51
52 // [Tensor]
53 // =============================================================================================================
54 // =============================================================================================================
55 // Make_normal:
56 //-------------------------------------------------
65 void Make_normal(Tensor &Tin, const double &mean, const double &std,
66 const unsigned int &seed = std::random_device()());
67
68 // Make_uniform:
69 //--------------------------------------------------
82 void Make_uniform(Tensor &Tin, const double &low = 0, const double &high = 1,
83 const unsigned int &seed = std::random_device()());
84
85 // [UniTensor]
86 // =============================================================================================================
87 // =============================================================================================================
88 // Make_normal:
89 //-------------------------------------------------
98 void Make_normal(UniTensor &Tin, const double &mean, const double &std,
99 const unsigned int &seed = std::random_device()());
100
101 // Make_uniform:
102 //--------------------------------------------------
114 void Make_uniform(UniTensor &Tin, const double &low = 0, const double &high = 1,
115 const unsigned int &seed = std::random_device()());
116
117 // normal:
119
132 Tensor normal(const cytnx_uint64 &Nelem, const double &mean, const double &std,
133 const int &device = Device.cpu, const unsigned int &seed = std::random_device()(),
134 const unsigned int &dtype = Type.Double);
135
148 Tensor normal(const std::vector<cytnx_uint64> &Nelem, const double &mean, const double &std,
149 const int &device = Device.cpu, const unsigned int &seed = std::random_device()(),
150 const unsigned int &dtype = Type.Double);
152
153 // uniform:
155
167 Tensor uniform(const cytnx_uint64 &Nelem, const double &low, const double &high,
168 const int &device = Device.cpu,
169 const unsigned int &seed = std::random_device()(),
170 const unsigned int &dtype = Type.Double);
171
185 Tensor uniform(const std::vector<cytnx_uint64> &Nelem, const double &low, const double &high,
186 const int &device = Device.cpu,
187 const unsigned int &seed = std::random_device()(),
188 const unsigned int &dtype = Type.Double);
190
191 } // namespace random
192} // namespace cytnx
193
194#endif
an memeory storage with multi-type/multi-device support
Definition Storage.hpp:1051
an tensor (multi-dimensional array)
Definition Tensor.hpp:345
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1705
Tensor normal(const cytnx_uint64 &Nelem, const double &mean, const double &std, const int &device=Device.cpu, const unsigned int &seed=std::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=std::random_device()(), const unsigned int &dtype=Type.Double)
create an Tensor with all the elements are initialized with uniform distribution
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(Storage &Sin, const double &mean, const double &std, const unsigned int &seed=std::random_device()())
Randomize the memory of a Storage with normal distributon.
Definition Accessor.hpp:12
Device_class Device
data on which devices.
uint64_t cytnx_uint64
Definition Type.hpp:45
Type_class Type
data type