Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
4ecb49c
Fixed issue 3640 by adding logic for complex imaginary numbers
1ucian0 Jan 3, 2020
9a25537
Merge branch 'master' into fixissue3640branch
sumitpuri Jan 3, 2020
834ba0c
Added test for display of 'pi'.
sumitpuri Jan 3, 2020
be364d8
Added test for displaying 'pi' for both real and imaginary parts of c…
sumitpuri Jan 3, 2020
d505325
Merge branch 'master' into fixissue3640branch
1ucian0 Jan 3, 2020
ca4a326
Release notes added for Fixes #3640
sumitpuri Jan 4, 2020
19ce29b
release notes
1ucian0 Jan 5, 2020
88cad51
Merge branch 'master' of github.com:Qiskit/qiskit-terra into fixissue…
1ucian0 Jan 5, 2020
36b7881
Fixes #3400
sumitpuri Jan 5, 2020
7325b45
Revert "Fixes #3400"
sumitpuri Jan 5, 2020
883e07f
Fixes #3400
sumitpuri Jan 5, 2020
569168b
Added release notes for Fixes #3400
sumitpuri Jan 5, 2020
b8b010e
Fixes #3684 Text drawer displays cU1 correctly.
sumitpuri Jan 5, 2020
d7f175f
Revert "Fixes #3684 Text drawer displays cU1 correctly."
sumitpuri Jan 7, 2020
6b40eb6
Fixes #3400 by adding jupyter-execute statement in the examples.
sumitpuri Jan 7, 2020
461e518
Fixes #3400 by adding jupyter-execute statement in the examples and c…
sumitpuri Jan 7, 2020
2abc824
Update qiskit/extensions/standard/crz.py
sumitpuri Jan 8, 2020
dc55cf8
Revert "Update qiskit/extensions/standard/crz.py"
sumitpuri Jan 8, 2020
91815f6
Fixes #3400 Added import numpy
sumitpuri Jan 8, 2020
ba224f7
#3400 added import numpy statements
sumitpuri Jan 9, 2020
4b1299a
Fixes #3400 incorporated comments from @nonhermitian
sumitpuri Jan 11, 2020
d923b8b
Fixes #3400 added more text.
sumitpuri Jan 11, 2020
c21aae1
Update qiskit/extensions/standard/rx.py
sumitpuri Jan 14, 2020
563f4ea
Added params for matrix generation.
sumitpuri Jan 14, 2020
abf3074
Removed Matrix representation from rz.py
sumitpuri Jan 14, 2020
2ceb42a
Update qiskit/extensions/standard/z.py
sumitpuri Jan 25, 2020
0d79b67
Update qiskit/extensions/standard/y.py
sumitpuri Jan 25, 2020
52f4387
Update qiskit/extensions/standard/y.py
sumitpuri Jan 25, 2020
c8c1956
Update qiskit/extensions/standard/u2.py
sumitpuri Jan 25, 2020
28b9417
Update qiskit/extensions/standard/cx.py
sumitpuri Jan 25, 2020
b201cef
Update qiskit/extensions/standard/u3.py
sumitpuri Jan 25, 2020
4f8a9ca
Fixes #3400 incorporated suggestions
sumitpuri Jan 25, 2020
985dd33
Merge branch 'fixissue3640branch' of https://github.com/sumitpuri/qis…
sumitpuri Jan 25, 2020
7271c91
Fixes #3400 H gate description.
sumitpuri Jan 25, 2020
bf56398
Added matrix for cswap
sumitpuri Jan 25, 2020
c927d96
Consistency with removing hyphen.
sumitpuri Jan 26, 2020
c58525d
Fixes #3400 consistency
sumitpuri Jan 26, 2020
83417c9
Fixing style
sumitpuri Jan 26, 2020
9f2eecf
Rearranged the import order
sumitpuri Jan 26, 2020
2df8e5d
Fixes matrix representation
sumitpuri Jan 26, 2020
ef91800
Incorporating suggestions
sumitpuri Jan 26, 2020
524f6db
Incorporated comments (#3400)
sumitpuri Jan 31, 2020
c8391c3
Merge branch 'fixissue3640branch' of https://github.com/sumitpuri/qis…
kdk Feb 3, 2020
df39bf7
Merge branch 'master' into fixissue3640branch
kdk Feb 3, 2020
41b89cc
Update qiskit/extensions/standard/swap.py
sumitpuri Feb 3, 2020
0c7debc
Update qiskit/extensions/standard/h.py
sumitpuri Feb 4, 2020
59a917b
Update qiskit/extensions/standard/swap.py
sumitpuri Feb 4, 2020
4cb5190
Update qiskit/extensions/standard/x.py
sumitpuri Feb 4, 2020
4abf422
Merge branch 'master' into fixissue3640branch
kdk Feb 6, 2020
b48a6be
Fix lint failures following merge resolution.
kdk Feb 6, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions qiskit/extensions/standard/h.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,29 @@ def to_matrix(self):

@deprecate_arguments({'q': 'qubit'})
def h(self, qubit, *, q=None): # pylint: disable=invalid-name,unused-argument
"""Apply H to q."""
"""Apply Hadamard (H) gate to a specified qubit (qubit).
An H gate implements a rotation of pi about the axis (x + z)/sqrt(2) on the Bloch sphere.
This gate is canonically used to rotate the qubit state from |0⟩ to |+⟩ or |1⟩ to |-⟩.
Comment thread
sumitpuri marked this conversation as resolved.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(1)
circuit.h(0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.h import HGate
HGate().to_matrix()
"""
return self.append(HGate(), [qubit], [])


Expand Down Expand Up @@ -132,7 +154,29 @@ def to_matrix(self):
@deprecate_arguments({'ctl': 'control_qubit', 'tgt': 'target_qubit'})
def ch(self, control_qubit, target_qubit, # pylint: disable=invalid-name
*, ctl=None, tgt=None): # pylint: disable=unused-argument
"""Apply CH from ctl to tgt."""
"""Apply cH gate from a specified control (control_qubit) to target (target_qubit) qubit.
This gate is canonically used to rotate the qubit state from |0⟩ to |+⟩ and and |1⟩ to |−⟩
when the control qubit is in state |1>.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(2)
circuit.ch(0,1)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.h import CHGate
CHGate().to_matrix()
"""
return self.append(CHGate(), [control_qubit, target_qubit], [])


Expand Down
26 changes: 23 additions & 3 deletions qiskit/extensions/standard/iden.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,30 @@ def to_matrix(self):

@deprecate_arguments({'q': 'qubit'})
def iden(self, qubit, *, q=None): # pylint: disable=unused-argument
"""Apply Identity to qubit.
"""Apply Identity to to a specified qubit (qubit).

Identity gate corresponds to a single-qubit gate wait cycle,
and should not be optimized or unrolled (it is an opaque gate).
The Identity gate ensures that nothing is applied to a qubit for one unit
of gate time. It leaves the quantum states |0> and |1> unchanged.
The Identity gate should not be optimized or unrolled (it is an opaque gate).

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(1)
circuit.iden(0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.iden import IdGate
IdGate().to_matrix()
"""
return self.append(IdGate(), [qubit], [])

Expand Down
26 changes: 25 additions & 1 deletion qiskit/extensions/standard/rx.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,31 @@ def to_matrix(self):

@deprecate_arguments({'q': 'qubit'})
def rx(self, theta, qubit, *, q=None): # pylint: disable=invalid-name,unused-argument
"""Apply Rx to q."""
"""Apply Rx gate with angle theta to a specified qubit (qubit).
An Rx gate implements a theta radian rotation of the qubit state vector about the
x axis of the Bloch sphere.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit.circuit import QuantumCircuit, Parameter

theta = Parameter('θ')
circuit = QuantumCircuit(1)
circuit.rx(theta,0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

import numpy
from qiskit.extensions.standard.rx import RXGate
RXGate(numpy.pi/2).to_matrix()
"""
return self.append(RXGate(theta), [qubit], [])


Expand Down
26 changes: 25 additions & 1 deletion qiskit/extensions/standard/ry.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,31 @@ def to_matrix(self):

@deprecate_arguments({'q': 'qubit'})
def ry(self, theta, qubit, *, q=None): # pylint: disable=invalid-name,unused-argument
"""Apply Ry to qubit."""
"""Apply Ry gate with angle theta to a specified qubit (qubit).
An Ry gate implements a theta radian rotation of the qubit state vector about the
y axis of the Bloch sphere.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit.circuit import QuantumCircuit, Parameter

theta = Parameter('θ')
circuit = QuantumCircuit(1)
circuit.ry(theta,0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

import numpy
from qiskit.extensions.standard.ry import RYGate
RYGate(numpy.pi/2).to_matrix()
"""
return self.append(RYGate(theta), [qubit], [])


Expand Down
36 changes: 34 additions & 2 deletions qiskit/extensions/standard/rz.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,23 @@ def inverse(self):

@deprecate_arguments({'q': 'qubit'})
def rz(self, phi, qubit, *, q=None): # pylint: disable=invalid-name,unused-argument
"""Apply Rz to qubit."""
"""Apply Rz gate with angle phi to a specified qubit (qubit).
An Rz gate implemements a phi radian rotation of the qubit state vector about the
z axis of the Bloch sphere.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit.circuit import QuantumCircuit, Parameter

phi = Parameter('φ')
circuit = QuantumCircuit(1)
circuit.rz(phi,0)
circuit.draw()
"""
return self.append(RZGate(phi), [qubit], [])


Expand Down Expand Up @@ -111,7 +127,23 @@ def inverse(self):
@deprecate_arguments({'ctl': 'control_qubit', 'tgt': 'target_qubit'})
def crz(self, theta, control_qubit, target_qubit,
*, ctl=None, tgt=None): # pylint: disable=unused-argument
"""Apply crz from ctl to tgt with angle theta."""
"""Apply cRz gate from a specified control (control_qubit) to target (target_qubit) qubit
with angle theta. A cRz gate implements a theta radian rotation of the qubit state vector
about the z axis of the Bloch sphere when the control qubit is in state |1>.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit.circuit import QuantumCircuit, Parameter

theta = Parameter('θ')
circuit = QuantumCircuit(2)
circuit.crz(theta,0,1)
circuit.draw()
"""
return self.append(CrzGate(theta), [control_qubit, target_qubit], [])


Expand Down
48 changes: 46 additions & 2 deletions qiskit/extensions/standard/s.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,57 @@ def to_matrix(self):

@deprecate_arguments({'q': 'qubit'})
def s(self, qubit, *, q=None): # pylint: disable=invalid-name,unused-argument
"""Apply S to qubit."""
"""Apply S gate to a specified qubit (qubit).
An S gate implements a pi/2 rotation of the qubit state vector about the
z axis of the Bloch sphere.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(1)
circuit.s(0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.s import SGate
SGate().to_matrix()
"""
return self.append(SGate(), [qubit], [])


@deprecate_arguments({'q': 'qubit'})
def sdg(self, qubit, *, q=None): # pylint: disable=unused-argument
"""Apply Sdg to qubit."""
"""Apply Sdg gate to a specified qubit (qubit).
An Sdg gate implements a -pi/2 rotation of the qubit state vector about the
z axis of the Bloch sphere. It is the inverse of S gate.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(1)
circuit.sdg(0)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.s import SdgGate
SdgGate().to_matrix()
"""
return self.append(SdgGate(), [qubit], [])


Expand Down
59 changes: 57 additions & 2 deletions qiskit/extensions/standard/swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,28 @@ def to_matrix(self):


def swap(self, qubit1, qubit2):
"""Apply SWAP from qubit1 to qubit2."""
"""Apply SWAP gate to a pair specified qubits (qubit1, qubit2).
The SWAP gate canonically swaps the states of two qubits.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(2)
circuit.swap(0,1)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.swap import SwapGate
SwapGate().to_matrix()
"""
return self.append(SwapGate(), [qubit1, qubit2], [])


Expand Down Expand Up @@ -112,13 +133,47 @@ def inverse(self):
"""Invert this gate."""
return FredkinGate() # self-inverse

def to_matrix(self):
"""Return a Numpy.array for the Fredkin (CSWAP) gate."""
return numpy.array([[1, 0, 0, 0, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0, 0],
[0, 0, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 0, 0, 1]], dtype=complex)


@deprecate_arguments({'ctl': 'control_qubit',
'tgt1': 'target_qubit1',
'tgt2': 'target_qubit2'})
def cswap(self, control_qubit, target_qubit1, target_qubit2,
*, ctl=None, tgt1=None, tgt2=None): # pylint: disable=unused-argument
"""Apply Fredkin to circuit."""
"""Apply Fredkin (CSWAP) gate from a specified control (control_qubit) to target1
(target_qubit1) and target2 (target_qubit2) qubits. The CSWAP gate is canonically
used to swap the qubit states of target1 and target2 when the control qubit is in
state |1>.

Examples:

Circuit Representation:

.. jupyter-execute::

from qiskit import QuantumCircuit

circuit = QuantumCircuit(3)
circuit.cswap(0,1,2)
circuit.draw()

Matrix Representation:

.. jupyter-execute::

from qiskit.extensions.standard.swap import FredkinGate
FredkinGate().to_matrix()
"""
return self.append(FredkinGate(),
[control_qubit, target_qubit1, target_qubit2],
[])
Expand Down
Loading