9#include <initializer_list>
31 Scalar_base(): _dtype(
Type.Void){};
33 virtual cytnx_float to_cytnx_float()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
34 virtual cytnx_double to_cytnx_double()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
37 virtual cytnx_int64 to_cytnx_int64()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
38 virtual cytnx_uint64 to_cytnx_uint64()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
39 virtual cytnx_int32 to_cytnx_int32()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
40 virtual cytnx_uint32 to_cytnx_uint32()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
41 virtual cytnx_int16 to_cytnx_int16()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
42 virtual cytnx_uint16 to_cytnx_uint16()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;};
43 virtual cytnx_bool to_cytnx_bool()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
return 0;}
45 virtual void iadd(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
46 virtual void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
47 virtual void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
48 virtual void iadd(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
49 virtual void iadd(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
50 virtual void iadd(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
51 virtual void iadd(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
52 virtual void iadd(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
53 virtual void iadd(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
54 virtual void iadd(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
55 virtual void iadd(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
56 virtual void iadd(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
58 virtual void isub(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
59 virtual void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
60 virtual void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
61 virtual void isub(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
62 virtual void isub(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
63 virtual void isub(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
64 virtual void isub(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
65 virtual void isub(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
66 virtual void isub(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
67 virtual void isub(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
68 virtual void isub(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
69 virtual void isub(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
71 virtual void imul(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
72 virtual void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
73 virtual void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
74 virtual void imul(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
75 virtual void imul(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
76 virtual void imul(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
77 virtual void imul(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
78 virtual void imul(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
79 virtual void imul(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
80 virtual void imul(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
81 virtual void imul(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
82 virtual void imul(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
84 virtual void idiv(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
85 virtual void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
86 virtual void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
87 virtual void idiv(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
88 virtual void idiv(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
89 virtual void idiv(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
90 virtual void idiv(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
91 virtual void idiv(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
92 virtual void idiv(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
93 virtual void idiv(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
94 virtual void idiv(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
95 virtual void idiv(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
98 virtual bool less(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
99 virtual bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
100 virtual bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
101 virtual bool less(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
102 virtual bool less(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
103 virtual bool less(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
104 virtual bool less(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
105 virtual bool less(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
106 virtual bool less(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
107 virtual bool less(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
108 virtual bool less(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
109 virtual bool less(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
111 virtual bool greater(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
112 virtual bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
113 virtual bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
114 virtual bool greater(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
115 virtual bool greater(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
116 virtual bool greater(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
117 virtual bool greater(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
118 virtual bool greater(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
119 virtual bool greater(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
120 virtual bool greater(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
121 virtual bool greater(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
122 virtual bool greater(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
124 virtual bool eq(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return 0;}
127 virtual void set_maxval(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");};
128 virtual void set_minval(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");};
130 virtual void conj_(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
131 virtual Scalar_base* get_real(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return nullptr;}
132 virtual Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return nullptr;}
134 virtual void iabs(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
135 virtual void isqrt(){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
137 virtual void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
138 virtual void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
139 virtual void assign_selftype(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
140 virtual void assign_selftype(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
141 virtual void assign_selftype(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
142 virtual void assign_selftype(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
143 virtual void assign_selftype(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
144 virtual void assign_selftype(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
145 virtual void assign_selftype(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
146 virtual void assign_selftype(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
147 virtual void assign_selftype(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");}
149 virtual Scalar_base* astype(
const unsigned int &dtype){
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return nullptr;}
151 virtual void* get_raw_address()
const{
cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
return nullptr;}
153 virtual void print(std::ostream& os)
const{};
154 virtual Scalar_base* copy()
const{
155 Scalar_base *tmp =
new Scalar_base();
164 typedef Scalar_base* (*pScalar_init)();
168 class Scalar_init_interface:
public Type_class{
170 std::vector<pScalar_init> UScIInit;
171 Scalar_init_interface();
173 extern Scalar_init_interface
__ScII;
177 class ComplexDoubleScalar:
public Scalar_base{
182 ComplexDoubleScalar(): _elem(0){this->_dtype =
Type.ComplexDouble;};
183 ComplexDoubleScalar(
const cytnx_complex128 &in):_elem(0){
184 this->_dtype =
Type.ComplexDouble;
200 void assign_selftype(
const cytnx_complex128 &c){this->_elem = c;}
201 void assign_selftype(
const cytnx_complex64 &c){this->_elem = c;}
202 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
203 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
204 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
205 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
206 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
207 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
208 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
209 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
210 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
212 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_complex128();}
213 void iadd(
const cytnx_complex128 &c){this->_elem += c;}
214 void iadd(
const cytnx_complex64 &c){this->_elem += c;}
215 void iadd(
const cytnx_double &c){this->_elem += c;}
216 void iadd(
const cytnx_float &c){this->_elem += c;}
217 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
218 void iadd(
const cytnx_int64 &c){this->_elem += c;}
219 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
220 void iadd(
const cytnx_int32 &c){this->_elem += c;}
221 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
222 void iadd(
const cytnx_int16 &c){this->_elem += c;}
223 void iadd(
const cytnx_bool &c){this->_elem += c;}
225 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_complex128();}
226 void isub(
const cytnx_complex128 &c){this->_elem -= c;}
227 void isub(
const cytnx_complex64 &c){this->_elem -= c;}
228 void isub(
const cytnx_double &c){this->_elem -= c;}
229 void isub(
const cytnx_float &c){this->_elem -= c;}
230 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
231 void isub(
const cytnx_int64 &c){this->_elem -= c;}
232 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
233 void isub(
const cytnx_int32 &c){this->_elem -= c;}
234 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
235 void isub(
const cytnx_int16 &c){this->_elem -= c;}
236 void isub(
const cytnx_bool &c){this->_elem -= c;}
238 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_complex128();}
239 void imul(
const cytnx_complex128 &c){this->_elem *= c;}
240 void imul(
const cytnx_complex64 &c){this->_elem *= c;}
241 void imul(
const cytnx_double &c){this->_elem *= c;}
242 void imul(
const cytnx_float &c){this->_elem *= c;}
243 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
244 void imul(
const cytnx_int64 &c){this->_elem *= c;}
245 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
246 void imul(
const cytnx_int32 &c){this->_elem *= c;}
247 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
248 void imul(
const cytnx_int16 &c){this->_elem *= c;}
249 void imul(
const cytnx_bool &c){this->_elem *= c;}
251 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_complex128();}
252 void idiv(
const cytnx_complex128 &c){this->_elem /= c;}
253 void idiv(
const cytnx_complex64 &c){this->_elem /= c;}
254 void idiv(
const cytnx_double &c){this->_elem /= c;}
255 void idiv(
const cytnx_float &c){this->_elem /= c;}
256 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
257 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
258 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
259 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
260 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
261 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
262 void idiv(
const cytnx_bool &c){this->_elem /= c;}
265 void isqrt(){this->_elem=std::sqrt(this->_elem);}
267 bool less(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
268 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
269 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
270 bool less(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
271 bool less(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
272 bool less(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
273 bool less(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
274 bool less(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
275 bool less(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
276 bool less(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
277 bool less(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
278 bool less(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
280 bool greater(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
281 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
282 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
283 bool greater(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
284 bool greater(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
285 bool greater(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
286 bool greater(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
287 bool greater(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
288 bool greater(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
289 bool greater(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
290 bool greater(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
291 bool greater(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
293 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_complex128();}
295 void set_maxval(){
cytnx_error_msg(
true,
"[ERROR] maxval not supported for complex type%s",
"\n");}
296 void set_minval(){
cytnx_error_msg(
true,
"[ERROR] minval not supported for complex type%s",
"\n");}
298 void conj_(){this->_elem = std::conj(this->_elem);}
299 Scalar_base* get_real(){
300 Scalar_base *tmp =
__ScII.UScIInit[
Type.Double]();
301 tmp->assign_selftype(this->_elem.real());
304 Scalar_base* get_imag(){
305 Scalar_base *tmp =
__ScII.UScIInit[
Type.Double]();
306 tmp->assign_selftype(this->_elem.imag());
310 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
312 Scalar_base* astype(
const unsigned int &dtype){
313 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
314 tmp->assign_selftype(this->_elem);
318 Scalar_base* copy()
const{
319 ComplexDoubleScalar *tmp =
new ComplexDoubleScalar(this->_elem);
322 void print(std::ostream& os)
const{
323 os <<
"< " << this->_elem <<
" >";
327 class ComplexFloatScalar:
public Scalar_base{
332 ComplexFloatScalar(): _elem(0){this->_dtype =
Type.ComplexFloat;};
333 ComplexFloatScalar(
const cytnx_complex64 &in): _elem(0){
334 this->_dtype =
Type.ComplexFloat;
350 void assign_selftype(
const cytnx_complex128 &c){this->_elem = c;}
351 void assign_selftype(
const cytnx_complex64 &c){this->_elem = c;}
352 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
353 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
354 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
355 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
356 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
357 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
358 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
359 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
360 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
363 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_complex64();}
364 void iadd(
const cytnx_complex128 &c){this->_elem += c;}
365 void iadd(
const cytnx_complex64 &c){this->_elem += c;}
366 void iadd(
const cytnx_double &c){this->_elem += c;}
367 void iadd(
const cytnx_float &c){this->_elem += c;}
368 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
369 void iadd(
const cytnx_int64 &c){this->_elem += c;}
370 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
371 void iadd(
const cytnx_int32 &c){this->_elem += c;}
372 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
373 void iadd(
const cytnx_int16 &c){this->_elem += c;}
374 void iadd(
const cytnx_bool &c){this->_elem += c;}
376 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_complex64();}
377 void isub(
const cytnx_complex128 &c){this->_elem -= c;}
378 void isub(
const cytnx_complex64 &c){this->_elem -= c;}
379 void isub(
const cytnx_double &c){this->_elem -= c;}
380 void isub(
const cytnx_float &c){this->_elem -= c;}
381 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
382 void isub(
const cytnx_int64 &c){this->_elem -= c;}
383 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
384 void isub(
const cytnx_int32 &c){this->_elem -= c;}
385 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
386 void isub(
const cytnx_int16 &c){this->_elem -= c;}
387 void isub(
const cytnx_bool &c){this->_elem -= c;}
389 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_complex64();}
390 void imul(
const cytnx_complex128 &c){this->_elem *= c;}
391 void imul(
const cytnx_complex64 &c){this->_elem *= c;}
392 void imul(
const cytnx_double &c){this->_elem *= c;}
393 void imul(
const cytnx_float &c){this->_elem *= c;}
394 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
395 void imul(
const cytnx_int64 &c){this->_elem *= c;}
396 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
397 void imul(
const cytnx_int32 &c){this->_elem *= c;}
398 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
399 void imul(
const cytnx_int16 &c){this->_elem *= c;}
400 void imul(
const cytnx_bool &c){this->_elem *= c;}
402 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_complex64();}
403 void idiv(
const cytnx_complex128 &c){this->_elem /= c;}
404 void idiv(
const cytnx_complex64 &c){this->_elem /= c;}
405 void idiv(
const cytnx_double &c){this->_elem /= c;}
406 void idiv(
const cytnx_float &c){this->_elem /= c;}
407 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
408 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
409 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
410 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
411 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
412 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
413 void idiv(
const cytnx_bool &c){this->_elem /= c;}
416 bool less(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
417 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
418 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
419 bool less(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
420 bool less(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
421 bool less(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
422 bool less(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
423 bool less(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
424 bool less(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
425 bool less(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
426 bool less(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
427 bool less(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
429 bool greater(
const Scalar_base* c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
430 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
431 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
432 bool greater(
const cytnx_double &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
433 bool greater(
const cytnx_float &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
434 bool greater(
const cytnx_uint64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
435 bool greater(
const cytnx_int64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
436 bool greater(
const cytnx_uint32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
437 bool greater(
const cytnx_int32 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
438 bool greater(
const cytnx_uint16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
439 bool greater(
const cytnx_int16 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
440 bool greater(
const cytnx_bool &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
442 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_complex64();}
444 void set_maxval(){
cytnx_error_msg(
true,
"[ERROR] maxval not supported for complex type%s",
"\n");}
445 void set_minval(){
cytnx_error_msg(
true,
"[ERROR] minval not supported for complex type%s",
"\n");}
447 void conj_(){this->_elem = std::conj(this->_elem);}
448 Scalar_base* get_real(){
449 Scalar_base *tmp =
__ScII.UScIInit[
Type.Float]();
450 tmp->assign_selftype(this->_elem.real());
453 Scalar_base* get_imag(){
454 Scalar_base *tmp =
__ScII.UScIInit[
Type.Float]();
455 tmp->assign_selftype(this->_elem.imag());
459 void iabs(){this->_elem=std::abs(this->_elem);}
460 void isqrt(){this->_elem=std::sqrt(this->_elem);}
462 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
463 Scalar_base* astype(
const unsigned int &dtype){
464 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
465 tmp->assign_selftype(this->_elem);
469 Scalar_base* copy()
const{
470 ComplexFloatScalar *tmp =
new ComplexFloatScalar(this->_elem);
473 void print(std::ostream& os)
const{
474 os <<
"< " << this->_elem <<
" >";
478 class DoubleScalar:
public Scalar_base{
483 DoubleScalar(): _elem(0){this->_dtype =
Type.Double;};
484 DoubleScalar(
const cytnx_double &in): _elem(0){
485 this->_dtype =
Type.Double;
489 cytnx_float to_cytnx_float()
const{
return this->_elem;};
490 cytnx_double to_cytnx_double()
const{
return this->_elem;};
493 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
494 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
495 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
496 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
497 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
498 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
499 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
501 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
502 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
503 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
504 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
505 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
506 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
507 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
508 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
509 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
510 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
511 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
514 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_double();}
515 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
516 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
517 void iadd(
const cytnx_double &c){this->_elem += c;}
518 void iadd(
const cytnx_float &c){this->_elem += c;}
519 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
520 void iadd(
const cytnx_int64 &c){this->_elem += c;}
521 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
522 void iadd(
const cytnx_int32 &c){this->_elem += c;}
523 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
524 void iadd(
const cytnx_int16 &c){this->_elem += c;}
525 void iadd(
const cytnx_bool &c){this->_elem += c;}
527 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_double();}
528 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
529 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
530 void isub(
const cytnx_double &c){this->_elem -= c;}
531 void isub(
const cytnx_float &c){this->_elem -= c;}
532 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
533 void isub(
const cytnx_int64 &c){this->_elem -= c;}
534 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
535 void isub(
const cytnx_int32 &c){this->_elem -= c;}
536 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
537 void isub(
const cytnx_int16 &c){this->_elem -= c;}
538 void isub(
const cytnx_bool &c){this->_elem -= c;}
540 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_double();}
541 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
542 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
543 void imul(
const cytnx_double &c){this->_elem *= c;}
544 void imul(
const cytnx_float &c){this->_elem *= c;}
545 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
546 void imul(
const cytnx_int64 &c){this->_elem *= c;}
547 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
548 void imul(
const cytnx_int32 &c){this->_elem *= c;}
549 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
550 void imul(
const cytnx_int16 &c){this->_elem *= c;}
551 void imul(
const cytnx_bool &c){this->_elem *= c;}
553 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_double();}
554 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
555 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
556 void idiv(
const cytnx_double &c){this->_elem /= c;}
557 void idiv(
const cytnx_float &c){this->_elem /= c;}
558 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
559 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
560 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
561 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
562 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
563 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
564 void idiv(
const cytnx_bool &c){this->_elem /= c;}
566 void iabs(){this->_elem=std::abs(this->_elem);}
567 void isqrt(){this->_elem=std::sqrt(this->_elem);}
569 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_double();}
570 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
571 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
572 bool less(
const cytnx_double &c){
return this->_elem < c;}
573 bool less(
const cytnx_float &c){
return this->_elem < c;}
574 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
575 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
576 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
577 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
578 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
579 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
580 bool less(
const cytnx_bool &c){
return this->_elem < c;}
582 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_double();}
583 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
584 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
585 bool greater(
const cytnx_double &c){
return this->_elem > c;}
586 bool greater(
const cytnx_float &c){
return this->_elem > c;}
587 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
588 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
589 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
590 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
591 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
592 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
593 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
595 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_double();}
597 void set_maxval(){this->_elem = std::numeric_limits<double>::max();}
598 void set_minval(){this->_elem = std::numeric_limits<double>::min();}
600 void conj_(){
return;}
601 Scalar_base* get_real(){
return this->copy();}
602 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
605 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
606 Scalar_base* astype(
const unsigned int &dtype){
607 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
608 tmp->assign_selftype(this->_elem);
611 Scalar_base* copy()
const{
612 DoubleScalar *tmp =
new DoubleScalar(this->_elem);
615 void print(std::ostream& os)
const{
616 os <<
"< " << this->_elem <<
" >";
620 class FloatScalar:
public Scalar_base{
625 FloatScalar(): _elem(0){this->_dtype =
Type.Float;};
626 FloatScalar(
const cytnx_float &in): _elem(0){
627 this->_dtype =
Type.Float;
631 cytnx_float to_cytnx_float()
const{
return this->_elem;};
632 cytnx_double to_cytnx_double()
const{
return this->_elem;};
635 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
636 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
637 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
638 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
639 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
640 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
641 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
643 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
644 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
645 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
646 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
647 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
648 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
649 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
650 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
651 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
652 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
653 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
655 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_float();}
656 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
657 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
658 void iadd(
const cytnx_double &c){this->_elem += c;}
659 void iadd(
const cytnx_float &c){this->_elem += c;}
660 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
661 void iadd(
const cytnx_int64 &c){this->_elem += c;}
662 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
663 void iadd(
const cytnx_int32 &c){this->_elem += c;}
664 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
665 void iadd(
const cytnx_int16 &c){this->_elem += c;}
666 void iadd(
const cytnx_bool &c){this->_elem += c;}
668 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_float();}
669 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
670 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
671 void isub(
const cytnx_double &c){this->_elem -= c;}
672 void isub(
const cytnx_float &c){this->_elem -= c;}
673 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
674 void isub(
const cytnx_int64 &c){this->_elem -= c;}
675 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
676 void isub(
const cytnx_int32 &c){this->_elem -= c;}
677 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
678 void isub(
const cytnx_int16 &c){this->_elem -= c;}
679 void isub(
const cytnx_bool &c){this->_elem -= c;}
681 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_float();}
682 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
683 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
684 void imul(
const cytnx_double &c){this->_elem *= c;}
685 void imul(
const cytnx_float &c){this->_elem *= c;}
686 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
687 void imul(
const cytnx_int64 &c){this->_elem *= c;}
688 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
689 void imul(
const cytnx_int32 &c){this->_elem *= c;}
690 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
691 void imul(
const cytnx_int16 &c){this->_elem *= c;}
692 void imul(
const cytnx_bool &c){this->_elem *= c;}
694 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_float();}
695 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
696 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
697 void idiv(
const cytnx_double &c){this->_elem /= c;}
698 void idiv(
const cytnx_float &c){this->_elem /= c;}
699 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
700 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
701 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
702 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
703 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
704 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
705 void idiv(
const cytnx_bool &c){this->_elem /= c;}
709 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_float();}
710 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
711 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
712 bool less(
const cytnx_double &c){
return this->_elem < c;}
713 bool less(
const cytnx_float &c){
return this->_elem < c;}
714 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
715 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
716 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
717 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
718 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
719 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
720 bool less(
const cytnx_bool &c){
return this->_elem < c;}
722 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_float();}
723 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
724 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
725 bool greater(
const cytnx_double &c){
return this->_elem > c;}
726 bool greater(
const cytnx_float &c){
return this->_elem > c;}
727 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
728 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
729 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
730 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
731 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
732 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
733 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
735 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_float();}
736 void isqrt(){this->_elem=std::sqrt(this->_elem);}
738 void conj_(){
return;}
739 Scalar_base* get_real(){
return this->copy();}
740 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
742 void set_maxval(){this->_elem = std::numeric_limits<float>::max();}
743 void set_minval(){this->_elem = std::numeric_limits<float>::min();}
745 void iabs(){this->_elem=std::abs(this->_elem);}
747 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
748 Scalar_base* astype(
const unsigned int &dtype){
749 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
750 tmp->assign_selftype(this->_elem);
753 Scalar_base* copy()
const{
754 FloatScalar *tmp =
new FloatScalar(this->_elem);
757 void print(std::ostream& os)
const{
758 os <<
"< " << this->_elem <<
" >";
762 class Int64Scalar:
public Scalar_base{
767 Int64Scalar(): _elem(0){this->_dtype =
Type.Int64;};
768 Int64Scalar(
const cytnx_int64 &in): _elem(0){
769 this->_dtype =
Type.Int64;
773 cytnx_float to_cytnx_float()
const{
return this->_elem;};
774 cytnx_double to_cytnx_double()
const{
return this->_elem;};
777 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
778 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
779 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
780 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
781 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
782 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
783 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
785 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
786 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
787 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
788 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
789 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
790 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
791 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
792 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
793 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
794 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
795 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
797 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_int64();}
798 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
799 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
800 void iadd(
const cytnx_double &c){this->_elem += c;}
801 void iadd(
const cytnx_float &c){this->_elem += c;}
802 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
803 void iadd(
const cytnx_int64 &c){this->_elem += c;}
804 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
805 void iadd(
const cytnx_int32 &c){this->_elem += c;}
806 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
807 void iadd(
const cytnx_int16 &c){this->_elem += c;}
808 void iadd(
const cytnx_bool &c){this->_elem += c;}
810 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_int64();}
811 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
812 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
813 void isub(
const cytnx_double &c){this->_elem -= c;}
814 void isub(
const cytnx_float &c){this->_elem -= c;}
815 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
816 void isub(
const cytnx_int64 &c){this->_elem -= c;}
817 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
818 void isub(
const cytnx_int32 &c){this->_elem -= c;}
819 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
820 void isub(
const cytnx_int16 &c){this->_elem -= c;}
821 void isub(
const cytnx_bool &c){this->_elem -= c;}
823 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_int64();}
824 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
825 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
826 void imul(
const cytnx_double &c){this->_elem *= c;}
827 void imul(
const cytnx_float &c){this->_elem *= c;}
828 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
829 void imul(
const cytnx_int64 &c){this->_elem *= c;}
830 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
831 void imul(
const cytnx_int32 &c){this->_elem *= c;}
832 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
833 void imul(
const cytnx_int16 &c){this->_elem *= c;}
834 void imul(
const cytnx_bool &c){this->_elem *= c;}
837 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_int64();}
838 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
839 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
840 void idiv(
const cytnx_double &c){this->_elem /= c;}
841 void idiv(
const cytnx_float &c){this->_elem /= c;}
842 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
843 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
844 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
845 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
846 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
847 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
848 void idiv(
const cytnx_bool &c){this->_elem /= c;}
850 void iabs(){this->_elem=std::abs(this->_elem);}
851 void isqrt(){this->_elem=std::sqrt(this->_elem);}
853 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_int64();}
854 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
855 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
856 bool less(
const cytnx_double &c){
return this->_elem < c;}
857 bool less(
const cytnx_float &c){
return this->_elem < c;}
858 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
859 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
860 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
861 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
862 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
863 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
864 bool less(
const cytnx_bool &c){
return this->_elem < c;}
866 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_int64();}
867 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
868 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
869 bool greater(
const cytnx_double &c){
return this->_elem > c;}
870 bool greater(
const cytnx_float &c){
return this->_elem > c;}
871 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
872 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
873 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
874 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
875 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
876 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
877 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
879 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_int64();}
881 void conj_(){
return;}
882 Scalar_base* get_real(){
return this->copy();}
883 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
885 void set_maxval(){this->_elem = std::numeric_limits<cytnx_int64>::max();}
886 void set_minval(){this->_elem = std::numeric_limits<cytnx_int64>::min();}
888 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
889 Scalar_base* astype(
const unsigned int &dtype){
890 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
891 tmp->assign_selftype(this->_elem);
894 Scalar_base* copy()
const{
895 Int64Scalar *tmp =
new Int64Scalar(this->_elem);
898 void print(std::ostream& os)
const{
899 os <<
"< " << this->_elem <<
" >";
902 class Uint64Scalar:
public Scalar_base{
907 Uint64Scalar(): _elem(0){this->_dtype =
Type.Uint64;};
908 Uint64Scalar(
const cytnx_uint64 &in): _elem(0){
909 this->_dtype =
Type.Uint64;
913 cytnx_float to_cytnx_float()
const{
return this->_elem;};
914 cytnx_double to_cytnx_double()
const{
return this->_elem;};
917 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
918 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
919 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
920 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
921 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
922 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
923 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
925 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
926 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
927 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
928 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
929 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
930 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
931 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
932 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
933 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
934 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
935 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
937 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_uint64();}
938 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
939 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
940 void iadd(
const cytnx_double &c){this->_elem += c;}
941 void iadd(
const cytnx_float &c){this->_elem += c;}
942 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
943 void iadd(
const cytnx_int64 &c){this->_elem += c;}
944 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
945 void iadd(
const cytnx_int32 &c){this->_elem += c;}
946 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
947 void iadd(
const cytnx_int16 &c){this->_elem += c;}
948 void iadd(
const cytnx_bool &c){this->_elem += c;}
950 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_uint64();}
951 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
952 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
953 void isub(
const cytnx_double &c){this->_elem -= c;}
954 void isub(
const cytnx_float &c){this->_elem -= c;}
955 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
956 void isub(
const cytnx_int64 &c){this->_elem -= c;}
957 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
958 void isub(
const cytnx_int32 &c){this->_elem -= c;}
959 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
960 void isub(
const cytnx_int16 &c){this->_elem -= c;}
961 void isub(
const cytnx_bool &c){this->_elem -= c;}
963 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_uint64();}
964 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
965 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
966 void imul(
const cytnx_double &c){this->_elem *= c;}
967 void imul(
const cytnx_float &c){this->_elem *= c;}
968 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
969 void imul(
const cytnx_int64 &c){this->_elem *= c;}
970 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
971 void imul(
const cytnx_int32 &c){this->_elem *= c;}
972 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
973 void imul(
const cytnx_int16 &c){this->_elem *= c;}
974 void imul(
const cytnx_bool &c){this->_elem *= c;}
976 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_uint64();}
977 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
978 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
979 void idiv(
const cytnx_double &c){this->_elem /= c;}
980 void idiv(
const cytnx_float &c){this->_elem /= c;}
981 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
982 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
983 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
984 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
985 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
986 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
987 void idiv(
const cytnx_bool &c){this->_elem /= c;}
989 void iabs(){this->_elem=std::abs(
cytnx_double(this->_elem));}
990 void isqrt(){this->_elem=std::sqrt(this->_elem);}
992 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_uint64();}
993 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
994 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
995 bool less(
const cytnx_double &c){
return this->_elem < c;}
996 bool less(
const cytnx_float &c){
return this->_elem < c;}
997 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
998 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
999 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1000 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1001 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1002 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1003 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1005 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_uint64();}
1006 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1007 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1008 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1009 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1010 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1011 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1012 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1013 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1014 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1015 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1016 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1018 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_uint64();}
1020 void conj_(){
return;}
1021 Scalar_base* get_real(){
return this->copy();}
1022 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1024 void set_maxval(){this->_elem = std::numeric_limits<cytnx_uint64>::max();}
1025 void set_minval(){this->_elem = std::numeric_limits<cytnx_uint64>::min();}
1028 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1029 Scalar_base* astype(
const unsigned int &dtype){
1030 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1031 tmp->assign_selftype(this->_elem);
1034 Scalar_base* copy()
const{
1035 Uint64Scalar *tmp =
new Uint64Scalar(this->_elem);
1038 void print(std::ostream& os)
const{
1039 os <<
"< " << this->_elem <<
" >";
1042 class Int32Scalar:
public Scalar_base{
1047 Int32Scalar(): _elem(0){this->_dtype =
Type.Int32;};
1048 Int32Scalar(
const cytnx_int32 &in): _elem(0){
1049 this->_dtype =
Type.Int32;
1053 cytnx_float to_cytnx_float()
const{
return this->_elem;};
1054 cytnx_double to_cytnx_double()
const{
return this->_elem;};
1057 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
1058 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
1059 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
1060 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
1061 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
1062 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
1063 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
1066 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1067 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1068 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
1069 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
1070 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
1071 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
1072 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
1073 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
1074 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
1075 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
1076 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
1078 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_int32();}
1079 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1080 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1081 void iadd(
const cytnx_double &c){this->_elem += c;}
1082 void iadd(
const cytnx_float &c){this->_elem += c;}
1083 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
1084 void iadd(
const cytnx_int64 &c){this->_elem += c;}
1085 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
1086 void iadd(
const cytnx_int32 &c){this->_elem += c;}
1087 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
1088 void iadd(
const cytnx_int16 &c){this->_elem += c;}
1089 void iadd(
const cytnx_bool &c){this->_elem += c;}
1091 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_int32();}
1092 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1093 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1094 void isub(
const cytnx_double &c){this->_elem -= c;}
1095 void isub(
const cytnx_float &c){this->_elem -= c;}
1096 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
1097 void isub(
const cytnx_int64 &c){this->_elem -= c;}
1098 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
1099 void isub(
const cytnx_int32 &c){this->_elem -= c;}
1100 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
1101 void isub(
const cytnx_int16 &c){this->_elem -= c;}
1102 void isub(
const cytnx_bool &c){this->_elem -= c;}
1104 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_int32();}
1105 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1106 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1107 void imul(
const cytnx_double &c){this->_elem *= c;}
1108 void imul(
const cytnx_float &c){this->_elem *= c;}
1109 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
1110 void imul(
const cytnx_int64 &c){this->_elem *= c;}
1111 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
1112 void imul(
const cytnx_int32 &c){this->_elem *= c;}
1113 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
1114 void imul(
const cytnx_int16 &c){this->_elem *= c;}
1115 void imul(
const cytnx_bool &c){this->_elem *= c;}
1117 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_int32();}
1118 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1119 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1120 void idiv(
const cytnx_double &c){this->_elem /= c;}
1121 void idiv(
const cytnx_float &c){this->_elem /= c;}
1122 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
1123 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
1124 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
1125 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
1126 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
1127 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
1128 void idiv(
const cytnx_bool &c){this->_elem /= c;}
1130 void iabs(){this->_elem=std::abs(this->_elem);}
1131 void isqrt(){this->_elem=std::sqrt(this->_elem);}
1133 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_int32();}
1134 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1135 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1136 bool less(
const cytnx_double &c){
return this->_elem < c;}
1137 bool less(
const cytnx_float &c){
return this->_elem < c;}
1138 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
1139 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
1140 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1141 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1142 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1143 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1144 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1147 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_int32();}
1148 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1149 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1150 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1151 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1152 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1153 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1154 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1155 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1156 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1157 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1158 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1160 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_int32();}
1162 void conj_(){
return;}
1163 Scalar_base* get_real(){
return this->copy();}
1164 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1166 void set_maxval(){this->_elem = std::numeric_limits<cytnx_int32>::max();}
1167 void set_minval(){this->_elem = std::numeric_limits<cytnx_int32>::min();}
1169 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1171 Scalar_base* astype(
const unsigned int &dtype){
1172 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1173 tmp->assign_selftype(this->_elem);
1176 Scalar_base* copy()
const{
1177 Int32Scalar *tmp =
new Int32Scalar(this->_elem);
1180 void print(std::ostream& os)
const{
1181 os <<
"< " << this->_elem <<
" >";
1184 class Uint32Scalar:
public Scalar_base{
1189 Uint32Scalar(): _elem(0){this->_dtype =
Type.Uint32;};
1190 Uint32Scalar(
const cytnx_uint32 &in): _elem(0){
1191 this->_dtype =
Type.Uint32;
1195 cytnx_float to_cytnx_float()
const{
return this->_elem;};
1196 cytnx_double to_cytnx_double()
const{
return this->_elem;};
1199 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
1200 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
1201 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
1202 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
1203 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
1204 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
1205 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
1207 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1208 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1209 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
1210 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
1211 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
1212 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
1213 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
1214 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
1215 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
1216 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
1217 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
1219 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_uint32();}
1220 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1221 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1222 void iadd(
const cytnx_double &c){this->_elem += c;}
1223 void iadd(
const cytnx_float &c){this->_elem += c;}
1224 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
1225 void iadd(
const cytnx_int64 &c){this->_elem += c;}
1226 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
1227 void iadd(
const cytnx_int32 &c){this->_elem += c;}
1228 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
1229 void iadd(
const cytnx_int16 &c){this->_elem += c;}
1230 void iadd(
const cytnx_bool &c){this->_elem += c;}
1232 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_uint32();}
1233 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1234 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1235 void isub(
const cytnx_double &c){this->_elem -= c;}
1236 void isub(
const cytnx_float &c){this->_elem -= c;}
1237 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
1238 void isub(
const cytnx_int64 &c){this->_elem -= c;}
1239 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
1240 void isub(
const cytnx_int32 &c){this->_elem -= c;}
1241 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
1242 void isub(
const cytnx_int16 &c){this->_elem -= c;}
1243 void isub(
const cytnx_bool &c){this->_elem -= c;}
1245 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_uint32();}
1246 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1247 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1248 void imul(
const cytnx_double &c){this->_elem *= c;}
1249 void imul(
const cytnx_float &c){this->_elem *= c;}
1250 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
1251 void imul(
const cytnx_int64 &c){this->_elem *= c;}
1252 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
1253 void imul(
const cytnx_int32 &c){this->_elem *= c;}
1254 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
1255 void imul(
const cytnx_int16 &c){this->_elem *= c;}
1256 void imul(
const cytnx_bool &c){this->_elem *= c;}
1258 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_uint32();}
1259 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1260 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1261 void idiv(
const cytnx_double &c){this->_elem /= c;}
1262 void idiv(
const cytnx_float &c){this->_elem /= c;}
1263 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
1264 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
1265 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
1266 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
1267 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
1268 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
1269 void idiv(
const cytnx_bool &c){this->_elem /= c;}
1271 void iabs(){this->_elem=std::abs(
cytnx_double(this->_elem));}
1272 void isqrt(){this->_elem=std::sqrt(this->_elem);}
1274 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_uint32();}
1275 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1276 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1277 bool less(
const cytnx_double &c){
return this->_elem < c;}
1278 bool less(
const cytnx_float &c){
return this->_elem < c;}
1279 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
1280 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
1281 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1282 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1283 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1284 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1285 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1287 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_uint32();}
1288 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1289 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1290 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1291 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1292 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1293 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1294 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1295 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1296 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1297 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1298 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1300 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_uint32();}
1302 void conj_(){
return;}
1303 Scalar_base* get_real(){
return this->copy();}
1304 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1306 void set_maxval(){this->_elem = std::numeric_limits<cytnx_uint32>::max();}
1307 void set_minval(){this->_elem = std::numeric_limits<cytnx_uint32>::min();}
1310 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1311 Scalar_base* astype(
const unsigned int &dtype){
1312 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1313 tmp->assign_selftype(this->_elem);
1316 Scalar_base* copy()
const{
1317 Uint32Scalar *tmp =
new Uint32Scalar(this->_elem);
1320 void print(std::ostream& os)
const{
1321 os <<
"< " << this->_elem <<
" >";
1324 class Int16Scalar:
public Scalar_base{
1329 Int16Scalar(): _elem(0){this->_dtype =
Type.Int16;};
1330 Int16Scalar(
const cytnx_int16 &in): _elem(0){
1331 this->_dtype =
Type.Int16;
1335 cytnx_float to_cytnx_float()
const{
return this->_elem;};
1336 cytnx_double to_cytnx_double()
const{
return this->_elem;};
1339 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
1340 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
1341 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
1342 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
1343 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
1344 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
1345 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
1347 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1348 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1349 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
1350 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
1351 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
1352 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
1353 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
1354 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
1355 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
1356 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
1357 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
1360 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_int16();}
1361 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1362 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1363 void iadd(
const cytnx_double &c){this->_elem += c;}
1364 void iadd(
const cytnx_float &c){this->_elem += c;}
1365 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
1366 void iadd(
const cytnx_int64 &c){this->_elem += c;}
1367 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
1368 void iadd(
const cytnx_int32 &c){this->_elem += c;}
1369 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
1370 void iadd(
const cytnx_int16 &c){this->_elem += c;}
1371 void iadd(
const cytnx_bool &c){this->_elem += c;}
1373 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_int16();}
1374 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1375 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1376 void isub(
const cytnx_double &c){this->_elem -= c;}
1377 void isub(
const cytnx_float &c){this->_elem -= c;}
1378 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
1379 void isub(
const cytnx_int64 &c){this->_elem -= c;}
1380 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
1381 void isub(
const cytnx_int32 &c){this->_elem -= c;}
1382 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
1383 void isub(
const cytnx_int16 &c){this->_elem -= c;}
1384 void isub(
const cytnx_bool &c){this->_elem -= c;}
1386 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_int16();}
1387 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1388 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1389 void imul(
const cytnx_double &c){this->_elem *= c;}
1390 void imul(
const cytnx_float &c){this->_elem *= c;}
1391 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
1392 void imul(
const cytnx_int64 &c){this->_elem *= c;}
1393 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
1394 void imul(
const cytnx_int32 &c){this->_elem *= c;}
1395 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
1396 void imul(
const cytnx_int16 &c){this->_elem *= c;}
1397 void imul(
const cytnx_bool &c){this->_elem *= c;}
1399 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_int16();}
1400 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1401 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1402 void idiv(
const cytnx_double &c){this->_elem /= c;}
1403 void idiv(
const cytnx_float &c){this->_elem /= c;}
1404 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
1405 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
1406 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
1407 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
1408 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
1409 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
1410 void idiv(
const cytnx_bool &c){this->_elem /= c;}
1412 void iabs(){this->_elem=std::abs(this->_elem);}
1413 void isqrt(){this->_elem=std::sqrt(this->_elem);}
1415 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_int16();}
1416 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1417 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1418 bool less(
const cytnx_double &c){
return this->_elem < c;}
1419 bool less(
const cytnx_float &c){
return this->_elem < c;}
1420 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
1421 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
1422 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1423 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1424 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1425 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1426 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1428 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_int16();}
1429 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1430 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1431 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1432 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1433 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1434 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1435 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1436 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1437 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1438 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1439 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1441 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_int16();}
1443 void conj_(){
return;}
1444 Scalar_base* get_real(){
return this->copy();}
1445 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1447 void set_maxval(){this->_elem = std::numeric_limits<cytnx_int16>::max();}
1448 void set_minval(){this->_elem = std::numeric_limits<cytnx_int16>::min();}
1450 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1451 Scalar_base* astype(
const unsigned int &dtype){
1452 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1453 tmp->assign_selftype(this->_elem);
1456 Scalar_base* copy()
const{
1457 Int16Scalar *tmp =
new Int16Scalar(this->_elem);
1460 void print(std::ostream& os)
const{
1461 os <<
"< " << this->_elem <<
" >";
1464 class Uint16Scalar:
public Scalar_base{
1469 Uint16Scalar(): _elem(0){this->_dtype =
Type.Uint16;};
1470 Uint16Scalar(
const cytnx_uint16 &in): _elem(0){
1471 this->_dtype =
Type.Uint16;
1475 cytnx_float to_cytnx_float()
const{
return this->_elem;};
1476 cytnx_double to_cytnx_double()
const{
return this->_elem;};
1479 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
1480 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
1481 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
1482 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
1483 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
1484 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
1485 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
1487 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1488 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1489 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
1490 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
1491 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
1492 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
1493 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
1494 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
1495 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
1496 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
1497 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
1499 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_uint16();}
1500 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1501 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1502 void iadd(
const cytnx_double &c){this->_elem += c;}
1503 void iadd(
const cytnx_float &c){this->_elem += c;}
1504 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
1505 void iadd(
const cytnx_int64 &c){this->_elem += c;}
1506 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
1507 void iadd(
const cytnx_int32 &c){this->_elem += c;}
1508 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
1509 void iadd(
const cytnx_int16 &c){this->_elem += c;}
1510 void iadd(
const cytnx_bool &c){this->_elem += c;}
1512 void isub(
const Scalar_base* c){this->_elem += c->to_cytnx_uint16();}
1513 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1514 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1515 void isub(
const cytnx_double &c){this->_elem += c;}
1516 void isub(
const cytnx_float &c){this->_elem += c;}
1517 void isub(
const cytnx_uint64 &c){this->_elem += c;}
1518 void isub(
const cytnx_int64 &c){this->_elem += c;}
1519 void isub(
const cytnx_uint32 &c){this->_elem += c;}
1520 void isub(
const cytnx_int32 &c){this->_elem += c;}
1521 void isub(
const cytnx_uint16 &c){this->_elem += c;}
1522 void isub(
const cytnx_int16 &c){this->_elem += c;}
1523 void isub(
const cytnx_bool &c){this->_elem += c;}
1525 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_uint16();}
1526 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1527 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1528 void imul(
const cytnx_double &c){this->_elem *= c;}
1529 void imul(
const cytnx_float &c){this->_elem *= c;}
1530 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
1531 void imul(
const cytnx_int64 &c){this->_elem *= c;}
1532 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
1533 void imul(
const cytnx_int32 &c){this->_elem *= c;}
1534 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
1535 void imul(
const cytnx_int16 &c){this->_elem *= c;}
1536 void imul(
const cytnx_bool &c){this->_elem *= c;}
1539 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_uint16();}
1540 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1541 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1542 void idiv(
const cytnx_double &c){this->_elem /= c;}
1543 void idiv(
const cytnx_float &c){this->_elem /= c;}
1544 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
1545 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
1546 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
1547 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
1548 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
1549 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
1550 void idiv(
const cytnx_bool &c){this->_elem /= c;}
1552 void iabs(){this->_elem=std::abs(this->_elem);}
1553 void isqrt(){this->_elem=std::sqrt(this->_elem);}
1555 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_uint16();}
1556 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1557 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1558 bool less(
const cytnx_double &c){
return this->_elem < c;}
1559 bool less(
const cytnx_float &c){
return this->_elem < c;}
1560 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
1561 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
1562 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1563 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1564 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1565 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1566 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1568 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_uint16();}
1569 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1570 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1571 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1572 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1573 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1574 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1575 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1576 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1577 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1578 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1579 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1581 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_uint16();}
1583 void conj_(){
return;}
1584 Scalar_base* get_real(){
return this->copy();}
1585 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1587 void set_maxval(){this->_elem = std::numeric_limits<cytnx_uint16>::max();}
1588 void set_minval(){this->_elem = std::numeric_limits<cytnx_uint16>::min();}
1590 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1591 Scalar_base* astype(
const unsigned int &dtype){
1592 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1593 tmp->assign_selftype(this->_elem);
1596 Scalar_base* copy()
const{
1597 Uint16Scalar *tmp =
new Uint16Scalar(this->_elem);
1600 void print(std::ostream& os)
const{
1601 os <<
"< " << this->_elem <<
" >";
1604 class BoolScalar:
public Scalar_base{
1609 BoolScalar(): _elem(0){this->_dtype =
Type.Bool;};
1610 BoolScalar(
const cytnx_bool &in): _elem(0){
1611 this->_dtype =
Type.Bool;
1615 cytnx_float to_cytnx_float()
const{
return this->_elem;};
1616 cytnx_double to_cytnx_double()
const{
return this->_elem;};
1619 cytnx_int64 to_cytnx_int64()
const{
return this->_elem;};
1620 cytnx_uint64 to_cytnx_uint64()
const{
return this->_elem;};
1621 cytnx_int32 to_cytnx_int32()
const{
return this->_elem;};
1622 cytnx_uint32 to_cytnx_uint32()
const{
return this->_elem;};
1623 cytnx_int16 to_cytnx_int16()
const{
return this->_elem;};
1624 cytnx_uint16 to_cytnx_uint16()
const{
return this->_elem;};
1625 cytnx_bool to_cytnx_bool()
const{
return this->_elem;};
1627 void assign_selftype(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1628 void assign_selftype(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");}
1629 void assign_selftype(
const cytnx_double &c){this->_elem = c;}
1630 void assign_selftype(
const cytnx_float &c){this->_elem = c;}
1631 void assign_selftype(
const cytnx_uint64 &c){this->_elem = c;}
1632 void assign_selftype(
const cytnx_int64 &c){this->_elem = c;}
1633 void assign_selftype(
const cytnx_uint32 &c){this->_elem = c;}
1634 void assign_selftype(
const cytnx_int32 &c){this->_elem = c;}
1635 void assign_selftype(
const cytnx_uint16 &c){this->_elem = c;}
1636 void assign_selftype(
const cytnx_int16 &c){this->_elem = c;}
1637 void assign_selftype(
const cytnx_bool &c){this->_elem = c;}
1639 void iadd(
const Scalar_base* c){this->_elem += c->to_cytnx_bool();}
1640 void iadd(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1641 void iadd(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1642 void iadd(
const cytnx_double &c){this->_elem += c;}
1643 void iadd(
const cytnx_float &c){this->_elem += c;}
1644 void iadd(
const cytnx_uint64 &c){this->_elem += c;}
1645 void iadd(
const cytnx_int64 &c){this->_elem += c;}
1646 void iadd(
const cytnx_uint32 &c){this->_elem += c;}
1647 void iadd(
const cytnx_int32 &c){this->_elem += c;}
1648 void iadd(
const cytnx_uint16 &c){this->_elem += c;}
1649 void iadd(
const cytnx_int16 &c){this->_elem += c;}
1650 void iadd(
const cytnx_bool &c){this->_elem += c;}
1652 void isub(
const Scalar_base* c){this->_elem -= c->to_cytnx_bool();}
1653 void isub(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1654 void isub(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1655 void isub(
const cytnx_double &c){this->_elem -= c;}
1656 void isub(
const cytnx_float &c){this->_elem -= c;}
1657 void isub(
const cytnx_uint64 &c){this->_elem -= c;}
1658 void isub(
const cytnx_int64 &c){this->_elem -= c;}
1659 void isub(
const cytnx_uint32 &c){this->_elem -= c;}
1660 void isub(
const cytnx_int32 &c){this->_elem -= c;}
1661 void isub(
const cytnx_uint16 &c){this->_elem -= c;}
1662 void isub(
const cytnx_int16 &c){this->_elem -= c;}
1663 void isub(
const cytnx_bool &c){this->_elem -= c;}
1665 void imul(
const Scalar_base* c){this->_elem *= c->to_cytnx_bool();}
1666 void imul(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1667 void imul(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1668 void imul(
const cytnx_double &c){this->_elem *= c;}
1669 void imul(
const cytnx_float &c){this->_elem *= c;}
1670 void imul(
const cytnx_uint64 &c){this->_elem *= c;}
1671 void imul(
const cytnx_int64 &c){this->_elem *= c;}
1672 void imul(
const cytnx_uint32 &c){this->_elem *= c;}
1673 void imul(
const cytnx_int32 &c){this->_elem *= c;}
1674 void imul(
const cytnx_uint16 &c){this->_elem *= c;}
1675 void imul(
const cytnx_int16 &c){this->_elem *= c;}
1676 void imul(
const cytnx_bool &c){this->_elem *= c;}
1679 void idiv(
const Scalar_base* c){this->_elem /= c->to_cytnx_bool();}
1680 void idiv(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1681 void idiv(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");}
1682 void idiv(
const cytnx_double &c){this->_elem /= c;}
1683 void idiv(
const cytnx_float &c){this->_elem /= c;}
1684 void idiv(
const cytnx_uint64 &c){this->_elem /= c;}
1685 void idiv(
const cytnx_int64 &c){this->_elem /= c;}
1686 void idiv(
const cytnx_uint32 &c){this->_elem /= c;}
1687 void idiv(
const cytnx_int32 &c){this->_elem /= c;}
1688 void idiv(
const cytnx_uint16 &c){this->_elem /= c;}
1689 void idiv(
const cytnx_int16 &c){this->_elem /= c;}
1690 void idiv(
const cytnx_bool &c){this->_elem /= c;}
1692 void iabs(){this->_elem=std::abs(this->_elem);}
1693 void isqrt(){this->_elem=std::sqrt(this->_elem);}
1695 bool less(
const Scalar_base* c){
return this->_elem < c->to_cytnx_bool();}
1696 bool less(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1697 bool less(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1698 bool less(
const cytnx_double &c){
return this->_elem < c;}
1699 bool less(
const cytnx_float &c){
return this->_elem < c;}
1700 bool less(
const cytnx_uint64 &c){
return this->_elem < c;}
1701 bool less(
const cytnx_int64 &c){
return this->_elem < c;}
1702 bool less(
const cytnx_uint32 &c){
return this->_elem < c;}
1703 bool less(
const cytnx_int32 &c){
return this->_elem < c;}
1704 bool less(
const cytnx_uint16 &c){
return this->_elem < c;}
1705 bool less(
const cytnx_int16 &c){
return this->_elem < c;}
1706 bool less(
const cytnx_bool &c){
return this->_elem < c;}
1708 bool greater(
const Scalar_base* c){
return this->_elem > c->to_cytnx_bool();}
1709 bool greater(
const cytnx_complex128 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1710 bool greater(
const cytnx_complex64 &c){
cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
return 0;}
1711 bool greater(
const cytnx_double &c){
return this->_elem > c;}
1712 bool greater(
const cytnx_float &c){
return this->_elem > c;}
1713 bool greater(
const cytnx_uint64 &c){
return this->_elem > c;}
1714 bool greater(
const cytnx_int64 &c){
return this->_elem > c;}
1715 bool greater(
const cytnx_uint32 &c){
return this->_elem > c;}
1716 bool greater(
const cytnx_int32 &c){
return this->_elem > c;}
1717 bool greater(
const cytnx_uint16 &c){
return this->_elem > c;}
1718 bool greater(
const cytnx_int16 &c){
return this->_elem > c;}
1719 bool greater(
const cytnx_bool &c){
return this->_elem > c;}
1722 bool eq(
const Scalar_base* c){
return this->_elem == c->to_cytnx_bool();}
1724 void conj_(){
return;}
1725 Scalar_base* get_real(){
return this->copy();}
1726 Scalar_base* get_imag(){
cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
return nullptr;}
1728 void set_maxval(){this->_elem =
true;}
1729 void set_minval(){this->_elem =
false;}
1732 void* get_raw_address()
const{
return (
void*)(&this->_elem);}
1733 Scalar_base* astype(
const unsigned int &dtype){
1734 Scalar_base *tmp =
__ScII.UScIInit[dtype]();
1735 tmp->assign_selftype(this->_elem);
1738 Scalar_base* copy()
const{
1739 BoolScalar *tmp =
new BoolScalar(this->_elem);
1742 void print(std::ostream& os)
const{
1743 os <<
"< " << this->_elem <<
" >";
1756 boost::intrusive_ptr<Storage_base> _insimpl;
1759 Sproxy(boost::intrusive_ptr<Storage_base> _ptr,
const cytnx_uint64 &idx) : _insimpl(_ptr), _loc(idx){}
1762 const Sproxy& operator=(
const Scalar &rc);
1773 const Sproxy& operator=(
const cytnx_bool &rc);
1775 const Sproxy& operator=(
const Sproxy &rc);
1792 this->Init_by_number(in);
1795 this->Init_by_number(in);
1798 this->Init_by_number(in);
1801 this->Init_by_number(in);
1804 this->Init_by_number(in);
1807 this->Init_by_number(in);
1810 this->Init_by_number(in);
1813 this->Init_by_number(in);
1816 this->Init_by_number(in);
1819 this->Init_by_number(in);
1822 this->Init_by_number(in);
1828 out.
_impl->set_maxval();
1833 out.
_impl->set_minval();
1841 if(this->_impl!=
nullptr)
delete this->
_impl;
1843 this->_impl->assign_selftype(in);
1847 Scalar(
const Sproxy &prox);
1858 if(this->_impl!=
nullptr)
delete this->
_impl;
1859 this->_impl =
new ComplexDoubleScalar(in);
1862 if(this->_impl!=
nullptr)
delete this->
_impl;
1863 this->_impl =
new ComplexFloatScalar(in);
1866 if(this->_impl!=
nullptr)
delete this->
_impl;
1867 this->_impl =
new DoubleScalar(in);
1870 if(this->_impl!=
nullptr)
delete this->
_impl;
1871 this->_impl =
new FloatScalar(in);
1874 if(this->_impl!=
nullptr)
delete this->
_impl;
1875 this->_impl =
new Int64Scalar(in);
1878 if(this->_impl!=
nullptr)
delete this->
_impl;
1879 this->_impl =
new Uint64Scalar(in);
1882 if(this->_impl!=
nullptr)
delete this->
_impl;
1883 this->_impl =
new Int32Scalar(in);
1886 if(this->_impl!=
nullptr)
delete this->
_impl;
1887 this->_impl =
new Uint32Scalar(in);
1890 if(this->_impl!=
nullptr)
delete this->
_impl;
1891 this->_impl =
new Int16Scalar(in);
1894 if(this->_impl!=
nullptr)
delete this->
_impl;
1895 this->_impl =
new Uint16Scalar(in);
1898 if(this->_impl!=
nullptr)
delete this->
_impl;
1899 this->_impl =
new BoolScalar(in);
1906 if(this->_impl!=
nullptr)
1909 this->_impl = rhs.
_impl->copy();
1914 if(this->_impl!=
nullptr)
1917 this->_impl = rhs.
_impl->copy();
1924 this->Init_by_number(rhs);
1928 this->Init_by_number(rhs);
1932 this->Init_by_number(rhs);
1936 this->Init_by_number(rhs);
1940 this->Init_by_number(rhs);
1944 this->Init_by_number(rhs);
1948 this->Init_by_number(rhs);
1952 this->Init_by_number(rhs);
1956 this->Init_by_number(rhs);
1960 this->Init_by_number(rhs);
1964 this->Init_by_number(rhs);
1988 return this->_impl->_dtype;
1993 this->_impl->print(std::cout);
1994 std::cout << std::string(
" Scalar dtype: [") <<
Type.getname(this->_impl->_dtype) << std::string(
"]") << std::endl;
1999 return this->_impl->to_cytnx_double();
2002 return this->_impl->to_cytnx_float();
2005 return this->_impl->to_cytnx_uint64();
2008 return this->_impl->to_cytnx_int64();
2011 return this->_impl->to_cytnx_uint32();
2014 return this->_impl->to_cytnx_int32();
2017 return this->_impl->to_cytnx_uint16();
2020 return this->_impl->to_cytnx_int16();
2023 return this->_impl->to_cytnx_bool();
2026 if(this->_impl!=
nullptr)
2033 this->_impl->iadd(rc);
2036 this->_impl->iadd(rhs.
_impl);
2040 this->_impl->isub(rc);
2043 this->_impl->isub(rhs.
_impl);
2047 this->_impl->imul(rc);
2050 this->_impl->imul(rhs.
_impl);
2054 this->_impl->idiv(rc);
2057 this->_impl->idiv(rhs.
_impl);
2062 this->_impl->iabs();
2066 this->_impl->isqrt();
2086 int rid =
Type.cy_typeid(rc);
2087 if( rid < this->
dtype()){
2089 return tmp.
_impl->less(rc);
2091 return this->_impl->less(rc);
2096 if(rhs.
dtype() < this->dtype()){
2100 return this->_impl->less(rhs.
_impl);
2108 int rid =
Type.cy_typeid(rc);
2109 if( rid < this->
dtype()){
2111 return !(tmp.
_impl->greater(rc));
2113 return !(this->_impl->greater(rc));
2118 if(rhs.
dtype() < this->dtype()){
2122 return !(this->_impl->greater(rhs.
_impl));
2131 int rid =
Type.cy_typeid(rc);
2132 if( rid < this->
dtype()){
2134 return tmp.
_impl->greater(rc);
2136 return this->_impl->greater(rc);
2141 if(rhs.
dtype() < this->dtype()){
2145 return this->_impl->greater(rhs.
_impl);
2153 int rid =
Type.cy_typeid(rc);
2154 if( rid < this->
dtype()){
2156 return !(tmp.
_impl->less(rc));
2158 return !(this->_impl->less(rc));
2163 if(rhs.
dtype() < this->dtype()){
2167 return !(this->_impl->less(rhs.
_impl));
2175 int rid =
Type.cy_typeid(rc);
2176 if( this->
dtype() < rid){
2181 out.
_impl->iadd(rc);
2199 int rid =
Type.cy_typeid(rc);
2200 if( this->
dtype() < rid){
2205 out.
_impl->imul(rc);
2223 int rid =
Type.cy_typeid(rc);
2224 if( this->
dtype() < rid){
2229 out.
_impl->isub(rc);
2247 int rid =
Type.cy_typeid(rc);
2248 if( this->
dtype() < rid){
2253 out.
_impl->idiv(rc);
2316 Scalar
operator+(
const Scalar &lc,
const Scalar &rs);
2320 Scalar
operator*(
const Scalar &lc,
const Scalar &rs);
2323 Scalar
operator-(
const Scalar &lc,
const Scalar &rs);
2326 Scalar
operator/(
const Scalar &lc,
const Scalar &rs);
2330 bool operator<(
const Scalar &lc,
const Scalar &rs);
2334 bool operator>(
const Scalar &lc,
const Scalar &rs);
2338 bool operator<=(
const Scalar &lc,
const Scalar &rs);
2341 bool operator>=(
const Scalar &lc,
const Scalar &rs);
2344 bool operator==(
const Scalar &lc,
const Scalar &rs);
2348 Scalar
abs(
const Scalar &c);
2349 Scalar
sqrt(
const Scalar &c);
2357 std::ostream&
operator<<(std::ostream& os,
const Scalar &in);
Definition Scalar.hpp:1751
void operator-=(const T &rc)
Definition Scalar.hpp:2039
Scalar & operator=(const Scalar &rhs)
Definition Scalar.hpp:1913
bool less(const Scalar &rhs) const
Definition Scalar.hpp:2094
Scalar_base * _impl
Definition Scalar.hpp:1786
bool leq(const T &rc) const
Definition Scalar.hpp:2106
Scalar(const cytnx_int64 &in)
Definition Scalar.hpp:1806
Scalar & operator=(const cytnx_bool &rhs)
Definition Scalar.hpp:1963
Scalar(const cytnx_double &in)
Definition Scalar.hpp:1797
Scalar(const T &in, const unsigned int &dtype)
Definition Scalar.hpp:1840
Scalar & operator=(const cytnx_float &rhs)
Definition Scalar.hpp:1935
~Scalar()
Definition Scalar.hpp:2025
Scalar(const cytnx_int16 &in)
Definition Scalar.hpp:1818
Scalar rmul(const T &rc) const
Definition Scalar.hpp:2197
static Scalar minval(const unsigned int &dtype)
Definition Scalar.hpp:1831
Scalar & operator=(const cytnx_uint16 &rhs)
Definition Scalar.hpp:1955
void operator+=(const T &rc)
Definition Scalar.hpp:2032
static Scalar maxval(const unsigned int &dtype)
Definition Scalar.hpp:1826
Scalar & operator=(const cytnx_int64 &rhs)
Definition Scalar.hpp:1943
Scalar()
Definition Scalar.hpp:1788
Scalar rsub(const T &rc) const
Definition Scalar.hpp:2221
Scalar(const cytnx_int32 &in)
Definition Scalar.hpp:1812
Scalar & operator=(const cytnx_int16 &rhs)
Definition Scalar.hpp:1959
Scalar(const cytnx_uint32 &in)
Definition Scalar.hpp:1809
bool less(const T &rc) const
Definition Scalar.hpp:2084
Scalar(const cytnx_uint16 &in)
Definition Scalar.hpp:1815
Scalar & operator=(const cytnx_uint64 &rhs)
Definition Scalar.hpp:1939
Scalar real() const
Definition Scalar.hpp:1981
int dtype() const
Definition Scalar.hpp:1987
void operator/=(const T &rc)
Definition Scalar.hpp:2053
Scalar(const cytnx_float &in)
Definition Scalar.hpp:1800
Scalar & operator=(const cytnx_double &rhs)
Definition Scalar.hpp:1931
Scalar sqrt() const
Definition Scalar.hpp:2075
Scalar(const cytnx_complex64 &in)
Definition Scalar.hpp:1794
void operator*=(const T &rc)
Definition Scalar.hpp:2046
bool geq(const Scalar &rhs) const
Definition Scalar.hpp:2161
Scalar & operator=(const cytnx_int32 &rhs)
Definition Scalar.hpp:1951
Scalar(Scalar_base *in)
Definition Scalar.hpp:1851
bool greater(const T &rc) const
Definition Scalar.hpp:2129
Scalar(const cytnx_uint64 &in)
Definition Scalar.hpp:1803
Scalar conj() const
Definition Scalar.hpp:1974
void operator-=(const Scalar &rhs)
Definition Scalar.hpp:2042
Scalar imag() const
Definition Scalar.hpp:1980
bool leq(const Scalar &rhs) const
Definition Scalar.hpp:2116
void iabs()
Definition Scalar.hpp:2061
Scalar abs() const
Definition Scalar.hpp:2069
Scalar rdiv(const T &rc) const
Definition Scalar.hpp:2245
void print() const
Definition Scalar.hpp:1992
bool greater(const Scalar &rhs) const
Definition Scalar.hpp:2139
bool geq(const T &rc) const
Definition Scalar.hpp:2151
void isqrt()
Definition Scalar.hpp:2065
Scalar rmul(const Scalar &rhs) const
Definition Scalar.hpp:2208
Scalar & operator=(const cytnx_uint32 &rhs)
Definition Scalar.hpp:1947
Scalar & operator=(const cytnx_complex128 &rhs)
Definition Scalar.hpp:1923
Scalar(const cytnx_bool &in)
Definition Scalar.hpp:1821
Scalar rdiv(const Scalar &rhs) const
Definition Scalar.hpp:2256
Scalar(const Scalar &rhs)
Definition Scalar.hpp:1905
void operator+=(const Scalar &rhs)
Definition Scalar.hpp:2035
void operator*=(const Scalar &rhs)
Definition Scalar.hpp:2049
void operator/=(const Scalar &rhs)
Definition Scalar.hpp:2056
Scalar(const cytnx_complex128 &in)
Definition Scalar.hpp:1791
Scalar & operator=(const cytnx_complex64 &rhs)
Definition Scalar.hpp:1927
Scalar rsub(const Scalar &rhs) const
Definition Scalar.hpp:2232
Scalar radd(const Scalar &rhs) const
Definition Scalar.hpp:2184
Scalar radd(const T &rc) const
Definition Scalar.hpp:2173
Scalar astype(const unsigned int &dtype) const
Definition Scalar.hpp:1969
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:18
Definition Accessor.hpp:12
cytnx_complex128 complex128(const Scalar &in)
Definition Scalar.cpp:6
cytnx::UniTensor operator*(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
bool operator<=(const Scalar &lc, const Scalar &rs)
Definition Scalar.cpp:43
double cytnx_double
Definition Type.hpp:20
uint32_t cytnx_uint32
Definition Type.hpp:23
bool cytnx_bool
Definition Type.hpp:31
std::complex< double > cytnx_complex128
Definition Type.hpp:30
float cytnx_float
Definition Type.hpp:21
std::ostream & operator<<(std::ostream &os, const Scalar &in)
Definition Scalar.cpp:14
int16_t cytnx_int16
Definition Type.hpp:27
Scalar abs(const Scalar &c)
Definition Scalar.cpp:60
std::complex< float > cytnx_complex64
Definition Type.hpp:29
cytnx::UniTensor operator-(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
int32_t cytnx_int32
Definition Type.hpp:26
Tensor operator==(const Tensor &Lt, const Tensor &Rt)
uint16_t cytnx_uint16
Definition Type.hpp:24
uint64_t cytnx_uint64
Definition Type.hpp:22
cytnx_complex64 complex64(const Scalar &in)
Definition Scalar.cpp:10
int64_t cytnx_int64
Definition Type.hpp:25
Type_class Type
Definition Type.cpp:143
Scalar sqrt(const Scalar &c)
Definition Scalar.cpp:62
cytnx::UniTensor operator+(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
bool operator>(const Scalar &lc, const Scalar &rs)
Definition Scalar.cpp:40
Scalar_init_interface __ScII
Definition Scalar.cpp:201
cytnx::UniTensor operator/(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
bool operator>=(const Scalar &lc, const Scalar &rs)
Definition Scalar.cpp:46
bool operator<(const Scalar &lc, const Scalar &rs)
Definition Scalar.cpp:36