Skip to content

Commit

Permalink
Compatible naming of fid function
Browse files Browse the repository at this point in the history
  • Loading branch information
nwittler committed Feb 6, 2021
1 parent 2833c89 commit 6ac6ba0
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion c3/libraries/fidelities.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def average_infid_CZ(U_dict: dict, index, dims, eval, proj=True):


@fid_reg_deco
def average_infid(U_dict: dict, gate: str, index, dims, proj=True):
def average_infid_simult(U_dict: dict, gate: str, index, dims, proj=True):
"""
Average fidelity uses the Pauli basis to compare. Thus, perfect gates are
always 2x2 (per qubit) and the actual unitary needs to be projected down.
Expand All @@ -295,6 +295,31 @@ def average_infid(U_dict: dict, gate: str, index, dims, proj=True):
return infid


@fid_reg_deco
def average_infid(U_dict: dict, gate: str, index, dims, proj=True):
"""
Average fidelity uses the Pauli basis to compare. Thus, perfect gates are
always 2x2 (per qubit) and the actual unitary needs to be projected down.
Parameters
----------
U_dict : dict
Contains unitary representations of the gates, identified by a key.
index : int
Index of the qubit(s) in the Hilbert space to be evaluated
dims : list
List of dimensions of qubits
proj : boolean
Project to computational subspace
"""
U = U_dict[gate]
U_ideal = tf.Variable(
perfect_gate(gate, index, dims=[2] * len(dims)), dtype=tf.complex128
)
infid = 1 - tf_average_fidelity(U, U_ideal, lvls=dims)
return infid


@fid_reg_deco
def average_infid_set(U_dict: dict, index, dims, eval, proj=True):
"""
Expand Down

0 comments on commit 6ac6ba0

Please sign in to comment.