weylchamber.coordinates module¶
Calculation of Weyl chamber coordinates
Summary¶
Functions:
Calculate Weyl chamber coordinates \((c_1, c_2, c_3)\) |
|
Return the canonical gate for the given \((c_1, c_2, c_3)\) |
|
The inverse of |
|
Check if \((c_1, c_2, c_3)\) are in the given region of the Weyl chamber |
|
Check if the coordinates \((c_1, c_2, c_3)\) are inside the Weyl chamber |
|
Return a random two-qubit gate |
|
Return a random point \((c_1, c_2, c_3)\) in the Weyl chamber (units of π) |
|
Convert A from the canonical basis to the the "magic" Bell basis |
|
Return the region of the Weyl chamber the given point is in. |
__all__
: c1c2c3
, canonical_gate
, from_magic
, point_in_region
, point_in_weyl_chamber
, random_gate
, random_weyl_point
, to_magic
, weyl_region
Reference¶
- weylchamber.coordinates.c1c2c3(U, ndigits=8)[source]¶
Calculate Weyl chamber coordinates \((c_1, c_2, c_3)\)
Given U (in canonical basis), calculate the Weyl Chamber coordinates \((c_1, c_2, c_3)\), in units of π.
In order to facility numerical stability, the resulting coordinates are rounded to the given precision (cf. ndigits parameter of the built-in round function). Otherwise, rounding errors would likely to result in points that are not in the Weyl chamber, e.g. (0.1, 0.0, 1.0e-13)
Algorithm from Childs et al., PRA 68, 052311 (2003).
Example
>>> print("%.2f %.2f %.2f" % c1c2c3(qutip.core.gates.cnot())) 0.50 0.00 0.00
- weylchamber.coordinates.canonical_gate(c1, c2, c3)[source]¶
Return the canonical gate for the given \((c_1, c_2, c_3)\)
The canonical gate is defined as :rtype:
Qobj
\[\Op{A} = e^{i \frac{\pi}{2} \left( c_1 \Op{\sigma}_x \Op{\sigma}_x + c_2 \Op{\sigma}_y \Op{\sigma}_y + c_3 \Op{\sigma}_z \Op{\sigma}_z \right)}\]Example
>>> gate = qutip.Qobj( ... [[0.707107+0.000000j, 0.000000+0.000000j, 0.000000+0.000000j, 0.000000+0.707107j], ... [0.000000+0.000000j, 0.707107+0.000000j, 0.000000+0.707107j, 0.000000+0.000000j], ... [0.000000+0.000000j, 0.000000+0.707107j, 0.707107+0.000000j, 0.000000+0.000000j], ... [0.000000+0.707107j, 0.000000+0.000000j, 0.000000+0.000000j, 0.707107+0.000000j]], ... dims=[[2,2], [2,2]]) >>> U = canonical_gate(0.5,0,0) >>> assert (U - gate).norm() < 1e-5 >>> assert np.max(np.abs( ... np.array(c1c2c3(U)) - np.array([0.5, 0, 0]))) < 1e-15
- weylchamber.coordinates.from_magic(A)[source]¶
The inverse of
to_magic()
- Return type:
- weylchamber.coordinates.point_in_region(region, c1, c2, c3, check_weyl=False)[source]¶
Check if \((c_1, c_2, c_3)\) are in the given region of the Weyl chamber
The regions are ‘W0’ (between origin O and perfect entanglers polyhedron), ‘W0*’ (between point A1 and perfect entangler polyhedron), ‘W1’ (between A3 point and perfect entanglers polyhedron), and ‘PE’ (inside perfect entanglers polyhedron)
If the check_weyl parameter is given a True, raise a ValueError for any points outside of the Weyl chamber
- Return type:
Examples
>>> from weylchamber.visualize import WeylChamber >>> point_in_region('W0', *WeylChamber.O) True >>> point_in_region('W0', 0.2, 0.05, 0.0) True >>> point_in_region('W0', *WeylChamber.L) False >>> point_in_region('W0', *WeylChamber.Q) False >>> point_in_region('PE', *WeylChamber.Q) True >>> point_in_region('W0*', *WeylChamber.A1) True >>> point_in_region('W0*', 0.8, 0.1, 0.1) True >>> point_in_region('W1', *WeylChamber.A3) True >>> point_in_region('W1', 0.5, 0.4, 0.25) True >>> point_in_region('W1', 0.5, 0.25, 0) False >>> point_in_region('PE', 0.5, 0.25, 0) True
The function may be also applied against arrays:
>>> res = point_in_region('W1', [0.5,0.5], [0.4,0.25], [0.25,0.0]) >>> assert np.all(res == np.array([ True, False]))
- weylchamber.coordinates.point_in_weyl_chamber(c1, c2, c3, raise_exception=False)[source]¶
Check if the coordinates \((c_1, c_2, c_3)\) are inside the Weyl chamber
- Return type:
Examples
>>> BGATE = qutip.core.gates.berkeley() >>> point_in_weyl_chamber(*c1c2c3(BGATE)) True >>> point_in_weyl_chamber(*c1c2c3(qutip.identity([2, 2]))) True
The coordinates may also be array-like, in which case a boolean numpy array is returned.
>>> res = point_in_weyl_chamber( ... [0.0,0.5,0.8], [1.0,0.25,0.0], [1.0,0.25,0.0]) >>> assert np.all(res == np.array([False, True, True]))
If raise_exception is True, raise an
ValueError
if any values are outside the Weyl chamber.>>> try: ... point_in_weyl_chamber(1.0, 0.5, 0, raise_exception=True) ... except ValueError as e: ... print(e) (1, 0.5, 0) is not in the Weyl chamber
- weylchamber.coordinates.random_gate(region=None)[source]¶
Return a random two-qubit gate
If region is not None, the gate will be in the specified region of the Weyl chamber. The following region names are allowed: :rtype:
Qobj
‘SQ’: single qubit gates, consisting of the Weyl chamber points O, A2
‘PE’: polyhedron of perfect entanglers
‘W0’: region between point O and the PE polyhedron
‘W0*’: region between point A2 and the PE polyhedron
‘W1’: region between point A3 ([SWAP]) and the PE polyhedron
- weylchamber.coordinates.random_weyl_point(region=None)[source]¶
Return a random point \((c_1, c_2, c_3)\) in the Weyl chamber (units of π)
If region is given in [‘W0’, ‘W0*’, ‘W1’, ‘PE’], the point will be in the specified region of the Weyl chamber
Example
>>> c1, c2, c3 = random_weyl_point() >>> point_in_weyl_chamber(c1, c2, c3) True >>> c1, c2, c3 = random_weyl_point(region='PE') >>> point_in_region('PE', c1, c2, c3) True >>> c1, c2, c3 = random_weyl_point(region='W0') >>> point_in_region('W0', c1, c2, c3) True >>> c1, c2, c3 = random_weyl_point(region='W0*') >>> point_in_region('W0*', c1, c2, c3) True >>> c1, c2, c3 = random_weyl_point(region='W1') >>> point_in_region('W1', c1, c2, c3) True
- weylchamber.coordinates.to_magic(A)[source]¶
Convert A from the canonical basis to the the “magic” Bell basis
- Return type:
- weylchamber.coordinates.weyl_region(c1, c2, c3, check_weyl=True)[source]¶
Return the region of the Weyl chamber the given point is in.
- Return type:
- Returns:
One of ‘W0’, ‘W0*’, ‘W1’, ‘PE’
Examples
>>> from weylchamber.visualize import WeylChamber >>> print(weyl_region(*WeylChamber.O)) W0 >>> print(weyl_region(*WeylChamber.A1)) W0* >>> print(weyl_region(*WeylChamber.A3)) W1 >>> print(weyl_region(*WeylChamber.L)) PE >>> print(weyl_region(0.2, 0.05, 0.0)) W0 >>> print(weyl_region(0.8, 0.1, 0.1)) W0* >>> print(weyl_region(0.5, 0.25, 0)) PE >>> print(weyl_region(0.5, 0.4, 0.25)) W1 >>> try: ... weyl_region(1.0, 0.5, 0) ... except ValueError as e: ... print(e) (1, 0.5, 0) is not in the Weyl chamber >>> print(weyl_region(1.0, 0.1, 0, check_weyl=False)) W0*
Only scalar values are accepted for c1, c2, c3