Basic Rotation Gates#

from qualtran import Bloq, CompositeBloq, BloqBuilder, Signature, Register
from qualtran import QBit, QInt, QUInt, QAny
from qualtran.drawing import show_bloq, show_call_graph, show_counts_sigma
from typing import *
import numpy as np
import sympy
import cirq

XPowGate#

A gate that rotates around the X axis of the Bloch sphere.

The unitary matrix of XPowGate(exponent=t, global_shift=s) is: $$ e^{i \pi t (s + 1/2)}

(1)#\[\begin{bmatrix} \cos(\pi t /2) & -i \sin(\pi t /2) \\ -i \sin(\pi t /2) & \cos(\pi t /2) \end{bmatrix}\]

$$

Note in particular that this gate has a global phase factor of \(e^{i \pi t / 2}\) vs the traditionally defined rotation matrices about the Pauli X axis. See Rx for rotations without the global phase. The global phase factor can be adjusted by using the global_shift parameter when initializing.

Parameters#

  • exponent: The t in gate**t. Determines how much the eigenvalues of the gate are phased by. For example, eigenvectors phased by -1 when gate**1 is applied will gain a relative phase of e^{i pi exponent} when gate**exponent is applied (relative to eigenvectors unaffected by gate**1).

  • global_shift: Offsets the eigenvalues of the gate at exponent=1. In effect, this controls a global phase factor on the gate’s unitary matrix. The factor for global_shift=s is: exp(i * pi * s * t)

  • eps: precision for implementation of rotation.

Registers#

  • q: One-bit register.

References#

from qualtran.bloqs.basic_gates import XPowGate

Example Instances#

x_pow = XPowGate(exponent=0.123, eps=1e-8)

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([x_pow],
           ['`x_pow`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
x_pow_g, x_pow_sigma = x_pow.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(x_pow_g)
show_counts_sigma(x_pow_sigma)
../../_images/a2d7a49c4a34707c2a0da97dba62a090c053e130268ae5f672c52c2af334e230.svg

Counts totals:

  • X**0.123: 1

YPowGate#

A gate that rotates around the Y axis of the Bloch sphere.

The unitary matrix of YPowGate(exponent=t) is:

\[\begin{split} \begin{bmatrix} e^{i \pi t /2} \cos(\pi t /2) & - e^{i \pi t /2} \sin(\pi t /2) \\ e^{i \pi t /2} \sin(\pi t /2) & e^{i \pi t /2} \cos(\pi t /2) \end{bmatrix} \end{split}\]

Note in particular that this gate has a global phase factor of \(e^{i \pi t / 2}\) vs the traditionally defined rotation matrices about the Pauli Y axis. See Ry for rotations without the global phase. The global phase factor can be adjusted by using the global_shift parameter when initializing.

Parameters#

  • exponent: The t in gate**t. Determines how much the eigenvalues of the gate are phased by. For example, eigenvectors phased by -1 when gate**1 is applied will gain a relative phase of e^{i pi exponent} when gate**exponent is applied (relative to eigenvectors unaffected by gate**1).

  • global_shift: Offsets the eigenvalues of the gate at exponent=1. In effect, this controls a global phase factor on the gate’s unitary matrix. The factor for global_shift=s is: exp(i * pi * s * t)

  • eps: precision for implementation of rotation.

Registers#

  • q: One-bit register.

References#

from qualtran.bloqs.basic_gates import YPowGate

Example Instances#

y_pow = YPowGate(exponent=0.123, eps=1e-8)

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([y_pow],
           ['`y_pow`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
y_pow_g, y_pow_sigma = y_pow.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(y_pow_g)
show_counts_sigma(y_pow_sigma)
../../_images/0c3410b4f1875c502fe983caae3d7e2c33c3ac1210828c83add38dc008f0cf4e.svg

Counts totals:

  • Y**0.123: 1

ZPowGate#

A gate that rotates around the Z axis of the Bloch sphere.

The unitary matrix of ZPowGate(exponent=t, global_shift=s) is:

\[\begin{split} e^{i \pi s t} \begin{bmatrix} 1 & 0 \\ 0 & e^{i \pi t} \end{bmatrix} \end{split}\]

Note in particular that this gate has a global phase factor of \(e^{i\pi t/2}\) vs the traditionally defined rotation matrices about the Pauli Z axis. See Rz for rotations without the global phase. The global phase factor can be adjusted by using the global_shift parameter when initializing.

Parameters#

  • exponent: The t in gate**t. Determines how much the eigenvalues of the gate are phased by. For example, eigenvectors phased by -1 when gate**1 is applied will gain a relative phase of e^{i pi exponent} when gate**exponent is applied (relative to eigenvectors unaffected by gate**1).

  • global_shift: Offsets the eigenvalues of the gate at exponent=1. In effect, this controls a global phase factor on the gate’s unitary matrix. The factor for global_shift=s is: exp(i * pi * s * t)

  • eps: precision for implementation of rotation.

Registers#

  • qubits: One-bit register.

References#

from qualtran.bloqs.basic_gates import ZPowGate

Example Instances#

z_pow = ZPowGate(exponent=0.123, eps=1e-8)

Graphical Signature#

from qualtran.drawing import show_bloqs
show_bloqs([z_pow],
           ['`z_pow`'])

Call Graph#

from qualtran.resource_counting.generalizers import ignore_split_join
z_pow_g, z_pow_sigma = z_pow.call_graph(max_depth=1, generalizer=ignore_split_join)
show_call_graph(z_pow_g)
show_counts_sigma(z_pow_sigma)
../../_images/f3a1bffe5fe4be93c371a336c7407e3c367e00c5cfd36e28adce98f870179592.svg

Counts totals:

  • Z**0.123: 1