Beispiel #1
0
def single_squeezing_matrix(r, phi, cutoff, dtype=tf.complex64.as_numpy_dtype):
    """creates a single-mode squeezing matrix"""
    r = r.numpy()
    phi = phi.numpy()
    gate = squeezing_tw(r, phi, cutoff, dtype)

    # NOTE: tested independently in thewalrus
    def grad(dy):  # pragma: no cover
        Dr, Dphi = grad_squeezing_tw(gate, r, phi)
        grad_r = tf.math.real(tf.reduce_sum(dy * tf.math.conj(Dr)))
        grad_phi = tf.math.real(tf.reduce_sum(dy * tf.math.conj(Dphi)))
        return grad_r, grad_phi, None

    return gate, grad
def squeezing(r, theta, trunc):
    r"""The squeezing operator :math:`S(re^{i\theta})`.

    Uses the `squeezing operation from The Walrus`_ to calculate the squeezing.

    .. _`squeezing operation from The Walrus`: https://the-walrus.readthedocs.io/en/latest/code/api/thewalrus.fock_gradients.squeezing.html

    Args:
            r (float): the magnitude of the squeezing
            theta (float): the squeezing angle
            trunc (int): the Fock cutoff
    """

    ret = squeezing_tw(r, theta, cutoff=trunc)

    return ret