def test_minimize_one_norm_with_amp_damp_choi(): for noise_level in [0.01, 0.02, 0.03]: q = LineQubit(0) ideal_matrix = _operation_to_choi(H(q)) basis_matrices = [ _operation_to_choi( [H(q), gate(q), AmplitudeDampingChannel(noise_level)(q)]) for gate in [I, Z] ] # Append reset channel reset_kraus = channel(ResetChannel()) basis_matrices.append(kraus_to_choi(reset_kraus)) optimal_coeffs = minimize_one_norm(ideal_matrix, basis_matrices) represented_mat = sum( [eta * mat for eta, mat in zip(optimal_coeffs, basis_matrices)]) assert np.allclose(ideal_matrix, represented_mat) # Optimal analytic result by Takagi (arXiv:2006.12509) expected = (1.0 + noise_level) / (1.0 - noise_level) assert np.isclose(np.linalg.norm(optimal_coeffs, 1), expected)
def test_minimize_one_norm_with_amp_damp_superoperators(): for noise_level in [0.01, 0.02, 0.03]: damp_kraus = amplitude_damping_kraus(noise_level, num_qubits=1) damp_super = kraus_to_super(damp_kraus) ideal_matrix = kraus_to_super(channel(H)) basis_matrices = [ damp_super @ kraus_to_super(channel(gate)) @ ideal_matrix for gate in [I, Z] ] # Append reset channel reset_kraus = channel(ResetChannel()) basis_matrices.append(kraus_to_super(reset_kraus)) optimal_coeffs = minimize_one_norm(ideal_matrix, basis_matrices, tol=1.0e-6) represented_mat = sum( [eta * mat for eta, mat in zip(optimal_coeffs, basis_matrices)]) assert np.allclose(ideal_matrix, represented_mat) # Optimal analytic result by Takagi (arXiv:2006.12509) expected = (1.0 + noise_level) / (1.0 - noise_level) assert np.isclose(np.linalg.norm(optimal_coeffs, 1), expected)