Cytnx v1.0.0
Loading...
Searching...
No Matches
Generator.hpp
Go to the documentation of this file.
1#ifndef CYTNX_GENERATOR_H_
2#define CYTNX_GENERATOR_H_
3
4#include "Type.hpp"
5#include "Device.hpp"
6#include "cytnx_error.hpp"
7#include "Tensor.hpp"
8#include <vector>
9#include <initializer_list>
10
11#ifdef BACKEND_TORCH
12#else
13namespace cytnx {
14
16
28 Tensor zeros(const cytnx_uint64 &Nelem, const unsigned int &dtype = Type.Double,
29 const int &device = Device.cpu);
42 Tensor zeros(const std::vector<cytnx_uint64> &Nelem, const unsigned int &dtype = Type.Double,
43 const int &device = Device.cpu);
45
58 Tensor identity(const cytnx_uint64 &Dim, const unsigned int &dtype = Type.Double,
59 const int &device = Device.cpu);
60
76 Tensor eye(const cytnx_uint64 &Dim, const unsigned int &dtype = Type.Double,
77 const int &device = Device.cpu);
78
80
92 Tensor ones(const cytnx_uint64 &Nelem, const unsigned int &dtype = Type.Double,
93 const int &device = Device.cpu);
106 Tensor ones(const std::vector<cytnx_uint64> &Nelem, const unsigned int &dtype = Type.Double,
107 const int &device = Device.cpu);
109
111
119 Tensor arange(const cytnx_int64 &Nelem);
134 Tensor arange(const cytnx_double &start, const cytnx_double &end, const cytnx_double &step = 1,
135 const unsigned int &dtype = Type.Double, const int &device = Device.cpu);
137
138 Tensor linspace(const cytnx_double &start, const cytnx_double &end, const cytnx_uint64 &Nelem,
139 const bool &endpoint = true, const unsigned int &dtype = Type.Double,
140 const int &device = Device.cpu);
141
142 // Tensor rand(const std::vector<cytnx_uint64> &size);
143 // Tensor randn(const std::vector<cytnx_uint64> &size);
144 // Tensor normal(const cytnx_double &mean, cytnx_double &std);
145
146} // namespace cytnx
147
148#endif // BACKEND_TORCH
149
150#endif // CYTNX_GENERATOR_H_
constexpr Type_class Type
data type
Definition Type.hpp:426
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
Definition Accessor.hpp:12
Device_class Device
data on which devices.
Tensor linspace(const cytnx_double &start, const cytnx_double &end, const cytnx_uint64 &Nelem, const bool &endpoint=true, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
Tensor arange(const cytnx_int64 &Nelem)
create an rank-1 Tensor with incremental unsigned integer elements start with [0,Nelem)
Tensor ones(const cytnx_uint64 &Nelem, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
create an rank-1 Tensor with all the elements are initialized with one.
Tensor zeros(const cytnx_uint64 &Nelem, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
create an rank-1 Tensor with all the elements are initialized with zero.
Tensor identity(const cytnx_uint64 &Dim, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
create an square rank-2 Tensor with all diagonal to be one.
Tensor eye(const cytnx_uint64 &Dim, const unsigned int &dtype=Type.Double, const int &device=Device.cpu)
create a square rank-2 Tensor with all diagonal to be one.