Cytnx v0.7.4
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
13
14namespace cytnx{
15 namespace random{
16
17 // [Storage]
18 // =============================================================================================================
19 // =============================================================================================================
20 // Make_normal:
21 //--------------------------------------------------
32 void Make_normal(Storage &Sin, const double &mean, const double &std, const unsigned int &seed=std::random_device()());
33
34 // Make_uniform:
35 //--------------------------------------------------
49 void Make_uniform(Storage &Sin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()());
50
51
52 // [Tensor]
53 // =============================================================================================================
54 // =============================================================================================================
55 // Make_normal:
56 //-------------------------------------------------
67 void Make_normal(Tensor &Tin, const double &mean, const double &std, const unsigned int &seed=std::random_device()());
68
69 // Make_uniform:
70 //--------------------------------------------------
84 void Make_uniform(Tensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()());
85
86
87
88 // [UniTensor]
89 // =============================================================================================================
90 // =============================================================================================================
91 // Make_normal:
92 //-------------------------------------------------
103 void Make_normal(UniTensor &Tin, const double &mean, const double &std, const unsigned int &seed=std::random_device()());
104
105 // Make_uniform:
106 //--------------------------------------------------
120 void Make_uniform(UniTensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()());
121
122
123
124
125
126 // normal:
128
140 Tensor normal(const cytnx_uint64 &Nelem, const double &mean, const double &std, const int &device=Device.cpu, const unsigned int &seed=std::random_device()());
141
154 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()());
156
157 // uniform:
159
171 Tensor uniform(const cytnx_uint64 &Nelem, const double &low, const double &high, const int &device=Device.cpu, const unsigned int &seed=std::random_device()());
172
185 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()());
187
188
189
190 }
191}
192
193#endif
an memeory storage with multi-type/multi-device support
Definition Storage.hpp:934
an tensor (multi-dimensional array)
Definition Tensor.hpp:333
An Enhanced tensor specifically designed for physical Tensor network simulation.
Definition UniTensor.hpp:1123
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
Definition Device.cpp:105
uint64_t cytnx_uint64
Definition Type.hpp:22