Example #1
0
def qft_steps(N=1, swapping=True):
    """
    Quantum Fourier Transform operator on N qubits returning the individual
    steps as unitary matrices operating from left to right.

    Parameters
    ----------
    N: int
        Number of qubits.
    swap: boolean
        Flag indicating sequence of swap gates to be applied at the end or not.

    Returns
    -------
    U_step_list: list of qobj
        List of Hadamard and controlled rotation gates implementing QFT.

    """
    if N < 1:
        raise ValueError("Minimum value of N can be 1")

    U_step_list = []
    if N == 1:
        U_step_list.append(snot())
    else:
        for i in range(N):
            for j in range(i):
                U_step_list.append(
                    cphase(np.pi / (2**(i - j)), N, control=i, target=j))
            U_step_list.append(snot(N, i))
        if swapping is True:
            for i in range(N // 2):
                U_step_list.append(swap(N, [N - i - 1, i]))

    return U_step_list
Example #2
0
def test_F_avg_psi(sqrt_SWAP_basis, canonical_basis):
    F = krotov.functionals.F_avg(
        fw_states_T=sqrt_SWAP_basis,
        basis_states=canonical_basis,
        gate=qutip_gates.cphase(np.pi),
    )
    assert abs(F - 0.3) < 1e-14
Example #3
0
def qft_steps(N=1, swapping=True):
    """
    Quantum Fourier Transform operator on N qubits returning the individual
    steps as unitary matrices operating from left to right.
    
    Parameters
    ----------
    N: int
        Number of qubits.
    swap: boolean
        Flag indicating sequence of swap gates to be applied at the end or not.
    
    Returns
    -------
    U_step_list: list of qobj
        List of Hadamard and controlled rotation gates implementing QFT.
    
    """
    if N < 1:
        raise ValueError("Minimum value of N can be 1")
    
    U_step_list = []
    if N == 1:
        U_step_list.append(snot())
    else:
        for i in range(N):
            for j in range(i):
                U_step_list.append(cphase(np.pi/(2**(i-j)), N,
                                   control=i, target=j))
            U_step_list.append(snot(N, i))
        if swapping == True:
            for i in range(N//2):
                U_step_list.append(swap(N, [N-i-1, i]))

    return U_step_list
Example #4
0
def cphase_lv_full_objectives(canonical_basis):
    L = qutip.Qobj()  # dummy Liouvillian (won't be used)
    return krotov.objectives.gate_objectives(
        canonical_basis,
        gate=qutip_gates.cphase(np.pi),
        H=L,
        liouville_states_set='full',
    )
Example #5
0
def test_F_avg_rho(sqrt_SWAP_basis, canonical_basis):
    fw_states_T = [
        psi * phi.dag()
        for (psi, phi) in product(sqrt_SWAP_basis, sqrt_SWAP_basis)
    ]
    F = krotov.functionals.F_avg(
        fw_states_T=fw_states_T,
        basis_states=canonical_basis,
        gate=qutip_gates.cphase(np.pi),
    )
    assert abs(F - 0.3) < 1e-14
Example #6
0
def cphase_objectives(canonical_basis):
    H = qutip.Qobj()  # dummy Hamiltonian (won't be used)
    return krotov.objectives.gate_objectives(canonical_basis,
                                             gate=qutip_gates.cphase(np.pi),
                                             H=H)