Cytnx v0.9.3
Loading...
Searching...
No Matches
Generator.hpp
Go to the documentation of this file.
1#ifndef _Generator_H_
2#define _Generator_H_
3#include "Type.hpp"
4#include "Device.hpp"
5#include "cytnx_error.hpp"
6#include "Tensor.hpp"
7#include <vector>
8#include <initializer_list>
9
10#ifdef BACKEND_TORCH
11#else
12namespace cytnx {
13
15
27 Tensor zeros(const cytnx_uint64 &Nelem, const unsigned int &dtype = Type.Double,
28 const int &device = Device.cpu);
41 Tensor zeros(const std::vector<cytnx_uint64> &Nelem, const unsigned int &dtype = Type.Double,
42 const int &device = Device.cpu);
44
57 Tensor identity(const cytnx_uint64 &Dim, const unsigned int &dtype = Type.Double,
58 const int &device = Device.cpu);
59
75 Tensor eye(const cytnx_uint64 &Dim, const unsigned int &dtype = Type.Double,
76 const int &device = Device.cpu);
77
79
91 Tensor ones(const cytnx_uint64 &Nelem, const unsigned int &dtype = Type.Double,
92 const int &device = Device.cpu);
105 Tensor ones(const std::vector<cytnx_uint64> &Nelem, const unsigned int &dtype = Type.Double,
106 const int &device = Device.cpu);
108
110
118 Tensor arange(const cytnx_int64 &Nelem);
133 Tensor arange(const cytnx_double &start, const cytnx_double &end, const cytnx_double &step = 1,
134 const unsigned int &dtype = Type.Double, const int &device = Device.cpu);
136
137 Tensor linspace(const cytnx_double &start, const cytnx_double &end, const cytnx_uint64 &Nelem,
138 const bool &endpoint = true, const unsigned int &dtype = Type.Double,
139 const int &device = Device.cpu);
140
141 // Tensor rand(const std::vector<cytnx_uint64> &size);
142 // Tensor randn(const std::vector<cytnx_uint64> &size);
143 // Tensor normal(const cytnx_double &mean, cytnx_double &std);
144
145} // namespace cytnx
146
147#endif // BACKEND_TORCH
148
149#endif
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
Helper function to print vector with ODT:
Definition Accessor.hpp:12
Device_class Device
data on which devices.
double cytnx_double
Definition Type.hpp:53
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.
uint64_t cytnx_uint64
Definition Type.hpp:55
int64_t cytnx_int64
Definition Type.hpp:58
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.
Type_class Type
data type
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 an square rank-2 Tensor with all diagonal to be one.