You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
printf("[!] Too many gates in the row. Resize the custom gate '%s' or decrease the number of pre-defined gates in the row. [%d]\n", keytypes[i].key, (gates_done+gate_size));
334
+
exit(-1);
335
+
}
336
+
337
+
i+=2;
338
+
339
+
while(keytypes[i].type!=IDX_BRACKET_OPEN) i++;
340
+
341
+
while(keytypes[i].type!=CMPND_STMT_CLOSE) {
342
+
if(cur_qubit_idx>gate_size) {
343
+
printf("[!] Too many gates in the custom gate '%s'. [number of gates: %d]\n", gate_name, cur_qubit_idx);
Copy file name to clipboardExpand all lines: README.md
+82-42Lines changed: 82 additions & 42 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,20 @@
1
1
# Qua-C
2
2
3
-
Qua-C (pronounced as /'kwɑ-si/) is a *domain specific programming language* for simulating **Quantum Computing Algorithms.**
3
+
Qua-C (pronounced as /'kwɑ-si/) is a *domain specific programming language* for simulating **Quantum Computing Algorithms.**
4
4
5
5
Qua-C is a language under development to make the process of coding a Quantum Algorithm easy and in a visual syntax format.
6
6
7
-
Qua-C has a different ideology from conventional programming languages, which have a sequential syntax format to apply functions and gates to data. Instead of a sequential construct, Qua-C executes code pseudo-parallel fashion for the set of qubits in the quregister.
7
+
Qua-C has a different ideology from conventional programming languages, which have a sequential syntax format to apply functions and gates to data. Instead of a sequential construct, Qua-C executes code column-wise manner for a set of qubits in the quregister.
8
8
9
9
**The Qua-C Transpiler is developed completely in 'C' language currently.**
10
10
11
11
Also see the 'Examples' folder to know more about the functionality. The 'Examples' folder contains various examples like:-
12
12
13
-
1. CNOT Gate
14
-
2. Hadamard Gate
15
-
3. Rotation of qubits about X, Y, Z - Axes of Bloch Sphere
16
-
4. Quantum NOT Gate
17
-
5. Quantum Registers
18
-
6. Quantum Rotation about imaginary axis
19
-
7. Quantum swapping of two Qubits
13
+
1. Basic Example
14
+
2.**Grover search** for 2 qubits
15
+
3. Hadamard Gate mania
16
+
4.**Shor's period finding** algorithm
17
+
5.**Grover Search** for 5 qubits with **custom gates**
20
18
21
19
22
20
## Quantum Registers
@@ -25,21 +23,27 @@ This feature allows the use to make registers consisting of multiple qubits at a
25
23
26
24
To make the coding of these gates easier, a functionality of short-hand gates is provided. The gates can be applied to the register as follows:-
27
25
28
-
*** example.qc ***
26
+
### example.qc ###
29
27
30
-
func test {
31
-
Pa()
32
-
[X, X]
33
-
[Z, Y]
28
+
gate MyOwnGate[2] {
34
29
[H, H]
35
-
[X, Z]
36
-
[Y, X]
37
30
}
38
31
39
-
quReg a = init(2)
40
-
a.name = "quReg1: "
41
-
a.prec = 6
32
+
func test {
33
+
[X, X] Pa()
34
+
[Z, Y] Pa()
35
+
[H, H] Pa()
36
+
[X, Z] Pa()
37
+
[Y, X] Pa()
38
+
[MyOwnGate]
39
+
}
42
40
41
+
#### Initialize ####
42
+
quReg a = new quReg[2] => 'myqureg1'
43
+
a.setPrecision(6)
44
+
45
+
#### Simulate ####
46
+
a.Pnz()
43
47
a.test()
44
48
a.Pnz()
45
49
@@ -48,48 +52,84 @@ OUTPUT:
48
52
49
53
./quacc example.qc
50
54
51
-
quReg2 =
52
-
[0] => {1.000000 + 0.000000 i} |00> 100.00 %
53
-
[1] => {0.000000 + 0.000000 i} |01> 0.00 %
54
-
[2] => {0.000000 + 0.000000 i} |10> 0.00 %
55
-
[3] => {0.000000 + 0.000000 i} |11> 0.00 %
55
+
[+] Parsing Successful...!!!
56
+
57
+
Executing program...
58
+
myqureg1 =
59
+
[0] => {1.000000 + 0.000000 i} |00> 100.000000 %
60
+
61
+
62
+
myqureg1 =
63
+
[0] => {0.000000 + 0.000000 i} |00> 0.000000 %
64
+
[1] => {0.000000 + 0.000000 i} |01> 0.000000 %
65
+
[2] => {0.000000 + 0.000000 i} |10> 0.000000 %
66
+
[3] => {1.000000 + 0.000000 i} |11> 100.000000 %
67
+
68
+
69
+
myqureg1 =
70
+
[0] => {0.000000 + 0.000000 i} |00> 0.000000 %
71
+
[1] => {-0.000000 + 1.000000 i} |01> 100.000000 %
72
+
[2] => {-0.000000 + 0.000000 i} |10> 0.000000 %
73
+
[3] => {0.000000 + 0.000000 i} |11> 0.000000 %
56
74
57
-
quReg2 =
58
-
[0] => {-0.000000 - 0.500000 i} |00> 25.00 %
59
-
[1] => {-0.000000 + 0.500000 i} |01> 25.00 %
60
-
[2] => {-0.000000 - 0.500000 i} |10> 25.00 %
61
-
[3] => {-0.000000 + 0.500000 i} |11> 25.00 %
75
+
76
+
myqureg1 =
77
+
[0] => {0.000000 + 0.500000 i} |00> 25.000000 %
78
+
[1] => {0.000000 - 0.500000 i} |01> 25.000000 %
79
+
[2] => {0.000000 + 0.500000 i} |10> 25.000000 %
80
+
[3] => {0.000000 - 0.500000 i} |11> 25.000000 %
81
+
82
+
83
+
myqureg1 =
84
+
[0] => {0.000000 - 0.500000 i} |00> 25.000000 %
85
+
[1] => {0.000000 + 0.500000 i} |01> 25.000000 %
86
+
[2] => {-0.000000 + 0.500000 i} |10> 25.000000 %
87
+
[3] => {-0.000000 - 0.500000 i} |11> 25.000000 %
88
+
89
+
90
+
myqureg1 =
91
+
[0] => {-0.500000 + 0.000000 i} |00> 25.000000 %
92
+
[1] => {-0.500000 + 0.000000 i} |01> 25.000000 %
93
+
[2] => {0.500000 + 0.000000 i} |10> 25.000000 %
94
+
[3] => {0.500000 + 0.000000 i} |11> 25.000000 %
95
+
96
+
97
+
myqureg1 =
98
+
[2] => {-1.000000 + 0.000000 i} |10> 100.000000 %
99
+
100
+
101
+
Time taken: 0 min, 0.000124 sec
62
102
63
103
64
104
The above code segment has the following meaning:-
65
105
- Initialize a new quRegister.
66
-
- Display text for the quRegister is "quReg1: ".
67
-
-Pa() -> Print all possible combinations of 'n' qubits in the quRegister.
106
+
- Display text for the quRegister is "quReg1".
107
+
-Pnz() -> Print only non-zero magnitude values of the 2 qubit quRegister.
68
108
- Pauli gate 'X' is applied to [qubit[0], qubit[1]] respectively.
109
+
- Print all states in the quRegister.
69
110
- Pauli gate 'Z' is applied to qubit[0] and 'Y' to qubit[1] respectively, and so on.
70
111
- Pnz() -> Print only non-zero magnitude values.
71
112
72
113
## List of short-hand gates
73
114
- Hadamard Gate: **H**
74
115
- Phase Gate: **S**
75
-
- Rotation Gate: **R(x)**
116
+
- Rotation Gate: **R_k**
76
117
77
-
x: Angle value (in degrees)(Int/Float)
78
-
- CNOT Gate:
79
-
- Control gate: **Co**
80
-
- NOT gate: **Cx**
118
+
k: power of n'th root of unity (w)
119
+
- Control gate: **@**
120
+
- Inverse Control gate: **o**
81
121
- NOOP Gate: **-**
82
122
- Pauli Gates
83
123
- Pauli X gate: **X**
84
124
- Pauli Y gate: **Y**
85
125
- Pauli Z gate: **Z**
86
-
- Swap Gate: **Sx**
87
-
- Quantum Fourier Transform (QFT) Gate: **Q**
88
-
- Inverse QFT Gate: **Qi**
126
+
- Swap Gate: **x**
127
+
- Quantum Fourier Transform (QFT) Gate: **~**
128
+
89
129
90
-
*For more info, see the examples:https://github.com/AbeerVaishnav13/qua-C/tree/master/Examples*
130
+
**For more info, see the examples:***https://github.com/AbeerVaishnav13/qua-C/tree/master/Examples*
91
131
92
-
*\*Currently, the language supports registers upto 28-qubits with 8GB of memory.*
132
+
**Currently, the language supports registers upto 29-qubits with 8GB of memory.**
93
133
94
134
## Installation Instructions
95
135
@@ -104,7 +144,7 @@ The dependencies for QuaC language is the **gcc** compiler and **cmake**.
104
144
105
145
sudo brew install gcc cmake
106
146
107
-
(iii) For Windows platform - install MINGW GCC for windows or even better, install any Linux distribution of your choice :)
147
+
(iii) For Windows platform - install MINGW GCC for windows or even better, install any Linux distribution of your choice :)
0 commit comments