-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathquantum_gates.h
97 lines (75 loc) · 3.54 KB
/
quantum_gates.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* quantum_gates.h: header file for quantum gate functions
*/
#ifndef __QUDA_QUANTUM_GATES_H
#define __QUDA_QUANTUM_GATES_H
#include "quantum_reg.h"
#define ONE_OVER_SQRT_2 0.707106781f
// One-bit quantum gates
/* Applies the quantum Hadamard gate to the target bit of a quantum register.
* Puts the target bit into a superposition of two states.
* |0> -> k(|0> + |1>); |1> -> k(|0>-|1>) where k=1/sqrt(2)
* Returns -1 on failure if a register expansion was necessary but failed.
* Returns 0 on success;
*/
int quda_quantum_hadamard_gate(int target, quantum_reg* qreg);
/* Applies the quantum Pauli X gate to the target bit of a quantum register.
* Also known as the Sigma X gate or the Quantum Not gate.
*/
void quda_quantum_pauli_x_gate(int target, quantum_reg* qreg);
/* Applies the quantum Pauli Y gate to the target bit of a quantum register.
* Also known as the Sigma Y gate.
*/
void quda_quantum_pauli_y_gate(int target, quantum_reg* qreg);
/* Applies the quantum Pauli Z gate to the target bit of a quantum register.
* Also known as the Sigma Z gate.
*/
void quda_quantum_pauli_z_gate(int target, quantum_reg* qreg);
/* Applies the quantum Phase gate to the target bit of a quantum register.
* This is the square root of the Pauli/Sigma Z gate.
*/
void quda_quantum_phase_gate(int target, quantum_reg* qreg);
/* Applies the quantum PI/8 gate to the target bit of a quantum register.
* This is the square root of the Phase gate.
*/
void quda_quantum_pi_over_8_gate(int target, quantum_reg* qreg);
/* Applies the quantum Rotate_k gate to the target bit of a quantum register.
* Arbitrary rotation gate used primarily in computing the quantum Fourier transform.
* k = 3 is effectively the PI/8 gate.
*/
void quda_quantum_rotate_k_gate(int target, quantum_reg* qreg, int k);
// Two-bit quantum gates
/* Applies the quantum Swap gate to exchange the states of the two target bits of a
* quantum register.
*/
void quda_quantum_swap_gate(int target1, int target2, quantum_reg* qreg);
/* Applies the quantum Controlled-Not gate to the target bit of a quantum register
* if the control bit is set.
* Also known as the Controlled-X gate.
*/
void quda_quantum_controlled_not_gate(int control, int target, quantum_reg* qreg);
/* Applies the Controlled-Y gate to the target bit of a quantum register if the
* control bit is set.
*/
void quda_quantum_controlled_y_gate(int control,int target, quantum_reg* qreg);
/* Applies the Controlled-Z gate to the target bit of a quantum register if the
* control bit is set.
*/
void quda_quantum_controlled_z_gate(int control, int target, quantum_reg* qreg);
/* Applies the Controlled-Phase gate to the target bit of a quantum register if the
* control bit is set.
*/
void quda_quantum_controlled_phase_gate(int control, int target, quantum_reg* qreg);
/* Applies the Controlled-Rotate_k gate to the targit bit of a quantum register if the
* control bit is set. Is a key component of the quantum Fourier transform.
*/
void quda_quantum_controlled_rotate_k_gate(int control, int target, quantum_reg* qreg, int k);
// Three-bit quantum gates
/* Applies the quantum Toffoli gate (Controlled-Controlled-Not) to the
* target bit of a quantum register if both control1 and control2 are set.
*/
void quda_quantum_toffoli_gate(int control1, int control2, int target, quantum_reg* qreg);
/* Applies the quantum Fredkin gate (Controlled-Swap) to exchange the two
* target bits of a quantum register.
*/
void quda_quantum_fredkin_gate(int control, int target1, int target2, quantum_reg* qreg);
#endif // __QUDA_QUANTUM_GATES_H