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 std::vector<cytnx_uint64> &shape, unsigned int dtype = Type.Double,
29 int device = Device.cpu);
30 Tensor zeros(std::initializer_list<cytnx_uint64> shape, unsigned int dtype = Type.Double,
31 int device = Device.cpu);
33
47 Tensor identity(cytnx_uint64 Dim, unsigned int dtype = Type.Double, int device = Device.cpu);
48
65 Tensor eye(cytnx_uint64 Dim, unsigned int dtype = Type.Double, int device = Device.cpu);
66
68
80 Tensor ones(const std::vector<cytnx_uint64> &shape, unsigned int dtype = Type.Double,
81 int device = Device.cpu);
82 Tensor ones(std::initializer_list<cytnx_uint64> shape, unsigned int dtype = Type.Double,
83 int device = Device.cpu);
85
87
94 Tensor arange(cytnx_int64 Nelem);
108 Tensor arange(cytnx_double start, cytnx_double end, cytnx_double step = 1,
109 unsigned int dtype = Type.Double, int device = Device.cpu);
111
112 Tensor linspace(cytnx_double start, cytnx_double end, cytnx_uint64 Nelem, bool endpoint = true,
113 unsigned int dtype = Type.Double, int device = Device.cpu);
114
115 // Tensor rand(const std::vector<cytnx_uint64> &size);
116 // Tensor randn(const std::vector<cytnx_uint64> &size);
117 // Tensor normal(const cytnx_double &mean, cytnx_double &std);
118
119} // namespace cytnx
120
121#endif // BACKEND_TORCH
122
123#endif // CYTNX_GENERATOR_H_
constexpr Type_class Type
data type
Definition Type.hpp:555
an tensor (multi-dimensional array)
Definition Tensor.hpp:41
Definition Accessor.hpp:12
Device_class Device
data on which devices.
Tensor eye(cytnx_uint64 Dim, unsigned int dtype=Type.Double, int device=Device.cpu)
Create a square rank-2 Tensor with the diagonal initialized to one and all other elements set to zero...
Tensor zeros(const std::vector< cytnx_uint64 > &shape, unsigned int dtype=Type.Double, int device=Device.cpu)
Create a Tensor with all elements initialized to zero.
Tensor linspace(cytnx_double start, cytnx_double end, cytnx_uint64 Nelem, bool endpoint=true, unsigned int dtype=Type.Double, int device=Device.cpu)
Tensor ones(const std::vector< cytnx_uint64 > &shape, unsigned int dtype=Type.Double, int device=Device.cpu)
Create a Tensor with all elements initialized to one.
Tensor arange(cytnx_int64 Nelem)
Create a rank-1 Tensor with incremental unsigned integer elements in the range [0,...
Tensor identity(cytnx_uint64 Dim, unsigned int dtype=Type.Double, int device=Device.cpu)
Create a square rank-2 Tensor with the diagonal initialized to one and all other elements set to zero...