Skip to content

Commit c68adb3

Browse files
committed
Added gpi, gpi2, virtualZ and ms gates
1 parent 6d8fae6 commit c68adb3

File tree

7 files changed

+3458
-547
lines changed

7 files changed

+3458
-547
lines changed

README.md

Lines changed: 177 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -225,18 +225,22 @@ console.log(quantumRandom());
225225
| **t** | T | T | T | 1 | | PI/4 rotation over Z-axis (synonym for `r4`) |
226226
| **sdg** | PHASE(-pi/2) | u1(-pi/2) | | 1 | | (-PI/2) rotation over Z-axis |
227227
| **tdg** | PHASE(-pi/4) | u1(-pi/4) | | 1 | | (-PI/4) rotation over Z-axis |
228-
| **swap** | SWAP | SWAP | SWAP | 2 | | Swaps the state of two qubits. |
229-
| **srswap** | def srswap | SWAP**(1/2) | | 2 | | Square root of swap |
230-
| **iswap** | ISWAP | ISWAP | | 2 | | Swaps the state of two qubits, applying a -i phase to q1 when it is in the 1 state and a -i phase to q2 when it is in the 0 state |
231-
| **xy** | XY | def xy | | 2 | phi | XY gate |
228+
| **gpi** | def gpi | gpi | | 1 | phi | GPi gate |
229+
| **gpi2** | def gpi2 | gpi2 | | 1 | phi | GPi2 gate |
230+
| **vz** | def vz | vz | | 1 | theta | VirtualZ gate |
232231
| **cx** | CNOT | CNOT | CNOT | 2 | | Controlled NOT (CNOT) gate |
233232
| **cy** | def cy | Y | Controlled Y | 2 | | Controlled Y gate (controlled rotation over Y-axis by PI) |
234233
| **cz** | CZ | CZ | Controlled Z | 2 | | Controlled Z gate (controlled rotation over Z-axis by PI) |
235234
| **ch** | def ch | H | Controlled H | 2 | | Controlled Hadamard gate |
236235
| **csrn** | def csrn | X**(1/2) | | 2 | | Controlled square root of NOT |
237-
| **ms** | def ms | ms | | 2 | theta | Mølmer-Sørensen gate |
236+
| **swap** | SWAP | SWAP | SWAP | 2 | | Swaps the state of two qubits. |
237+
| **srswap** | def srswap | SWAP**(1/2) | | 2 | | Square root of swap |
238+
| **iswap** | ISWAP | ISWAP | | 2 | | Swaps the state of two qubits, applying a -i phase to q1 when it is in the 1 state and a -i phase to q2 when it is in the 0 state |
239+
| **xx** | def xx | xx | | 2 | theta | XX gate |
238240
| **yy** | def yy | YY | | 2 | theta | YY gate |
239241
| **zz** | def zz | | | 2 | theta | Parametric 2-qubit rotation about ZZ |
242+
| **xy** | XY | def xy | | 2 | phi | XY gate |
243+
| **ms** | def ms | ms | | 2 | phi0, phi1 | Mølmer-Sørensen gate |
240244
| **cr2** | CPHASE(pi/2) | cu1(pi/2) | | 2 | | Controlled PI/2 rotation over Z-axis |
241245
| **cr4** | CPHASE(pi/4) | cu1(pi/4) | | 2 | | Controlled PI/4 rotation over Z-axis |
242246
| **cr8** | CPHASE(pi/8) | cu1(pi/8) | | 2 | | Controlled PI/8 rotation over Z-axis |
@@ -1719,99 +1723,89 @@ circuit.appendGate("sdg", 0);
17191723
circuit.appendGate("tdg", 0);
17201724
```
17211725

1722-
## swap
1723-
1724-
Swaps the state of two qubits.
1726+
## gpi
17251727

1726-
**Qubits:** 2
1728+
GPi gate
17271729

1728-
**Matrix:**
1729-
```javascript
1730-
[
1731-
1732-
[1,0,0,0],
1733-
[0,0,1,0],
1734-
[0,1,0,0],
1735-
[0,0,0,1]
1736-
]
1737-
```
1738-
1739-
**Example:**
1740-
```javascript
1741-
circuit.appendGate("swap", [0, 1]);
1742-
```
1730+
**Qubits:** 1
17431731

1744-
## srswap
1732+
**Parameters:**
17451733

1746-
Square root of swap
1734+
- phi
17471735

1748-
**Qubits:** 2
17491736

17501737
**Matrix:**
17511738
```javascript
17521739
[
17531740

1754-
[1,0,0,0],
1755-
[0,"0.5 * (1 + i)","0.5 * (1 - i)",0],
1756-
[0,"0.5 * (1 - i)","0.5 * (1 + i)",0],
1757-
[0,0,0,1]
1741+
[0,"exp(-i*phi)"],
1742+
["exp(i*phi)",0]
17581743
]
17591744
```
17601745

17611746
**Example:**
17621747
```javascript
1763-
circuit.appendGate("srswap", [0, 1]);
1748+
circuit.appendGate("gpi", 0, {
1749+
params: {
1750+
phi: "pi/2"
1751+
}
1752+
});
17641753
```
17651754

1766-
## iswap
1755+
## gpi2
17671756

1768-
Swaps the state of two qubits, applying a -i phase to q1 when it is in the 1 state and a -i phase to q2 when it is in the 0 state
1757+
GPi2 gate
1758+
1759+
**Qubits:** 1
1760+
1761+
**Parameters:**
1762+
1763+
- phi
17691764

1770-
**Qubits:** 2
17711765

17721766
**Matrix:**
17731767
```javascript
17741768
[
17751769

1776-
[1,0,0,0],
1777-
[0,0,"0+i",0],
1778-
[0,"0+i",0,0],
1779-
[0,0,0,1]
1770+
["1/sqrt(2)","(-i*exp(-i*phi))/sqrt(2)"],
1771+
["(-i*exp(i*phi))/sqrt(2)","1/sqrt(2)"]
17801772
]
17811773
```
17821774

17831775
**Example:**
17841776
```javascript
1785-
circuit.appendGate("iswap", [0, 1]);
1777+
circuit.appendGate("gpi2", 0, {
1778+
params: {
1779+
phi: "pi/2"
1780+
}
1781+
});
17861782
```
17871783

1788-
## xy
1784+
## vz
17891785

1790-
XY gate
1786+
VirtualZ gate
17911787

1792-
**Qubits:** 2
1788+
**Qubits:** 1
17931789

17941790
**Parameters:**
17951791

1796-
- phi
1792+
- theta
17971793

17981794

17991795
**Matrix:**
18001796
```javascript
18011797
[
18021798

1803-
[1,0,0,0],
1804-
[0,"cos(phi / 2)","i * sin(phi / 2)",0],
1805-
[0,"i * sin(phi / 2)","cos(phi / 2)",0],
1806-
[0,0,0,1]
1799+
["exp(-i*theta/2)",0],
1800+
[0,"exp(i*theta/2)"]
18071801
]
18081802
```
18091803

18101804
**Example:**
18111805
```javascript
1812-
circuit.appendGate("xy", [0, 1], {
1806+
circuit.appendGate("vz", 0, {
18131807
params: {
1814-
phi: "pi/2"
1808+
theta: "pi/2"
18151809
}
18161810
});
18171811
```
@@ -1926,9 +1920,75 @@ Controlled square root of NOT
19261920
circuit.appendGate("csrn", [0, 1]);
19271921
```
19281922

1929-
## ms
1923+
## swap
19301924

1931-
Mølmer-Sørensen gate
1925+
Swaps the state of two qubits.
1926+
1927+
**Qubits:** 2
1928+
1929+
**Matrix:**
1930+
```javascript
1931+
[
1932+
1933+
[1,0,0,0],
1934+
[0,0,1,0],
1935+
[0,1,0,0],
1936+
[0,0,0,1]
1937+
]
1938+
```
1939+
1940+
**Example:**
1941+
```javascript
1942+
circuit.appendGate("swap", [0, 1]);
1943+
```
1944+
1945+
## srswap
1946+
1947+
Square root of swap
1948+
1949+
**Qubits:** 2
1950+
1951+
**Matrix:**
1952+
```javascript
1953+
[
1954+
1955+
[1,0,0,0],
1956+
[0,"0.5 * (1 + i)","0.5 * (1 - i)",0],
1957+
[0,"0.5 * (1 - i)","0.5 * (1 + i)",0],
1958+
[0,0,0,1]
1959+
]
1960+
```
1961+
1962+
**Example:**
1963+
```javascript
1964+
circuit.appendGate("srswap", [0, 1]);
1965+
```
1966+
1967+
## iswap
1968+
1969+
Swaps the state of two qubits, applying a -i phase to q1 when it is in the 1 state and a -i phase to q2 when it is in the 0 state
1970+
1971+
**Qubits:** 2
1972+
1973+
**Matrix:**
1974+
```javascript
1975+
[
1976+
1977+
[1,0,0,0],
1978+
[0,0,"0+i",0],
1979+
[0,"0+i",0,0],
1980+
[0,0,0,1]
1981+
]
1982+
```
1983+
1984+
**Example:**
1985+
```javascript
1986+
circuit.appendGate("iswap", [0, 1]);
1987+
```
1988+
1989+
## xx
1990+
1991+
XX gate
19321992

19331993
**Qubits:** 2
19341994

@@ -1950,7 +2010,7 @@ Mølmer-Sørensen gate
19502010

19512011
**Example:**
19522012
```javascript
1953-
circuit.appendGate("ms", [0, 1], {
2013+
circuit.appendGate("xx", [0, 1], {
19542014
params: {
19552015
theta: "pi/2"
19562016
}
@@ -2019,6 +2079,70 @@ circuit.appendGate("zz", [0, 1], {
20192079
});
20202080
```
20212081

2082+
## xy
2083+
2084+
XY gate
2085+
2086+
**Qubits:** 2
2087+
2088+
**Parameters:**
2089+
2090+
- phi
2091+
2092+
2093+
**Matrix:**
2094+
```javascript
2095+
[
2096+
2097+
[1,0,0,0],
2098+
[0,"cos(phi / 2)","i * sin(phi / 2)",0],
2099+
[0,"i * sin(phi / 2)","cos(phi / 2)",0],
2100+
[0,0,0,1]
2101+
]
2102+
```
2103+
2104+
**Example:**
2105+
```javascript
2106+
circuit.appendGate("xy", [0, 1], {
2107+
params: {
2108+
phi: "pi/2"
2109+
}
2110+
});
2111+
```
2112+
2113+
## ms
2114+
2115+
Mølmer-Sørensen gate
2116+
2117+
**Qubits:** 2
2118+
2119+
**Parameters:**
2120+
2121+
- phi0
2122+
- phi1
2123+
2124+
2125+
**Matrix:**
2126+
```javascript
2127+
[
2128+
2129+
["1/sqrt(2)",0,0,"(-i*exp(-i*(phi0+phi1)))/sqrt(2)"],
2130+
[0,"1/sqrt(2)","(-i*exp(-i*(phi0-phi1)))/sqrt(2)",0],
2131+
[0,"(-i*exp(i*(phi0-phi1)))/sqrt(2)","1/sqrt(2)",0],
2132+
["(-i*exp(i*(phi0+phi1)))/sqrt(2)",0,0,"1/sqrt(2)"]
2133+
]
2134+
```
2135+
2136+
**Example:**
2137+
```javascript
2138+
circuit.appendGate("ms", [0, 1], {
2139+
params: {
2140+
phi0: "pi/2",
2141+
phi1: "pi/2"
2142+
}
2143+
});
2144+
```
2145+
20222146
## cr2
20232147

20242148
Controlled PI/2 rotation over Z-axis

0 commit comments

Comments
 (0)