// Copyright © 2021-2022 HQS Quantum Simulations GmbH. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing permissions and
// limitations under the License.
use Complex64;
use ;
use ;
use *;
use PySet;
use CalculatorFloat;
use ;
use *;
use *;
use HashMap;
/// The general single qubit unitary gate.
///
/// .. math::
/// U =\begin{pmatrix}
/// \alpha_r+i \alpha_i & -\beta_r+i \beta_i \\\\
/// \beta_r+i \beta_i & \alpha_r-i\alpha_i
/// \end{pmatrix}
///
/// Args:
/// qubit: The qubit that the unitary gate is applied to.
/// alpha_r: The real part of the on-diagonal elements of the single-qubit unitary.
/// alpha_i: The imaginary part of the on-diagonal elements of the single-qubit unitary.
/// beta_r: The real part of the off-diagonal elements of the single-qubit unitary.
/// beta_i: The imaginary part of the off-diagonal elements of the single-qubit unitary.
/// global_phase: The global phase of the single-qubit unitary.
///
/// The XPower gate :math:`e^{-i \frac{\theta}{2} \sigma^x}`.
///
/// .. math::
/// U = \begin{pmatrix}
/// \cos(\frac{\theta}{2}) & 0 \\\\
/// 0 & \cos(\frac{\theta}{2})
/// \end{pmatrix}
/// + \begin{pmatrix}
/// 0 & -i \sin(\frac{\theta}{2}) \\\\
/// -i \sin(\frac{\theta}{2}) & 0
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
///
/// The YPower gate :math:`e^{-i \frac{\theta}{2} \sigma^y}`.
///
/// .. math::
/// U = \begin{pmatrix}
/// \cos(\frac{\theta}{2}) & 0 \\\\
/// 0 & \cos(\frac{\theta}{2})
/// \end{pmatrix}
/// + \begin{pmatrix}
/// 0 & - \sin(\frac{\theta}{2}) \\\\
/// \sin(\frac{\theta}{2}) & 0
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
///
/// The ZPower gate :math:`e^{-i \frac{\theta}{2} \sigma^z}`.
///
/// .. math::
/// U = \begin{pmatrix}
/// \cos(\frac{\theta}{2}) & 0 \\\\
/// 0 & \cos(\frac{\theta}{2})
/// \end{pmatrix}
/// + \begin{pmatrix}
/// - i \sin(\frac{\theta}{2}) & 0 \\\\
/// 0 & i \sin(\frac{\theta}{2})
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
///
/// The phase shift gate applied on state |1>.
///
/// Rotation around Z-axis by an arbitrary angle $\theta$ (AC Stark shift of the state |1>).
///
/// .. math::
/// U = \begin{pmatrix}
/// 1 & 0\\\\
/// 0 & e^{i \theta}
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
///
/// The phase shift gate applied on state |0>.
///
/// Rotation around Z-axis by an arbitrary angle $\theta$ (AC Stark shift of the state |0>).
///
/// .. math::
/// U = \begin{pmatrix}
/// e^{i \theta} & 0\\\\
/// 0 & 1
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
///
/// The Pauli X gate.
///
/// .. math::
/// U = \begin{pmatrix}
/// 0 & 1 \\\\
/// 1 & 0
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The Pauli Y gate.
///
/// .. math::
/// U = \begin{pmatrix}
/// 0 & -i \\\\
/// i & 0
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The Pauli Z gate.
///
/// .. math::
/// U = \begin{pmatrix}
/// 1 & 0 \\\\
/// 0 & -1
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The square root of the XPower gate :math:`e^{-i \frac{\pi}{4} \sigma^x}`.
///
/// .. math::
/// U = \frac{1}{\sqrt(2)}\begin{pmatrix}
/// 1 & -i \\\\
/// -i & 1
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The inverse square root XPower gate :math:`e^{i \frac{\pi}{2} \sigma^x}`.
///
/// .. math::
/// U = \frac{1}{\sqrt{2}} \begin{pmatrix}
/// 1 & i \\\\
/// i & 1
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The Hadamard gate.
///
/// .. math::
/// U = \frac{1}{\sqrt{2}} \begin{pmatrix}
/// 1 & 1\\\\
/// 1 & -1
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The S gate.
///
/// .. math::
/// U = \frac{1}{\sqrt{2}} \begin{pmatrix}
/// 1 & 0 \\\\
/// 0 & i
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// The T gate.
///
/// .. math::
/// U = \frac{1}{\sqrt{2}} \begin{pmatrix}
/// 1 & 0 \\\\
/// 0 & e^{i \frac{\pi}{4}}
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
///
/// Implements a rotation around an axis in the x-y plane in spherical coordinates.
///
/// .. math::
/// U = \begin{pmatrix}
/// \cos(\frac{\theta}{2}) & 0 \\\\
/// 0 & \cos(\frac{\theta}{2})
/// \end{pmatrix}
/// + \begin{pmatrix}
/// -i \sin(\frac{\theta}{2}) v_z & \sin(\frac{\theta}{2}) \left(-i v_x - v_y \right) \\\\
/// \sin(\frac{\theta}{2}) \left(-i v_x + v_y \right) & i \sin(\frac{\theta}{2}) v_z
/// \end{pmatrix}
///
/// with
///
/// .. math::
/// v_x = \sin(\theta_{sph}) \cos(\phi_{sph}) \ , \\
/// v_y = \sin(\theta_{sph}) \sin(\phi_{sph}) \ , \\
/// v_z = \cos(\theta_{sph}) \ .
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
/// spherical_theta (CalculatorFloat): The rotation axis, unit-vector spherical coordinates :math:`\theta_{sph}`.
/// spherical_phi (CalculatorFloat): The rotation axis, unit-vector spherical coordinates :math:`\phi_{sph}` gives the angle in the x-y plane.
///
/// Implements a rotation around an axis in the x-y plane in spherical coordinates.
///
/// .. math::
/// U = \begin{pmatrix}
/// \cos(\frac{\theta}{2}) & -i e^{-i \phi} \sin(\frac{\theta}{2})\\\\
/// -i e^{i \phi} \sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2})
/// \end{pmatrix}
///
/// Args:
/// qubit (int): The qubit the unitary gate is applied to.
/// theta (CalculatorFloat): The angle :math:`\theta` of the rotation.
/// phi (CalculatorFloat): The rotation axis, in spherical coordinates :math:`\phi_{sph}` gives the angle in the x-y plane.
///