9#include <initializer_list>
29 Scalar_base() : _dtype(
Type.Void){};
32 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
36 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
40 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
44 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
48 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
52 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
56 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
60 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
64 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
68 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
72 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot cast to anytype!!%s",
"\n");
76 virtual void iadd(
const Scalar_base *c) {
77 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
79 virtual void iadd(
const cytnx_complex128 &c) {
80 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
82 virtual void iadd(
const cytnx_complex64 &c) {
83 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
85 virtual void iadd(
const cytnx_double &c) {
86 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
88 virtual void iadd(
const cytnx_float &c) {
89 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
91 virtual void iadd(
const cytnx_uint64 &c) {
92 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
94 virtual void iadd(
const cytnx_int64 &c) {
95 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
97 virtual void iadd(
const cytnx_uint32 &c) {
98 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
100 virtual void iadd(
const cytnx_int32 &c) {
101 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
103 virtual void iadd(
const cytnx_uint16 &c) {
104 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
106 virtual void iadd(
const cytnx_int16 &c) {
107 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
109 virtual void iadd(
const cytnx_bool &c) {
110 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
113 virtual void isub(
const Scalar_base *c) {
114 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
116 virtual void isub(
const cytnx_complex128 &c) {
117 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
119 virtual void isub(
const cytnx_complex64 &c) {
120 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
122 virtual void isub(
const cytnx_double &c) {
123 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
125 virtual void isub(
const cytnx_float &c) {
126 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
128 virtual void isub(
const cytnx_uint64 &c) {
129 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
131 virtual void isub(
const cytnx_int64 &c) {
132 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
134 virtual void isub(
const cytnx_uint32 &c) {
135 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
137 virtual void isub(
const cytnx_int32 &c) {
138 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
140 virtual void isub(
const cytnx_uint16 &c) {
141 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
143 virtual void isub(
const cytnx_int16 &c) {
144 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
146 virtual void isub(
const cytnx_bool &c) {
147 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
150 virtual void imul(
const Scalar_base *c) {
151 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
153 virtual void imul(
const cytnx_complex128 &c) {
154 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
156 virtual void imul(
const cytnx_complex64 &c) {
157 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
159 virtual void imul(
const cytnx_double &c) {
160 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
162 virtual void imul(
const cytnx_float &c) {
163 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
165 virtual void imul(
const cytnx_uint64 &c) {
166 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
168 virtual void imul(
const cytnx_int64 &c) {
169 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
171 virtual void imul(
const cytnx_uint32 &c) {
172 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
174 virtual void imul(
const cytnx_int32 &c) {
175 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
177 virtual void imul(
const cytnx_uint16 &c) {
178 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
180 virtual void imul(
const cytnx_int16 &c) {
181 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
183 virtual void imul(
const cytnx_bool &c) {
184 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
187 virtual void idiv(
const Scalar_base *c) {
188 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
190 virtual void idiv(
const cytnx_complex128 &c) {
191 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
193 virtual void idiv(
const cytnx_complex64 &c) {
194 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
196 virtual void idiv(
const cytnx_double &c) {
197 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
199 virtual void idiv(
const cytnx_float &c) {
200 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
202 virtual void idiv(
const cytnx_uint64 &c) {
203 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
205 virtual void idiv(
const cytnx_int64 &c) {
206 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
208 virtual void idiv(
const cytnx_uint32 &c) {
209 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
211 virtual void idiv(
const cytnx_int32 &c) {
212 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
214 virtual void idiv(
const cytnx_uint16 &c) {
215 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
217 virtual void idiv(
const cytnx_int16 &c) {
218 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
220 virtual void idiv(
const cytnx_bool &c) {
221 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
224 virtual bool less(
const Scalar_base *c) {
225 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
228 virtual bool less(
const cytnx_complex128 &c) {
229 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
232 virtual bool less(
const cytnx_complex64 &c) {
233 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
236 virtual bool less(
const cytnx_double &c) {
237 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
240 virtual bool less(
const cytnx_float &c) {
241 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
244 virtual bool less(
const cytnx_uint64 &c) {
245 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
248 virtual bool less(
const cytnx_int64 &c) {
249 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
252 virtual bool less(
const cytnx_uint32 &c) {
253 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
256 virtual bool less(
const cytnx_int32 &c) {
257 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
260 virtual bool less(
const cytnx_uint16 &c) {
261 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
264 virtual bool less(
const cytnx_int16 &c) {
265 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
268 virtual bool less(
const cytnx_bool &c) {
269 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
273 virtual bool greater(
const Scalar_base *c) {
274 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
277 virtual bool greater(
const cytnx_complex128 &c) {
278 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
281 virtual bool greater(
const cytnx_complex64 &c) {
282 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
285 virtual bool greater(
const cytnx_double &c) {
286 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
289 virtual bool greater(
const cytnx_float &c) {
290 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
293 virtual bool greater(
const cytnx_uint64 &c) {
294 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
297 virtual bool greater(
const cytnx_int64 &c) {
298 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
301 virtual bool greater(
const cytnx_uint32 &c) {
302 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
305 virtual bool greater(
const cytnx_int32 &c) {
306 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
309 virtual bool greater(
const cytnx_uint16 &c) {
310 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
313 virtual bool greater(
const cytnx_int16 &c) {
314 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
317 virtual bool greater(
const cytnx_bool &c) {
318 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
322 virtual bool eq(
const Scalar_base *c) {
323 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
327 virtual void set_maxval() {
328 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
330 virtual void set_minval() {
331 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
334 virtual void conj_() {
335 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
337 virtual Scalar_base *get_real() {
338 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
341 virtual Scalar_base *get_imag() {
342 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
346 virtual void iabs() {
347 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
349 virtual void isqrt() {
350 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
353 virtual void assign_selftype(
const cytnx_complex128 &c) {
354 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
356 virtual void assign_selftype(
const cytnx_complex64 &c) {
357 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
359 virtual void assign_selftype(
const cytnx_double &c) {
360 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
362 virtual void assign_selftype(
const cytnx_float &c) {
363 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
365 virtual void assign_selftype(
const cytnx_uint64 &c) {
366 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
368 virtual void assign_selftype(
const cytnx_int64 &c) {
369 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
371 virtual void assign_selftype(
const cytnx_uint32 &c) {
372 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
374 virtual void assign_selftype(
const cytnx_int32 &c) {
375 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
377 virtual void assign_selftype(
const cytnx_uint16 &c) {
378 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
380 virtual void assign_selftype(
const cytnx_int16 &c) {
381 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
383 virtual void assign_selftype(
const cytnx_bool &c) {
384 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
387 virtual Scalar_base *astype(
const unsigned int &dtype) {
388 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
392 virtual void *get_raw_address()
const {
393 cytnx_error_msg(
true,
"[ERROR] Void Type Scalar cannot have operation!!%s",
"\n");
397 virtual void print(std::ostream &os)
const {};
398 virtual Scalar_base *copy()
const {
399 Scalar_base *
tmp =
new Scalar_base();
406 typedef Scalar_base *(*pScalar_init)();
410 class Scalar_init_interface :
public Type_class {
413 inline static pScalar_init UScIInit[N_Type];
414 inline static bool inited =
false;
415 Scalar_init_interface();
417 extern Scalar_init_interface __ScII;
421 class ComplexDoubleScalar :
public Scalar_base {
425 ComplexDoubleScalar() : _elem(0) { this->_dtype =
Type.ComplexDouble; };
426 ComplexDoubleScalar(
const cytnx_complex128 &in) : _elem(0) {
427 this->_dtype =
Type.ComplexDouble;
432 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
436 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
442 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
446 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
450 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
454 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
458 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
462 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
466 cytnx_error_msg(
true,
"[ERROR] cannot cast complex128 to real%s",
"\n");
470 void assign_selftype(
const cytnx_complex128 &c) { this->_elem = c; }
471 void assign_selftype(
const cytnx_complex64 &c) { this->_elem = c; }
472 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
473 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
474 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
475 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
476 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
477 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
478 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
479 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
480 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
482 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_complex128(); }
483 void iadd(
const cytnx_complex128 &c) { this->_elem += c; }
484 void iadd(
const cytnx_complex64 &c) { this->_elem += c; }
485 void iadd(
const cytnx_double &c) { this->_elem += c; }
486 void iadd(
const cytnx_float &c) { this->_elem += c; }
487 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
488 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
489 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
490 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
491 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
492 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
493 void iadd(
const cytnx_bool &c) { this->_elem += c; }
495 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_complex128(); }
496 void isub(
const cytnx_complex128 &c) { this->_elem -= c; }
497 void isub(
const cytnx_complex64 &c) { this->_elem -= c; }
498 void isub(
const cytnx_double &c) { this->_elem -= c; }
499 void isub(
const cytnx_float &c) { this->_elem -= c; }
500 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
501 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
502 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
503 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
504 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
505 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
506 void isub(
const cytnx_bool &c) { this->_elem -= c; }
508 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_complex128(); }
509 void imul(
const cytnx_complex128 &c) { this->_elem *= c; }
510 void imul(
const cytnx_complex64 &c) { this->_elem *= c; }
511 void imul(
const cytnx_double &c) { this->_elem *= c; }
512 void imul(
const cytnx_float &c) { this->_elem *= c; }
513 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
514 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
515 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
516 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
517 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
518 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
519 void imul(
const cytnx_bool &c) { this->_elem *= c; }
521 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_complex128(); }
522 void idiv(
const cytnx_complex128 &c) { this->_elem /= c; }
523 void idiv(
const cytnx_complex64 &c) { this->_elem /= c; }
524 void idiv(
const cytnx_double &c) { this->_elem /= c; }
525 void idiv(
const cytnx_float &c) { this->_elem /= c; }
526 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
527 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
528 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
529 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
530 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
531 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
532 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
535 void isqrt() { this->_elem = std::sqrt(this->_elem); }
537 bool less(
const Scalar_base *c) {
538 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
541 bool less(
const cytnx_complex128 &c) {
542 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
545 bool less(
const cytnx_complex64 &c) {
546 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
549 bool less(
const cytnx_double &c) {
550 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
553 bool less(
const cytnx_float &c) {
554 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
557 bool less(
const cytnx_uint64 &c) {
558 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
561 bool less(
const cytnx_int64 &c) {
562 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
565 bool less(
const cytnx_uint32 &c) {
566 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
569 bool less(
const cytnx_int32 &c) {
570 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
573 bool less(
const cytnx_uint16 &c) {
574 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
577 bool less(
const cytnx_int16 &c) {
578 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
581 bool less(
const cytnx_bool &c) {
582 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
586 bool greater(
const Scalar_base *c) {
587 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
590 bool greater(
const cytnx_complex128 &c) {
591 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
594 bool greater(
const cytnx_complex64 &c) {
595 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
598 bool greater(
const cytnx_double &c) {
599 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
602 bool greater(
const cytnx_float &c) {
603 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
606 bool greater(
const cytnx_uint64 &c) {
607 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
610 bool greater(
const cytnx_int64 &c) {
611 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
614 bool greater(
const cytnx_uint32 &c) {
615 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
618 bool greater(
const cytnx_int32 &c) {
619 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
622 bool greater(
const cytnx_uint16 &c) {
623 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
626 bool greater(
const cytnx_int16 &c) {
627 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
630 bool greater(
const cytnx_bool &c) {
631 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
635 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_complex128(); }
638 cytnx_error_msg(
true,
"[ERROR] maxval not supported for complex type%s",
"\n");
641 cytnx_error_msg(
true,
"[ERROR] minval not supported for complex type%s",
"\n");
644 void conj_() { this->_elem = std::conj(this->_elem); }
645 Scalar_base *get_real() {
646 Scalar_base *
tmp = __ScII.UScIInit[
Type.Double]();
647 tmp->assign_selftype(this->_elem.real());
650 Scalar_base *get_imag() {
651 Scalar_base *
tmp = __ScII.UScIInit[
Type.Double]();
652 tmp->assign_selftype(this->_elem.imag());
656 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
658 Scalar_base *astype(
const unsigned int &dtype) {
659 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
660 tmp->assign_selftype(this->_elem);
664 Scalar_base *copy()
const {
665 ComplexDoubleScalar *
tmp =
new ComplexDoubleScalar(this->_elem);
668 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
671 class ComplexFloatScalar :
public Scalar_base {
675 ComplexFloatScalar() : _elem(0) { this->_dtype =
Type.ComplexFloat; };
676 ComplexFloatScalar(
const cytnx_complex64 &in) : _elem(0) {
677 this->_dtype =
Type.ComplexFloat;
682 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
686 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
692 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
696 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
700 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
704 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
708 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
712 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
716 cytnx_error_msg(
true,
"[ERROR] cannot cast complex64 to real%s",
"\n");
720 void assign_selftype(
const cytnx_complex128 &c) { this->_elem = c; }
721 void assign_selftype(
const cytnx_complex64 &c) { this->_elem = c; }
722 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
723 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
724 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
725 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
726 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
727 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
728 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
729 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
730 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
732 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_complex64(); }
733 void iadd(
const cytnx_complex128 &c) { this->_elem += c; }
734 void iadd(
const cytnx_complex64 &c) { this->_elem += c; }
735 void iadd(
const cytnx_double &c) { this->_elem += c; }
736 void iadd(
const cytnx_float &c) { this->_elem += c; }
737 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
738 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
739 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
740 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
741 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
742 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
743 void iadd(
const cytnx_bool &c) { this->_elem += c; }
745 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_complex64(); }
746 void isub(
const cytnx_complex128 &c) { this->_elem -= c; }
747 void isub(
const cytnx_complex64 &c) { this->_elem -= c; }
748 void isub(
const cytnx_double &c) { this->_elem -= c; }
749 void isub(
const cytnx_float &c) { this->_elem -= c; }
750 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
751 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
752 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
753 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
754 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
755 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
756 void isub(
const cytnx_bool &c) { this->_elem -= c; }
758 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_complex64(); }
759 void imul(
const cytnx_complex128 &c) { this->_elem *= c; }
760 void imul(
const cytnx_complex64 &c) { this->_elem *= c; }
761 void imul(
const cytnx_double &c) { this->_elem *= c; }
762 void imul(
const cytnx_float &c) { this->_elem *= c; }
763 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
764 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
765 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
766 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
767 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
768 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
769 void imul(
const cytnx_bool &c) { this->_elem *= c; }
771 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_complex64(); }
772 void idiv(
const cytnx_complex128 &c) { this->_elem /= c; }
773 void idiv(
const cytnx_complex64 &c) { this->_elem /= c; }
774 void idiv(
const cytnx_double &c) { this->_elem /= c; }
775 void idiv(
const cytnx_float &c) { this->_elem /= c; }
776 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
777 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
778 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
779 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
780 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
781 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
782 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
784 bool less(
const Scalar_base *c) {
785 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
788 bool less(
const cytnx_complex128 &c) {
789 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
792 bool less(
const cytnx_complex64 &c) {
793 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
796 bool less(
const cytnx_double &c) {
797 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
800 bool less(
const cytnx_float &c) {
801 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
804 bool less(
const cytnx_uint64 &c) {
805 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
808 bool less(
const cytnx_int64 &c) {
809 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
812 bool less(
const cytnx_uint32 &c) {
813 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
816 bool less(
const cytnx_int32 &c) {
817 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
820 bool less(
const cytnx_uint16 &c) {
821 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
824 bool less(
const cytnx_int16 &c) {
825 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
828 bool less(
const cytnx_bool &c) {
829 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
833 bool greater(
const Scalar_base *c) {
834 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
837 bool greater(
const cytnx_complex128 &c) {
838 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
841 bool greater(
const cytnx_complex64 &c) {
842 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
845 bool greater(
const cytnx_double &c) {
846 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
849 bool greater(
const cytnx_float &c) {
850 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
853 bool greater(
const cytnx_uint64 &c) {
854 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
857 bool greater(
const cytnx_int64 &c) {
858 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
861 bool greater(
const cytnx_uint32 &c) {
862 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
865 bool greater(
const cytnx_int32 &c) {
866 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
869 bool greater(
const cytnx_uint16 &c) {
870 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
873 bool greater(
const cytnx_int16 &c) {
874 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
877 bool greater(
const cytnx_bool &c) {
878 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
882 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_complex64(); }
885 cytnx_error_msg(
true,
"[ERROR] maxval not supported for complex type%s",
"\n");
888 cytnx_error_msg(
true,
"[ERROR] minval not supported for complex type%s",
"\n");
891 void conj_() { this->_elem = std::conj(this->_elem); }
892 Scalar_base *get_real() {
893 Scalar_base *
tmp = __ScII.UScIInit[
Type.Float]();
894 tmp->assign_selftype(this->_elem.real());
897 Scalar_base *get_imag() {
898 Scalar_base *
tmp = __ScII.UScIInit[
Type.Float]();
899 tmp->assign_selftype(this->_elem.imag());
903 void iabs() { this->_elem = std::abs(this->_elem); }
904 void isqrt() { this->_elem = std::sqrt(this->_elem); }
906 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
907 Scalar_base *astype(
const unsigned int &dtype) {
908 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
909 tmp->assign_selftype(this->_elem);
913 Scalar_base *copy()
const {
914 ComplexFloatScalar *
tmp =
new ComplexFloatScalar(this->_elem);
917 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
920 class DoubleScalar :
public Scalar_base {
924 DoubleScalar() : _elem(0) { this->_dtype =
Type.Double; };
925 DoubleScalar(
const cytnx_double &in) : _elem(0) {
926 this->_dtype =
Type.Double;
930 cytnx_float to_cytnx_float()
const {
return this->_elem; };
931 cytnx_double to_cytnx_double()
const {
return this->_elem; };
934 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
935 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
936 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
937 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
938 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
939 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
940 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
942 void assign_selftype(
const cytnx_complex128 &c) {
943 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
945 void assign_selftype(
const cytnx_complex64 &c) {
946 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
948 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
949 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
950 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
951 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
952 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
953 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
954 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
955 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
956 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
958 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_double(); }
959 void iadd(
const cytnx_complex128 &c) {
960 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
962 void iadd(
const cytnx_complex64 &c) {
963 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
965 void iadd(
const cytnx_double &c) { this->_elem += c; }
966 void iadd(
const cytnx_float &c) { this->_elem += c; }
967 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
968 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
969 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
970 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
971 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
972 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
973 void iadd(
const cytnx_bool &c) { this->_elem += c; }
975 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_double(); }
976 void isub(
const cytnx_complex128 &c) {
977 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
979 void isub(
const cytnx_complex64 &c) {
980 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
982 void isub(
const cytnx_double &c) { this->_elem -= c; }
983 void isub(
const cytnx_float &c) { this->_elem -= c; }
984 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
985 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
986 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
987 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
988 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
989 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
990 void isub(
const cytnx_bool &c) { this->_elem -= c; }
992 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_double(); }
993 void imul(
const cytnx_complex128 &c) {
994 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
996 void imul(
const cytnx_complex64 &c) {
997 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
999 void imul(
const cytnx_double &c) { this->_elem *= c; }
1000 void imul(
const cytnx_float &c) { this->_elem *= c; }
1001 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1002 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1003 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1004 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1005 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1006 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1007 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1009 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_double(); }
1010 void idiv(
const cytnx_complex128 &c) {
1011 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1013 void idiv(
const cytnx_complex64 &c) {
1014 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1016 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1017 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1018 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1019 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1020 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1021 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1022 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1023 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1024 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1026 void iabs() { this->_elem = std::abs(this->_elem); }
1027 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1029 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_double(); }
1030 bool less(
const cytnx_complex128 &c) {
1031 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1034 bool less(
const cytnx_complex64 &c) {
1035 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1038 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1039 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1040 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1041 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1042 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1043 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1044 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1045 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1046 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1048 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_double(); }
1049 bool greater(
const cytnx_complex128 &c) {
1050 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1053 bool greater(
const cytnx_complex64 &c) {
1054 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1057 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1058 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1059 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1060 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1061 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1062 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1063 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1064 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1065 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1067 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_double(); }
1069 void set_maxval() { this->_elem = std::numeric_limits<double>::max(); }
1070 void set_minval() { this->_elem = std::numeric_limits<double>::min(); }
1072 void conj_() {
return; }
1073 Scalar_base *get_real() {
return this->copy(); }
1074 Scalar_base *get_imag() {
1075 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1079 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1080 Scalar_base *astype(
const unsigned int &dtype) {
1081 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1082 tmp->assign_selftype(this->_elem);
1085 Scalar_base *copy()
const {
1086 DoubleScalar *
tmp =
new DoubleScalar(this->_elem);
1089 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1092 class FloatScalar :
public Scalar_base {
1096 FloatScalar() : _elem(0) { this->_dtype =
Type.Float; };
1097 FloatScalar(
const cytnx_float &in) : _elem(0) {
1098 this->_dtype =
Type.Float;
1102 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1103 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1106 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1107 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1108 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1109 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1110 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1111 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1112 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1114 void assign_selftype(
const cytnx_complex128 &c) {
1115 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1117 void assign_selftype(
const cytnx_complex64 &c) {
1118 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1120 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1121 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1122 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1123 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1124 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1125 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1126 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1127 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1128 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1130 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_float(); }
1131 void iadd(
const cytnx_complex128 &c) {
1132 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1134 void iadd(
const cytnx_complex64 &c) {
1135 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1137 void iadd(
const cytnx_double &c) { this->_elem += c; }
1138 void iadd(
const cytnx_float &c) { this->_elem += c; }
1139 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1140 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1141 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1142 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
1143 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
1144 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
1145 void iadd(
const cytnx_bool &c) { this->_elem += c; }
1147 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_float(); }
1148 void isub(
const cytnx_complex128 &c) {
1149 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1151 void isub(
const cytnx_complex64 &c) {
1152 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1154 void isub(
const cytnx_double &c) { this->_elem -= c; }
1155 void isub(
const cytnx_float &c) { this->_elem -= c; }
1156 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
1157 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
1158 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
1159 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
1160 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
1161 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
1162 void isub(
const cytnx_bool &c) { this->_elem -= c; }
1164 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_float(); }
1165 void imul(
const cytnx_complex128 &c) {
1166 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1168 void imul(
const cytnx_complex64 &c) {
1169 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1171 void imul(
const cytnx_double &c) { this->_elem *= c; }
1172 void imul(
const cytnx_float &c) { this->_elem *= c; }
1173 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1174 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1175 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1176 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1177 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1178 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1179 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1181 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_float(); }
1182 void idiv(
const cytnx_complex128 &c) {
1183 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1185 void idiv(
const cytnx_complex64 &c) {
1186 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1188 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1189 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1190 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1191 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1192 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1193 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1194 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1195 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1196 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1198 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_float(); }
1199 bool less(
const cytnx_complex128 &c) {
1200 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1203 bool less(
const cytnx_complex64 &c) {
1204 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1207 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1208 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1209 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1210 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1211 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1212 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1213 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1214 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1215 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1217 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_float(); }
1218 bool greater(
const cytnx_complex128 &c) {
1219 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1222 bool greater(
const cytnx_complex64 &c) {
1223 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1226 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1227 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1228 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1229 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1230 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1231 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1232 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1233 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1234 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1236 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_float(); }
1237 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1239 void conj_() {
return; }
1240 Scalar_base *get_real() {
return this->copy(); }
1241 Scalar_base *get_imag() {
1242 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1246 void set_maxval() { this->_elem = std::numeric_limits<float>::max(); }
1247 void set_minval() { this->_elem = std::numeric_limits<float>::min(); }
1249 void iabs() { this->_elem = std::abs(this->_elem); }
1251 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1252 Scalar_base *astype(
const unsigned int &dtype) {
1253 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1254 tmp->assign_selftype(this->_elem);
1257 Scalar_base *copy()
const {
1258 FloatScalar *
tmp =
new FloatScalar(this->_elem);
1261 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1264 class Int64Scalar :
public Scalar_base {
1268 Int64Scalar() : _elem(0) { this->_dtype =
Type.Int64; };
1269 Int64Scalar(
const cytnx_int64 &in) : _elem(0) {
1270 this->_dtype =
Type.Int64;
1274 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1275 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1278 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1279 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1280 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1281 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1282 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1283 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1284 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1286 void assign_selftype(
const cytnx_complex128 &c) {
1287 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1289 void assign_selftype(
const cytnx_complex64 &c) {
1290 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1292 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1293 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1294 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1295 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1296 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1297 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1298 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1299 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1300 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1302 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_int64(); }
1303 void iadd(
const cytnx_complex128 &c) {
1304 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1306 void iadd(
const cytnx_complex64 &c) {
1307 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1309 void iadd(
const cytnx_double &c) { this->_elem += c; }
1310 void iadd(
const cytnx_float &c) { this->_elem += c; }
1311 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1312 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1313 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1314 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
1315 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
1316 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
1317 void iadd(
const cytnx_bool &c) { this->_elem += c; }
1319 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_int64(); }
1320 void isub(
const cytnx_complex128 &c) {
1321 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1323 void isub(
const cytnx_complex64 &c) {
1324 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1326 void isub(
const cytnx_double &c) { this->_elem -= c; }
1327 void isub(
const cytnx_float &c) { this->_elem -= c; }
1328 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
1329 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
1330 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
1331 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
1332 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
1333 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
1334 void isub(
const cytnx_bool &c) { this->_elem -= c; }
1336 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_int64(); }
1337 void imul(
const cytnx_complex128 &c) {
1338 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1340 void imul(
const cytnx_complex64 &c) {
1341 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1343 void imul(
const cytnx_double &c) { this->_elem *= c; }
1344 void imul(
const cytnx_float &c) { this->_elem *= c; }
1345 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1346 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1347 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1348 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1349 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1350 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1351 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1353 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_int64(); }
1354 void idiv(
const cytnx_complex128 &c) {
1355 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1357 void idiv(
const cytnx_complex64 &c) {
1358 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1360 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1361 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1362 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1363 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1364 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1365 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1366 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1367 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1368 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1370 void iabs() { this->_elem = std::abs(this->_elem); }
1371 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1373 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_int64(); }
1374 bool less(
const cytnx_complex128 &c) {
1375 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1378 bool less(
const cytnx_complex64 &c) {
1379 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1382 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1383 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1384 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1385 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1386 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1387 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1388 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1389 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1390 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1392 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_int64(); }
1393 bool greater(
const cytnx_complex128 &c) {
1394 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1397 bool greater(
const cytnx_complex64 &c) {
1398 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1401 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1402 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1403 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1404 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1405 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1406 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1407 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1408 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1409 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1411 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_int64(); }
1413 void conj_() {
return; }
1414 Scalar_base *get_real() {
return this->copy(); }
1415 Scalar_base *get_imag() {
1416 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1420 void set_maxval() { this->_elem = std::numeric_limits<cytnx_int64>::max(); }
1421 void set_minval() { this->_elem = std::numeric_limits<cytnx_int64>::min(); }
1423 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1424 Scalar_base *astype(
const unsigned int &dtype) {
1425 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1426 tmp->assign_selftype(this->_elem);
1429 Scalar_base *copy()
const {
1430 Int64Scalar *
tmp =
new Int64Scalar(this->_elem);
1433 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1435 class Uint64Scalar :
public Scalar_base {
1439 Uint64Scalar() : _elem(0) { this->_dtype =
Type.Uint64; };
1440 Uint64Scalar(
const cytnx_uint64 &in) : _elem(0) {
1441 this->_dtype =
Type.Uint64;
1445 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1446 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1449 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1450 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1451 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1452 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1453 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1454 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1455 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1457 void assign_selftype(
const cytnx_complex128 &c) {
1458 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1460 void assign_selftype(
const cytnx_complex64 &c) {
1461 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1463 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1464 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1465 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1466 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1467 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1468 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1469 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1470 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1471 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1473 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_uint64(); }
1474 void iadd(
const cytnx_complex128 &c) {
1475 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1477 void iadd(
const cytnx_complex64 &c) {
1478 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1480 void iadd(
const cytnx_double &c) { this->_elem += c; }
1481 void iadd(
const cytnx_float &c) { this->_elem += c; }
1482 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1483 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1484 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1485 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
1486 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
1487 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
1488 void iadd(
const cytnx_bool &c) { this->_elem += c; }
1490 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_uint64(); }
1491 void isub(
const cytnx_complex128 &c) {
1492 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1494 void isub(
const cytnx_complex64 &c) {
1495 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1497 void isub(
const cytnx_double &c) { this->_elem -= c; }
1498 void isub(
const cytnx_float &c) { this->_elem -= c; }
1499 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
1500 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
1501 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
1502 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
1503 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
1504 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
1505 void isub(
const cytnx_bool &c) { this->_elem -= c; }
1507 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_uint64(); }
1508 void imul(
const cytnx_complex128 &c) {
1509 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1511 void imul(
const cytnx_complex64 &c) {
1512 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1514 void imul(
const cytnx_double &c) { this->_elem *= c; }
1515 void imul(
const cytnx_float &c) { this->_elem *= c; }
1516 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1517 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1518 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1519 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1520 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1521 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1522 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1524 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_uint64(); }
1525 void idiv(
const cytnx_complex128 &c) {
1526 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1528 void idiv(
const cytnx_complex64 &c) {
1529 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1531 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1532 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1533 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1534 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1535 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1536 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1537 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1538 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1539 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1541 void iabs() { this->_elem = std::abs(
cytnx_double(this->_elem)); }
1542 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1544 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_uint64(); }
1545 bool less(
const cytnx_complex128 &c) {
1546 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1549 bool less(
const cytnx_complex64 &c) {
1550 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1553 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1554 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1555 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1556 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1557 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1558 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1559 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1560 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1561 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1563 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_uint64(); }
1564 bool greater(
const cytnx_complex128 &c) {
1565 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1568 bool greater(
const cytnx_complex64 &c) {
1569 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1572 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1573 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1574 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1575 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1576 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1577 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1578 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1579 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1580 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1582 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_uint64(); }
1584 void conj_() {
return; }
1585 Scalar_base *get_real() {
return this->copy(); }
1586 Scalar_base *get_imag() {
1587 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1591 void set_maxval() { this->_elem = std::numeric_limits<cytnx_uint64>::max(); }
1592 void set_minval() { this->_elem = std::numeric_limits<cytnx_uint64>::min(); }
1594 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1595 Scalar_base *astype(
const unsigned int &dtype) {
1596 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1597 tmp->assign_selftype(this->_elem);
1600 Scalar_base *copy()
const {
1601 Uint64Scalar *
tmp =
new Uint64Scalar(this->_elem);
1604 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1606 class Int32Scalar :
public Scalar_base {
1610 Int32Scalar() : _elem(0) { this->_dtype =
Type.Int32; };
1611 Int32Scalar(
const cytnx_int32 &in) : _elem(0) {
1612 this->_dtype =
Type.Int32;
1616 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1617 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1620 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1621 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1622 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1623 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1624 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1625 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1626 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1628 void assign_selftype(
const cytnx_complex128 &c) {
1629 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1631 void assign_selftype(
const cytnx_complex64 &c) {
1632 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1634 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1635 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1636 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1637 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1638 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1639 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1640 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1641 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1642 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1644 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_int32(); }
1645 void iadd(
const cytnx_complex128 &c) {
1646 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1648 void iadd(
const cytnx_complex64 &c) {
1649 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1651 void iadd(
const cytnx_double &c) { this->_elem += c; }
1652 void iadd(
const cytnx_float &c) { this->_elem += c; }
1653 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1654 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1655 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1656 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
1657 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
1658 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
1659 void iadd(
const cytnx_bool &c) { this->_elem += c; }
1661 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_int32(); }
1662 void isub(
const cytnx_complex128 &c) {
1663 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1665 void isub(
const cytnx_complex64 &c) {
1666 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1668 void isub(
const cytnx_double &c) { this->_elem -= c; }
1669 void isub(
const cytnx_float &c) { this->_elem -= c; }
1670 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
1671 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
1672 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
1673 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
1674 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
1675 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
1676 void isub(
const cytnx_bool &c) { this->_elem -= c; }
1678 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_int32(); }
1679 void imul(
const cytnx_complex128 &c) {
1680 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1682 void imul(
const cytnx_complex64 &c) {
1683 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1685 void imul(
const cytnx_double &c) { this->_elem *= c; }
1686 void imul(
const cytnx_float &c) { this->_elem *= c; }
1687 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1688 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1689 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1690 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1691 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1692 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1693 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1695 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_int32(); }
1696 void idiv(
const cytnx_complex128 &c) {
1697 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1699 void idiv(
const cytnx_complex64 &c) {
1700 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1702 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1703 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1704 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1705 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1706 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1707 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1708 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1709 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1710 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1712 void iabs() { this->_elem = std::abs(this->_elem); }
1713 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1715 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_int32(); }
1716 bool less(
const cytnx_complex128 &c) {
1717 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1720 bool less(
const cytnx_complex64 &c) {
1721 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1724 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1725 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1726 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1727 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1728 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1729 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1730 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1731 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1732 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1734 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_int32(); }
1735 bool greater(
const cytnx_complex128 &c) {
1736 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1739 bool greater(
const cytnx_complex64 &c) {
1740 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1743 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1744 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1745 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1746 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1747 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1748 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1749 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1750 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1751 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1753 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_int32(); }
1755 void conj_() {
return; }
1756 Scalar_base *get_real() {
return this->copy(); }
1757 Scalar_base *get_imag() {
1758 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1762 void set_maxval() { this->_elem = std::numeric_limits<cytnx_int32>::max(); }
1763 void set_minval() { this->_elem = std::numeric_limits<cytnx_int32>::min(); }
1765 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1767 Scalar_base *astype(
const unsigned int &dtype) {
1768 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1769 tmp->assign_selftype(this->_elem);
1772 Scalar_base *copy()
const {
1773 Int32Scalar *
tmp =
new Int32Scalar(this->_elem);
1776 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1778 class Uint32Scalar :
public Scalar_base {
1782 Uint32Scalar() : _elem(0) { this->_dtype =
Type.Uint32; };
1783 Uint32Scalar(
const cytnx_uint32 &in) : _elem(0) {
1784 this->_dtype =
Type.Uint32;
1788 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1789 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1792 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1793 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1794 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1795 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1796 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1797 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1798 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1800 void assign_selftype(
const cytnx_complex128 &c) {
1801 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1803 void assign_selftype(
const cytnx_complex64 &c) {
1804 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1806 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1807 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1808 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1809 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1810 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1811 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1812 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1813 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1814 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1816 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_uint32(); }
1817 void iadd(
const cytnx_complex128 &c) {
1818 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1820 void iadd(
const cytnx_complex64 &c) {
1821 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1823 void iadd(
const cytnx_double &c) { this->_elem += c; }
1824 void iadd(
const cytnx_float &c) { this->_elem += c; }
1825 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1826 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1827 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1828 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
1829 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
1830 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
1831 void iadd(
const cytnx_bool &c) { this->_elem += c; }
1833 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_uint32(); }
1834 void isub(
const cytnx_complex128 &c) {
1835 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1837 void isub(
const cytnx_complex64 &c) {
1838 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1840 void isub(
const cytnx_double &c) { this->_elem -= c; }
1841 void isub(
const cytnx_float &c) { this->_elem -= c; }
1842 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
1843 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
1844 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
1845 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
1846 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
1847 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
1848 void isub(
const cytnx_bool &c) { this->_elem -= c; }
1850 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_uint32(); }
1851 void imul(
const cytnx_complex128 &c) {
1852 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1854 void imul(
const cytnx_complex64 &c) {
1855 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1857 void imul(
const cytnx_double &c) { this->_elem *= c; }
1858 void imul(
const cytnx_float &c) { this->_elem *= c; }
1859 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
1860 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
1861 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
1862 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
1863 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
1864 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
1865 void imul(
const cytnx_bool &c) { this->_elem *= c; }
1867 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_uint32(); }
1868 void idiv(
const cytnx_complex128 &c) {
1869 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1871 void idiv(
const cytnx_complex64 &c) {
1872 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1874 void idiv(
const cytnx_double &c) { this->_elem /= c; }
1875 void idiv(
const cytnx_float &c) { this->_elem /= c; }
1876 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
1877 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
1878 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
1879 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
1880 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
1881 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
1882 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
1884 void iabs() { this->_elem = std::abs(
cytnx_double(this->_elem)); }
1885 void isqrt() { this->_elem = std::sqrt(this->_elem); }
1887 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_uint32(); }
1888 bool less(
const cytnx_complex128 &c) {
1889 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1892 bool less(
const cytnx_complex64 &c) {
1893 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1896 bool less(
const cytnx_double &c) {
return this->_elem < c; }
1897 bool less(
const cytnx_float &c) {
return this->_elem < c; }
1898 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
1899 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
1900 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
1901 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
1902 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
1903 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
1904 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
1906 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_uint32(); }
1907 bool greater(
const cytnx_complex128 &c) {
1908 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1911 bool greater(
const cytnx_complex64 &c) {
1912 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
1915 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
1916 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
1917 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
1918 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
1919 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
1920 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
1921 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
1922 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
1923 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
1925 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_uint32(); }
1927 void conj_() {
return; }
1928 Scalar_base *get_real() {
return this->copy(); }
1929 Scalar_base *get_imag() {
1930 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
1934 void set_maxval() { this->_elem = std::numeric_limits<cytnx_uint32>::max(); }
1935 void set_minval() { this->_elem = std::numeric_limits<cytnx_uint32>::min(); }
1937 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
1938 Scalar_base *astype(
const unsigned int &dtype) {
1939 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
1940 tmp->assign_selftype(this->_elem);
1943 Scalar_base *copy()
const {
1944 Uint32Scalar *
tmp =
new Uint32Scalar(this->_elem);
1947 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
1949 class Int16Scalar :
public Scalar_base {
1953 Int16Scalar() : _elem(0) { this->_dtype =
Type.Int16; };
1954 Int16Scalar(
const cytnx_int16 &in) : _elem(0) {
1955 this->_dtype =
Type.Int16;
1959 cytnx_float to_cytnx_float()
const {
return this->_elem; };
1960 cytnx_double to_cytnx_double()
const {
return this->_elem; };
1963 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
1964 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
1965 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
1966 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
1967 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
1968 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
1969 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
1971 void assign_selftype(
const cytnx_complex128 &c) {
1972 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1974 void assign_selftype(
const cytnx_complex64 &c) {
1975 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
1977 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
1978 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
1979 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
1980 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
1981 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
1982 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
1983 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
1984 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
1985 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
1987 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_int16(); }
1988 void iadd(
const cytnx_complex128 &c) {
1989 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1991 void iadd(
const cytnx_complex64 &c) {
1992 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
1994 void iadd(
const cytnx_double &c) { this->_elem += c; }
1995 void iadd(
const cytnx_float &c) { this->_elem += c; }
1996 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
1997 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
1998 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
1999 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
2000 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
2001 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
2002 void iadd(
const cytnx_bool &c) { this->_elem += c; }
2004 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_int16(); }
2005 void isub(
const cytnx_complex128 &c) {
2006 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2008 void isub(
const cytnx_complex64 &c) {
2009 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2011 void isub(
const cytnx_double &c) { this->_elem -= c; }
2012 void isub(
const cytnx_float &c) { this->_elem -= c; }
2013 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
2014 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
2015 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
2016 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
2017 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
2018 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
2019 void isub(
const cytnx_bool &c) { this->_elem -= c; }
2021 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_int16(); }
2022 void imul(
const cytnx_complex128 &c) {
2023 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2025 void imul(
const cytnx_complex64 &c) {
2026 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2028 void imul(
const cytnx_double &c) { this->_elem *= c; }
2029 void imul(
const cytnx_float &c) { this->_elem *= c; }
2030 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
2031 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
2032 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
2033 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
2034 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
2035 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
2036 void imul(
const cytnx_bool &c) { this->_elem *= c; }
2038 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_int16(); }
2039 void idiv(
const cytnx_complex128 &c) {
2040 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2042 void idiv(
const cytnx_complex64 &c) {
2043 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2045 void idiv(
const cytnx_double &c) { this->_elem /= c; }
2046 void idiv(
const cytnx_float &c) { this->_elem /= c; }
2047 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
2048 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
2049 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
2050 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
2051 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
2052 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
2053 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
2055 void iabs() { this->_elem = std::abs(this->_elem); }
2056 void isqrt() { this->_elem = std::sqrt(this->_elem); }
2058 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_int16(); }
2059 bool less(
const cytnx_complex128 &c) {
2060 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2063 bool less(
const cytnx_complex64 &c) {
2064 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2067 bool less(
const cytnx_double &c) {
return this->_elem < c; }
2068 bool less(
const cytnx_float &c) {
return this->_elem < c; }
2069 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
2070 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
2071 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
2072 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
2073 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
2074 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
2075 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
2077 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_int16(); }
2078 bool greater(
const cytnx_complex128 &c) {
2079 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2082 bool greater(
const cytnx_complex64 &c) {
2083 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2086 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
2087 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
2088 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
2089 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
2090 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
2091 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
2092 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
2093 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
2094 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
2096 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_int16(); }
2098 void conj_() {
return; }
2099 Scalar_base *get_real() {
return this->copy(); }
2100 Scalar_base *get_imag() {
2101 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
2105 void set_maxval() { this->_elem = std::numeric_limits<cytnx_int16>::max(); }
2106 void set_minval() { this->_elem = std::numeric_limits<cytnx_int16>::min(); }
2108 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
2109 Scalar_base *astype(
const unsigned int &dtype) {
2110 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
2111 tmp->assign_selftype(this->_elem);
2114 Scalar_base *copy()
const {
2115 Int16Scalar *
tmp =
new Int16Scalar(this->_elem);
2118 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
2120 class Uint16Scalar :
public Scalar_base {
2124 Uint16Scalar() : _elem(0) { this->_dtype =
Type.Uint16; };
2125 Uint16Scalar(
const cytnx_uint16 &in) : _elem(0) {
2126 this->_dtype =
Type.Uint16;
2130 cytnx_float to_cytnx_float()
const {
return this->_elem; };
2131 cytnx_double to_cytnx_double()
const {
return this->_elem; };
2134 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
2135 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
2136 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
2137 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
2138 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
2139 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
2140 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
2142 void assign_selftype(
const cytnx_complex128 &c) {
2143 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
2145 void assign_selftype(
const cytnx_complex64 &c) {
2146 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
2148 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
2149 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
2150 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
2151 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
2152 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
2153 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
2154 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
2155 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
2156 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
2158 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_uint16(); }
2159 void iadd(
const cytnx_complex128 &c) {
2160 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2162 void iadd(
const cytnx_complex64 &c) {
2163 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2165 void iadd(
const cytnx_double &c) { this->_elem += c; }
2166 void iadd(
const cytnx_float &c) { this->_elem += c; }
2167 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
2168 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
2169 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
2170 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
2171 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
2172 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
2173 void iadd(
const cytnx_bool &c) { this->_elem += c; }
2175 void isub(
const Scalar_base *c) { this->_elem += c->to_cytnx_uint16(); }
2176 void isub(
const cytnx_complex128 &c) {
2177 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2179 void isub(
const cytnx_complex64 &c) {
2180 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2182 void isub(
const cytnx_double &c) { this->_elem += c; }
2183 void isub(
const cytnx_float &c) { this->_elem += c; }
2184 void isub(
const cytnx_uint64 &c) { this->_elem += c; }
2185 void isub(
const cytnx_int64 &c) { this->_elem += c; }
2186 void isub(
const cytnx_uint32 &c) { this->_elem += c; }
2187 void isub(
const cytnx_int32 &c) { this->_elem += c; }
2188 void isub(
const cytnx_uint16 &c) { this->_elem += c; }
2189 void isub(
const cytnx_int16 &c) { this->_elem += c; }
2190 void isub(
const cytnx_bool &c) { this->_elem += c; }
2192 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_uint16(); }
2193 void imul(
const cytnx_complex128 &c) {
2194 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2196 void imul(
const cytnx_complex64 &c) {
2197 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2199 void imul(
const cytnx_double &c) { this->_elem *= c; }
2200 void imul(
const cytnx_float &c) { this->_elem *= c; }
2201 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
2202 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
2203 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
2204 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
2205 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
2206 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
2207 void imul(
const cytnx_bool &c) { this->_elem *= c; }
2209 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_uint16(); }
2210 void idiv(
const cytnx_complex128 &c) {
2211 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2213 void idiv(
const cytnx_complex64 &c) {
2214 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2216 void idiv(
const cytnx_double &c) { this->_elem /= c; }
2217 void idiv(
const cytnx_float &c) { this->_elem /= c; }
2218 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
2219 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
2220 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
2221 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
2222 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
2223 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
2224 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
2226 void iabs() { this->_elem = std::abs(this->_elem); }
2227 void isqrt() { this->_elem = std::sqrt(this->_elem); }
2229 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_uint16(); }
2230 bool less(
const cytnx_complex128 &c) {
2231 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2234 bool less(
const cytnx_complex64 &c) {
2235 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2238 bool less(
const cytnx_double &c) {
return this->_elem < c; }
2239 bool less(
const cytnx_float &c) {
return this->_elem < c; }
2240 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
2241 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
2242 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
2243 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
2244 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
2245 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
2246 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
2248 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_uint16(); }
2249 bool greater(
const cytnx_complex128 &c) {
2250 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2253 bool greater(
const cytnx_complex64 &c) {
2254 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2257 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
2258 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
2259 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
2260 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
2261 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
2262 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
2263 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
2264 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
2265 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
2267 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_uint16(); }
2269 void conj_() {
return; }
2270 Scalar_base *get_real() {
return this->copy(); }
2271 Scalar_base *get_imag() {
2272 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
2276 void set_maxval() { this->_elem = std::numeric_limits<cytnx_uint16>::max(); }
2277 void set_minval() { this->_elem = std::numeric_limits<cytnx_uint16>::min(); }
2279 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
2280 Scalar_base *astype(
const unsigned int &dtype) {
2281 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
2282 tmp->assign_selftype(this->_elem);
2285 Scalar_base *copy()
const {
2286 Uint16Scalar *
tmp =
new Uint16Scalar(this->_elem);
2289 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
2291 class BoolScalar :
public Scalar_base {
2295 BoolScalar() : _elem(0) { this->_dtype =
Type.Bool; };
2296 BoolScalar(
const cytnx_bool &in) : _elem(0) {
2297 this->_dtype =
Type.Bool;
2301 cytnx_float to_cytnx_float()
const {
return this->_elem; };
2302 cytnx_double to_cytnx_double()
const {
return this->_elem; };
2305 cytnx_int64 to_cytnx_int64()
const {
return this->_elem; };
2306 cytnx_uint64 to_cytnx_uint64()
const {
return this->_elem; };
2307 cytnx_int32 to_cytnx_int32()
const {
return this->_elem; };
2308 cytnx_uint32 to_cytnx_uint32()
const {
return this->_elem; };
2309 cytnx_int16 to_cytnx_int16()
const {
return this->_elem; };
2310 cytnx_uint16 to_cytnx_uint16()
const {
return this->_elem; };
2311 cytnx_bool to_cytnx_bool()
const {
return this->_elem; };
2313 void assign_selftype(
const cytnx_complex128 &c) {
2314 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
2316 void assign_selftype(
const cytnx_complex64 &c) {
2317 cytnx_error_msg(
true,
"[ERROR] cannot convert complex to real%s",
"\n");
2319 void assign_selftype(
const cytnx_double &c) { this->_elem = c; }
2320 void assign_selftype(
const cytnx_float &c) { this->_elem = c; }
2321 void assign_selftype(
const cytnx_uint64 &c) { this->_elem = c; }
2322 void assign_selftype(
const cytnx_int64 &c) { this->_elem = c; }
2323 void assign_selftype(
const cytnx_uint32 &c) { this->_elem = c; }
2324 void assign_selftype(
const cytnx_int32 &c) { this->_elem = c; }
2325 void assign_selftype(
const cytnx_uint16 &c) { this->_elem = c; }
2326 void assign_selftype(
const cytnx_int16 &c) { this->_elem = c; }
2327 void assign_selftype(
const cytnx_bool &c) { this->_elem = c; }
2329 void iadd(
const Scalar_base *c) { this->_elem += c->to_cytnx_bool(); }
2330 void iadd(
const cytnx_complex128 &c) {
2331 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2333 void iadd(
const cytnx_complex64 &c) {
2334 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2336 void iadd(
const cytnx_double &c) { this->_elem += c; }
2337 void iadd(
const cytnx_float &c) { this->_elem += c; }
2338 void iadd(
const cytnx_uint64 &c) { this->_elem += c; }
2339 void iadd(
const cytnx_int64 &c) { this->_elem += c; }
2340 void iadd(
const cytnx_uint32 &c) { this->_elem += c; }
2341 void iadd(
const cytnx_int32 &c) { this->_elem += c; }
2342 void iadd(
const cytnx_uint16 &c) { this->_elem += c; }
2343 void iadd(
const cytnx_int16 &c) { this->_elem += c; }
2344 void iadd(
const cytnx_bool &c) { this->_elem += c; }
2346 void isub(
const Scalar_base *c) { this->_elem -= c->to_cytnx_bool(); }
2347 void isub(
const cytnx_complex128 &c) {
2348 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2350 void isub(
const cytnx_complex64 &c) {
2351 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2353 void isub(
const cytnx_double &c) { this->_elem -= c; }
2354 void isub(
const cytnx_float &c) { this->_elem -= c; }
2355 void isub(
const cytnx_uint64 &c) { this->_elem -= c; }
2356 void isub(
const cytnx_int64 &c) { this->_elem -= c; }
2357 void isub(
const cytnx_uint32 &c) { this->_elem -= c; }
2358 void isub(
const cytnx_int32 &c) { this->_elem -= c; }
2359 void isub(
const cytnx_uint16 &c) { this->_elem -= c; }
2360 void isub(
const cytnx_int16 &c) { this->_elem -= c; }
2361 void isub(
const cytnx_bool &c) { this->_elem -= c; }
2363 void imul(
const Scalar_base *c) { this->_elem *= c->to_cytnx_bool(); }
2364 void imul(
const cytnx_complex128 &c) {
2365 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2367 void imul(
const cytnx_complex64 &c) {
2368 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2370 void imul(
const cytnx_double &c) { this->_elem *= c; }
2371 void imul(
const cytnx_float &c) { this->_elem *= c; }
2372 void imul(
const cytnx_uint64 &c) { this->_elem *= c; }
2373 void imul(
const cytnx_int64 &c) { this->_elem *= c; }
2374 void imul(
const cytnx_uint32 &c) { this->_elem *= c; }
2375 void imul(
const cytnx_int32 &c) { this->_elem *= c; }
2376 void imul(
const cytnx_uint16 &c) { this->_elem *= c; }
2377 void imul(
const cytnx_int16 &c) { this->_elem *= c; }
2378 void imul(
const cytnx_bool &c) { this->_elem *= c; }
2380 void idiv(
const Scalar_base *c) { this->_elem /= c->to_cytnx_bool(); }
2381 void idiv(
const cytnx_complex128 &c) {
2382 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2384 void idiv(
const cytnx_complex64 &c) {
2385 cytnx_error_msg(
true,
"[ERROR] cannot operate real and complex values%s",
"\n");
2387 void idiv(
const cytnx_double &c) { this->_elem /= c; }
2388 void idiv(
const cytnx_float &c) { this->_elem /= c; }
2389 void idiv(
const cytnx_uint64 &c) { this->_elem /= c; }
2390 void idiv(
const cytnx_int64 &c) { this->_elem /= c; }
2391 void idiv(
const cytnx_uint32 &c) { this->_elem /= c; }
2392 void idiv(
const cytnx_int32 &c) { this->_elem /= c; }
2393 void idiv(
const cytnx_uint16 &c) { this->_elem /= c; }
2394 void idiv(
const cytnx_int16 &c) { this->_elem /= c; }
2395 void idiv(
const cytnx_bool &c) { this->_elem /= c; }
2397 void iabs() { this->_elem = std::abs(this->_elem); }
2398 void isqrt() { this->_elem = std::sqrt(this->_elem); }
2400 bool less(
const Scalar_base *c) {
return this->_elem < c->to_cytnx_bool(); }
2401 bool less(
const cytnx_complex128 &c) {
2402 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2405 bool less(
const cytnx_complex64 &c) {
2406 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2409 bool less(
const cytnx_double &c) {
return this->_elem < c; }
2410 bool less(
const cytnx_float &c) {
return this->_elem < c; }
2411 bool less(
const cytnx_uint64 &c) {
return this->_elem < c; }
2412 bool less(
const cytnx_int64 &c) {
return this->_elem < c; }
2413 bool less(
const cytnx_uint32 &c) {
return this->_elem < c; }
2414 bool less(
const cytnx_int32 &c) {
return this->_elem < c; }
2415 bool less(
const cytnx_uint16 &c) {
return this->_elem < c; }
2416 bool less(
const cytnx_int16 &c) {
return this->_elem < c; }
2417 bool less(
const cytnx_bool &c) {
return this->_elem < c; }
2419 bool greater(
const Scalar_base *c) {
return this->_elem > c->to_cytnx_bool(); }
2420 bool greater(
const cytnx_complex128 &c) {
2421 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2424 bool greater(
const cytnx_complex64 &c) {
2425 cytnx_error_msg(
true,
"[ERROR] comparison not supported for complex type%s",
"\n");
2428 bool greater(
const cytnx_double &c) {
return this->_elem > c; }
2429 bool greater(
const cytnx_float &c) {
return this->_elem > c; }
2430 bool greater(
const cytnx_uint64 &c) {
return this->_elem > c; }
2431 bool greater(
const cytnx_int64 &c) {
return this->_elem > c; }
2432 bool greater(
const cytnx_uint32 &c) {
return this->_elem > c; }
2433 bool greater(
const cytnx_int32 &c) {
return this->_elem > c; }
2434 bool greater(
const cytnx_uint16 &c) {
return this->_elem > c; }
2435 bool greater(
const cytnx_int16 &c) {
return this->_elem > c; }
2436 bool greater(
const cytnx_bool &c) {
return this->_elem > c; }
2438 bool eq(
const Scalar_base *c) {
return this->_elem == c->to_cytnx_bool(); }
2440 void conj_() {
return; }
2441 Scalar_base *get_real() {
return this->copy(); }
2442 Scalar_base *get_imag() {
2443 cytnx_error_msg(
true,
"[ERROR] real type Scalar does not have imag part!%s",
"\n");
2447 void set_maxval() { this->_elem =
true; }
2448 void set_minval() { this->_elem =
false; }
2450 void *get_raw_address()
const {
return (
void *)(&this->_elem); }
2451 Scalar_base *astype(
const unsigned int &dtype) {
2452 Scalar_base *
tmp = __ScII.UScIInit[dtype]();
2453 tmp->assign_selftype(this->_elem);
2456 Scalar_base *copy()
const {
2457 BoolScalar *
tmp =
new BoolScalar(this->_elem);
2460 void print(std::ostream &os)
const { os <<
"< " << this->_elem <<
" >"; };
2474 boost::intrusive_ptr<Storage_base> _insimpl;
2477 Sproxy(boost::intrusive_ptr<Storage_base> _ptr,
const cytnx_uint64 &idx)
2478 : _insimpl(_ptr), _loc(idx) {}
2480 Sproxy(
const Sproxy &rhs) {
2481 this->_insimpl = rhs._insimpl;
2482 this->_loc = rhs._loc;
2486 Sproxy &operator=(
const Scalar &rc);
2499 Sproxy &operator=(
const Sproxy &rc);
2501 Sproxy copy()
const {
2508 bool exists()
const;
2564 out._impl->set_maxval();
2578 out._impl->set_minval();
2592 Scalar(
const T &in,
const unsigned int &
dtype) : _impl(new Scalar_base()) {
2593 if (this->_impl !=
nullptr)
delete this->_impl;
2594 this->_impl = __ScII.UScIInit[
dtype]();
2595 this->_impl->assign_selftype(in);
2600 Scalar(
const Sproxy &prox);
2603 Scalar(Scalar_base *in) { this->_impl = in; }
2609 if (this->_impl !=
nullptr)
delete this->_impl;
2610 this->_impl =
new ComplexDoubleScalar(in);
2613 if (this->_impl !=
nullptr)
delete this->_impl;
2614 this->_impl =
new ComplexFloatScalar(in);
2617 if (this->_impl !=
nullptr)
delete this->_impl;
2618 this->_impl =
new DoubleScalar(in);
2621 if (this->_impl !=
nullptr)
delete this->_impl;
2622 this->_impl =
new FloatScalar(in);
2625 if (this->_impl !=
nullptr)
delete this->_impl;
2626 this->_impl =
new Int64Scalar(in);
2629 if (this->_impl !=
nullptr)
delete this->_impl;
2630 this->_impl =
new Uint64Scalar(in);
2633 if (this->_impl !=
nullptr)
delete this->_impl;
2634 this->_impl =
new Int32Scalar(in);
2637 if (this->_impl !=
nullptr)
delete this->_impl;
2638 this->_impl =
new Uint32Scalar(in);
2641 if (this->_impl !=
nullptr)
delete this->_impl;
2642 this->_impl =
new Int16Scalar(in);
2645 if (this->_impl !=
nullptr)
delete this->_impl;
2646 this->_impl =
new Uint16Scalar(in);
2649 if (this->_impl !=
nullptr)
delete this->_impl;
2650 this->_impl =
new BoolScalar(in);
2655 if (this->_impl !=
nullptr)
delete this->_impl;
2657 this->_impl = rhs._impl->copy();
2663 if (this->_impl !=
nullptr)
delete this->_impl;
2665 this->_impl = rhs._impl->copy();
2674 this->Init_by_number(rhs);
2682 this->Init_by_number(rhs);
2690 this->Init_by_number(rhs);
2698 this->Init_by_number(rhs);
2706 this->Init_by_number(rhs);
2714 this->Init_by_number(rhs);
2722 this->Init_by_number(rhs);
2730 this->Init_by_number(rhs);
2738 this->Init_by_number(rhs);
2746 this->Init_by_number(rhs);
2754 this->Init_by_number(rhs);
2801 int dtype()
const {
return this->_impl->_dtype; }
2808 this->_impl->print(std::cout);
2809 std::cout << std::string(
" Scalar dtype: [") <<
Type.getname(this->_impl->_dtype)
2810 << std::string(
"]") << std::endl;
2815 explicit operator cytnx_double()
const {
return this->_impl->to_cytnx_double(); }
2818 explicit operator cytnx_float()
const {
return this->_impl->to_cytnx_float(); }
2821 explicit operator cytnx_uint64()
const {
return this->_impl->to_cytnx_uint64(); }
2824 explicit operator cytnx_int64()
const {
return this->_impl->to_cytnx_int64(); }
2827 explicit operator cytnx_uint32()
const {
return this->_impl->to_cytnx_uint32(); }
2830 explicit operator cytnx_int32()
const {
return this->_impl->to_cytnx_int32(); }
2833 explicit operator cytnx_uint16()
const {
return this->_impl->to_cytnx_uint16(); }
2836 explicit operator cytnx_int16()
const {
return this->_impl->to_cytnx_int16(); }
2839 explicit operator cytnx_bool()
const {
return this->_impl->to_cytnx_bool(); }
2844 if (this->_impl !=
nullptr)
delete this->_impl;
2852 this->_impl->iadd(rc);
2862 this->_impl->isub(rc);
2872 this->_impl->imul(rc);
2883 this->_impl->idiv(rc);
2892 void iabs() { this->_impl->iabs(); }
2931 int rid =
Type.cy_typeid(rc);
2932 if (rid < this->
dtype()) {
2934 return tmp._impl->less(rc);
2936 return this->_impl->less(rc);
2948 if (rhs.
dtype() < this->dtype()) {
2950 return tmp._impl->less(rhs._impl);
2952 return this->_impl->less(rhs._impl);
2968 int rid =
Type.cy_typeid(rc);
2969 if (rid < this->
dtype()) {
2971 return !(tmp._impl->greater(rc));
2973 return !(this->_impl->greater(rc));
2985 if (rhs.
dtype() < this->dtype()) {
2987 return !(tmp._impl->greater(rhs._impl));
2989 return !(this->_impl->greater(rhs._impl));
3003 int rid =
Type.cy_typeid(rc);
3004 if (rid < this->
dtype()) {
3006 return tmp._impl->greater(rc);
3008 return this->_impl->greater(rc);
3020 if (rhs.
dtype() < this->dtype()) {
3022 return tmp._impl->greater(rhs._impl);
3024 return this->_impl->greater(rhs._impl);
3040 int rid =
Type.cy_typeid(rc);
3041 if (rid < this->
dtype()) {
3043 return !(tmp._impl->less(rc));
3045 return !(this->_impl->less(rc));
3057 if (rhs.
dtype() < this->dtype()) {
3059 return !(tmp._impl->less(rhs._impl));
3061 return !(this->_impl->less(rhs._impl));
3074 bool eq(
const T &rc)
const {
3076 int rid =
Type.cy_typeid(rc);
3077 if (rid < this->
dtype()) {
3079 return tmp._impl->eq(rc);
3081 return this->_impl->eq(rc);
3093 if (rhs.
dtype() < this->dtype()) {
3095 return tmp._impl->eq(rhs._impl);
3097 return this->_impl->eq(rhs._impl);
3110 int rid =
Type.cy_typeid(rc);
3111 if (this->
dtype() < rid) {
3116 out._impl->iadd(rc);
3131 out._impl->iadd(rhs._impl);
3144 int rid =
Type.cy_typeid(rc);
3145 if (this->
dtype() < rid) {
3150 out._impl->imul(rc);
3165 out._impl->imul(rhs._impl);
3178 int rid =
Type.cy_typeid(rc);
3179 if (this->
dtype() < rid) {
3184 out._impl->isub(rc);
3199 out._impl->isub(rhs._impl);
3212 int rid =
Type.cy_typeid(rc);
3213 if (this->
dtype() < rid) {
3218 out._impl->idiv(rc);
3233 out._impl->idiv(rhs._impl);
3388 std::ostream &operator<<(std::ostream &os,
const Scalar &in);
A class to represent a scalar.
Definition Scalar.hpp:2470
void operator-=(const T &rc)
The subtraction assignment operator of the Scalar class with a given number (template).
Definition Scalar.hpp:2861
Scalar & operator=(const Scalar &rhs)
The copy assignment of the Scalar class.
Definition Scalar.hpp:2662
bool less(const Scalar &rhs) const
Return whether the current Scalar is less than a given Scalar rhs.
Definition Scalar.hpp:2946
bool leq(const T &rc) const
Return whether the current Scalar is less than or equal to a given template number rc.
Definition Scalar.hpp:2966
Scalar(const cytnx_int64 &in)
init a Scalar with a cytnx::cytnx_int64
Definition Scalar.hpp:2537
Scalar & operator=(const cytnx_bool &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_bool rhs.
Definition Scalar.hpp:2753
Scalar(const cytnx_double &in)
init a Scalar with a cytnx::cytnx_double
Definition Scalar.hpp:2528
Scalar(const T &in, const unsigned int &dtype)
The constructor of the Scalar class.
Definition Scalar.hpp:2592
Scalar & operator=(const cytnx_float &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_float rhs.
Definition Scalar.hpp:2697
Scalar(const cytnx_int16 &in)
init a Scalar with a cytnx::cytnx_int16
Definition Scalar.hpp:2549
Scalar rmul(const T &rc) const
Return the multiplication of the current Scalar and a given template number rc.
Definition Scalar.hpp:3142
static Scalar minval(const unsigned int &dtype)
Get the min value of the Scalar with the given dtype.
Definition Scalar.hpp:2576
Scalar & operator=(const cytnx_uint16 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_uint16 rhs.
Definition Scalar.hpp:2737
void operator+=(const T &rc)
The addition assignment operator of the Scalar class with a given number (template).
Definition Scalar.hpp:2851
static Scalar maxval(const unsigned int &dtype)
Get the max value of the Scalar with the given dtype.
Definition Scalar.hpp:2562
Scalar & operator=(const cytnx_int64 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_int64 rhs.
Definition Scalar.hpp:2713
Scalar()
default constructor
Definition Scalar.hpp:2518
Scalar rsub(const T &rc) const
Return the subtraction of the current Scalar and a given template number rc.
Definition Scalar.hpp:3176
Scalar(const cytnx_int32 &in)
init a Scalar with a cytnx::cytnx_int32
Definition Scalar.hpp:2543
Scalar & operator=(const cytnx_int16 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_int16 rhs.
Definition Scalar.hpp:2745
Scalar(const cytnx_uint32 &in)
init a Scalar with a cytnx::cytnx_uint32
Definition Scalar.hpp:2540
bool less(const T &rc) const
Return whether the current Scalar is less than a given template number rc.
Definition Scalar.hpp:2929
Scalar(const cytnx_uint16 &in)
init a Scalar with a cytnx::cytnx_uint16
Definition Scalar.hpp:2546
Scalar & operator=(const cytnx_uint64 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_uint64 rhs.
Definition Scalar.hpp:2705
Scalar real() const
Get the real part of the Scalar. That means return if the Scalar is .
Definition Scalar.hpp:2794
int dtype() const
Get the dtype of the Scalar (see cytnx::Type for more details).
Definition Scalar.hpp:2801
void operator/=(const T &rc)
The division assignment operator of the Scalar class with a given number (template).
Definition Scalar.hpp:2882
Scalar(const cytnx_float &in)
init a Scalar with a cytnx::cytnx_float
Definition Scalar.hpp:2531
Scalar & operator=(const cytnx_double &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_double rhs.
Definition Scalar.hpp:2689
Scalar sqrt() const
The member function to get the square root of the Scalar.
Definition Scalar.hpp:2915
Scalar(const cytnx_complex64 &in)
init a Scalar with a cytnx::cytnx_complex64
Definition Scalar.hpp:2525
void operator*=(const T &rc)
The multiplication assignment operator of the Scalar class with a given number (template).
Definition Scalar.hpp:2871
bool geq(const Scalar &rhs) const
Return whether the current Scalar is greater than or equal to a given Scalar rhs.
Definition Scalar.hpp:3055
Scalar & operator=(const cytnx_int32 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_int32 rhs.
Definition Scalar.hpp:2729
bool greater(const T &rc) const
Return whether the current Scalar is greater than a given template number rc.
Definition Scalar.hpp:3001
Scalar(const cytnx_uint64 &in)
init a Scalar with a cytnx::cytnx_uint64
Definition Scalar.hpp:2534
Scalar conj() const
Get the conjugate of the Scalar. That means return if the Scalar is .
Definition Scalar.hpp:2776
void operator-=(const Scalar &rhs)
The subtraction assignment operator of the Scalar class with a given Scalar.
Definition Scalar.hpp:2866
Scalar imag() const
Get the imaginary part of the Scalar. That means return if the Scalar is .
Definition Scalar.hpp:2787
bool leq(const Scalar &rhs) const
Return whether the current Scalar is less than or equal to a given Scalar rhs.
Definition Scalar.hpp:2983
void iabs()
Set the Scalar to absolute value. (inplace)
Definition Scalar.hpp:2892
Scalar abs() const
The member function to get the absolute value of the Scalar.
Definition Scalar.hpp:2903
Scalar rdiv(const T &rc) const
Return the division of the current Scalar and a given template number rc.
Definition Scalar.hpp:3210
bool eq(const T &rc) const
Return whether the current Scalar is equal to a given template number rc.
Definition Scalar.hpp:3074
void print() const
Print the Scalar to the standard output.
Definition Scalar.hpp:2807
bool greater(const Scalar &rhs) const
Return whether the current Scalar is greater than a given Scalar rhs.
Definition Scalar.hpp:3018
bool geq(const T &rc) const
Return whether the current Scalar is greater than or equal to a given template number rc.
Definition Scalar.hpp:3038
void isqrt()
Set the Scalar to square root. (inplace)
Definition Scalar.hpp:2895
Scalar rmul(const Scalar &rhs) const
Return the multiplication of the current Scalar and a given Scalar rhs.
Definition Scalar.hpp:3158
Scalar & operator=(const cytnx_uint32 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_uint32 rhs.
Definition Scalar.hpp:2721
Scalar & operator=(const cytnx_complex128 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_complex128 rhs.
Definition Scalar.hpp:2673
Scalar(const cytnx_bool &in)
init a Scalar with a cytnx::cytnx_bool
Definition Scalar.hpp:2552
bool eq(const Scalar &rhs) const
Return whether the current Scalar is equal to a given Scalar rhs.
Definition Scalar.hpp:3091
Scalar rdiv(const Scalar &rhs) const
Return the division of the current Scalar and a given Scalar rhs.
Definition Scalar.hpp:3226
void operator+=(const Scalar &rhs)
The addition assignment operator of the Scalar class with a given Scalar.
Definition Scalar.hpp:2856
void operator*=(const Scalar &rhs)
The multiplication assignment operator of the Scalar class with a given Scalar.
Definition Scalar.hpp:2876
void operator/=(const Scalar &rhs)
The division assignment operator of the Scalar class with a given Scalar.
Definition Scalar.hpp:2889
Scalar(const cytnx_complex128 &in)
init a Scalar with a cytnx::cytnx_complex128
Definition Scalar.hpp:2522
Scalar & operator=(const cytnx_complex64 &rhs)
The copy assignment operator of the Scalar class with a given number cytnx::cytnx_complex64 rhs.
Definition Scalar.hpp:2681
Scalar rsub(const Scalar &rhs) const
Return the subtraction of the current Scalar and a given Scalar rhs.
Definition Scalar.hpp:3192
Scalar radd(const Scalar &rhs) const
Return the addition of the current Scalar and a given Scalar rhs.
Definition Scalar.hpp:3124
Scalar radd(const T &rc) const
Return the addition of the current Scalar and a given template number rc.
Definition Scalar.hpp:3108
Scalar astype(const unsigned int &dtype) const
Type conversion function.
Definition Scalar.hpp:2766
#define cytnx_error_msg(is_true, format,...)
Definition cytnx_error.hpp:16
Definition Accessor.hpp:12
cytnx_complex128 complex128(const Scalar &in)
Convert a Scalar object to a cytnx::complex128.
cytnx::UniTensor operator*(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The multiplication operator between two UniTensor.
bool operator<=(const Scalar &lc, const Scalar &rs)
The less-than-or-equal operator between two Scalar objects.
double cytnx_double
Definition Type.hpp:43
uint32_t cytnx_uint32
Definition Type.hpp:46
bool cytnx_bool
Definition Type.hpp:54
std::complex< double > cytnx_complex128
Definition Type.hpp:53
float cytnx_float
Definition Type.hpp:44
int16_t cytnx_int16
Definition Type.hpp:50
Scalar abs(const Scalar &c)
Return the absolute value of a Scalar object.
std::complex< float > cytnx_complex64
Definition Type.hpp:52
cytnx::UniTensor operator-(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The subtraction operator between two UniTensor.
int32_t cytnx_int32
Definition Type.hpp:49
Tensor operator==(const Tensor &Lt, const Tensor &Rt)
The comparison operator for Tensor.
uint16_t cytnx_uint16
Definition Type.hpp:47
uint64_t cytnx_uint64
Definition Type.hpp:45
cytnx_complex64 complex64(const Scalar &in)
Convert a Scalar object to a cytnx::complex64.
int64_t cytnx_int64
Definition Type.hpp:48
Scalar sqrt(const Scalar &c)
Return the square root of a Scalar object.
cytnx::UniTensor operator+(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The addtion operator between two UniTensor.
bool operator>(const Scalar &lc, const Scalar &rs)
The greater-than operator between two Scalar objects.
cytnx::UniTensor operator/(const cytnx::UniTensor &Lt, const cytnx::UniTensor &Rt)
The division operator between two UniTensor.
bool operator>=(const Scalar &lc, const Scalar &rs)
The greater-than-or-equal operator between two Scalar objects.
bool operator<(const Scalar &lc, const Scalar &rs)
The less-than operator between two Scalar objects.