Parametrized#

class discopy.quantum.gates.Parametrized(name, dom, cod, data=None, **params)[source]#

Bases: Box

Abstract class for parametrized boxes in a quantum circuit.

Parameters:
  • name (str) – Name of the parametrized class, e.g. "CRz".

  • dom (discopy.quantum.circuit.Ty) – Domain and codomain.

  • cod (discopy.quantum.circuit.Ty) – Domain and codomain.

  • data (any) – Data of the box, potentially with free symbols.

  • datatype (type) – Type to cast whenever there are no free symbols.

Example

>>> from sympy.abc import phi
>>> from sympy import pi, exp, I
>>> assert Rz(phi)\
...     == Parametrized('Rz', qubit, qubit, data=phi, is_mixed=False)
>>> assert Rz(phi).array[0,0] == exp(-1.0 * I * pi * phi)
>>> c = Rz(phi) >> Rz(-phi)
>>> assert list(c.eval().array.flatten()) == [1, 0, 0, 1]
>>> assert c.lambdify(phi)(.25) == Rz(.25) >> Rz(-.25)