MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / main

Function main

examples/isolated/complex_arithmetic.cpp:12–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12int main() {
13
14 initQuESTEnv();
15
16 // use 1_i instead of 1i to make the complex literal precision agnostic
17 qcomp x = 1.2 + 3.4_i;
18
19 // C with non-same-prec C (does not change x to keep consistency with arithemtic.c)
20 qcomp y = 1.5i - 2i - x + 3.5*x / 10.5_i;
21
22 // C + R
23 x = x + (int) 3;
24 x = x + (qindex) 3;
25 x = x + (float) 2;
26 x = x + (double) 2;
27 x = x + (long double) 2;
28
29 // R + C
30 x = (int) 3 + x;
31 x = (qindex) 3 + x;
32 x = (float) 2 + x;
33 x = (double) 2 + x;
34 x = (long double) 2 + x;
35
36 // C - R
37 x = x - (int) 3;
38 x = x - (qindex) 3;
39 x = x - (float) 2;
40 x = x - (double) 2;
41 x = x - (long double) 2;
42
43 // R - C
44 x = (int) 3 - x;
45 x = (qindex) 3 - x;
46 x = (float) 2 - x;
47 x = (double) 2 - x;
48 x = (long double) 2 - x;
49
50 // C * R
51 x = x * (int) 3;
52 x = x * (qindex) 3;
53 x = x * (float) 2;
54 x = x * (double) 2;
55 x = x * (long double) 2;
56
57 // R * C
58 x = (int) 3 * x;
59 x = (qindex) 3 * x;
60 x = (float) 2 * x;
61 x = (double) 2 * x;
62 x = (long double) 2 * x;
63
64 // C / R
65 x = x / (int) 3;
66 x = x / (qindex) 3;
67 x = x / (float) 2;
68 x = x / (double) 2;
69 x = x / (long double) 2;

Callers

nothing calls this directly

Calls 3

initQuESTEnvFunction · 0.85
reportScalarFunction · 0.85
finalizeQuESTEnvFunction · 0.85

Tested by

no test coverage detected