Cytnx v0.7.3
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 <vector>
9#include <initializer_list>
10#include <random>
11
12
13namespace cytnx{
14 namespace random{
15 // [Storage]
16 // =============================================================================================================
17 // =============================================================================================================
18 // Make_normal:
19 //--------------------------------------------------
30 void Make_normal(Storage &Sin, const double &mean, const double &std, const unsigned int &seed=std::random_device()());
31
32 // Make_uniform:
33 //--------------------------------------------------
47 void Make_uniform(Storage &Sin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()());
48
49
50 // [Tensor]
51 // =============================================================================================================
52 // =============================================================================================================
53 // Make_normal:
54 //-------------------------------------------------
65 void Make_normal(Tensor &Tin, const double &mean, const double &std, const unsigned int &seed=std::random_device()());
66
67 // Make_uniform:
68 //--------------------------------------------------
82 void Make_uniform(Tensor &Tin, const double &low=0, const double &high=1, const unsigned int &seed=std::random_device()());
83
84
85
86 // normal:
88
100 Tensor normal(const cytnx_uint64 &Nelem, const double &mean, const double &std, const int &device=Device.cpu, const unsigned int &seed=std::random_device()());
101
114 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()());
116
117 // uniform:
119
131 Tensor uniform(const cytnx_uint64 &Nelem, const double &low, const double &high, const int &device=Device.cpu, const unsigned int &seed=std::random_device()());
132
145 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()());
147
148
149
150 }
151}
152
153#endif
an memeory storage with multi-type/multi-device support
Definition Storage.hpp:918
an tensor (multi-dimensional array)
Definition Tensor.hpp:289
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