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
130 Tensor normal(const cytnx_uint64 &Nelem, const double &mean, const double &std,
131 const int &device = Device.cpu,
132 const unsigned int &seed = std::random_device()());
133
145 Tensor normal(const std::vector<cytnx_uint64> &Nelem, const double &mean, const double &std,
146 const int &device = Device.cpu,
147 const unsigned int &seed = std::random_device()());
149
150 // uniform:
152
163 Tensor uniform(const cytnx_uint64 &Nelem, const double &low, const double &high,
164 const int &device = Device.cpu,
165 const unsigned int &seed = std::random_device()());
166
179 Tensor uniform(const std::vector<cytnx_uint64> &Nelem, const double &low, const double &high,
180 const int &device = Device.cpu,
181 const unsigned int &seed = std::random_device()());
183
184 } // namespace random
185} // namespace cytnx
186
187#endif
an memeory storage with multi-type/multi-device support
Definition Storage.hpp:1039
an tensor (multi-dimensional array)
Definition Tensor.hpp:345
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:2449
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 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
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.
Definition Device.cpp:140
uint64_t cytnx_uint64
Definition Type.hpp:45