@@ -187,7 +187,7 @@ def state_type_from_op_type(op_type):
187
187
return state_type_preferences
188
188
189
189
190
- def convert (state , to_type , basis , cp_penalty = 1e-7 , ideal_state = None , flatten_structure = False ):
190
+ def convert (state , to_type , basis , cptp_penalty = 1e-7 , ideal_state = None , flatten_structure = False ):
191
191
"""
192
192
TODO: update docstring
193
193
Convert SPAM vector to a new type of parameterization.
@@ -220,7 +220,7 @@ def convert(state, to_type, basis, cp_penalty=1e-7, ideal_state=None, flatten_st
220
220
unchanged. When `True`, composed and embedded operations are "flattened"
221
221
into a single state of the requested `to_type`.
222
222
223
- cp_penalty : float, optional
223
+ cptp_penalty : float, optional
224
224
CPTP penalty that gets factored into the optimization to find the resulting model
225
225
when converting to an error-generator type.
226
226
@@ -269,7 +269,7 @@ def convert(state, to_type, basis, cp_penalty=1e-7, ideal_state=None, flatten_st
269
269
errgen = _LindbladErrorgen .from_error_generator (2 ** (2 * num_qubits ), parameterization = to_type )
270
270
num_errgens = errgen .num_params
271
271
272
- #GLND for states suffers from "trivial gauge" freedom. This function identifies
272
+ #GLND for states suffers from "dumb gauge" freedom. This function identifies
273
273
#the physical directions to avoid this gauge.
274
274
def calc_physical_subspace (ideal_prep , epsilon = 1e-9 ):
275
275
@@ -293,13 +293,16 @@ def calc_physical_subspace(ideal_prep, epsilon = 1e-9):
293
293
294
294
#We use optimization to find the best error generator representation
295
295
#we only vary physical directions, not independent error generators
296
+
296
297
def _objfn (v ):
297
298
L_vec = _np .zeros (len (phys_directions [0 ]))
298
299
for coeff , phys_direction in zip (v ,phys_directions ):
299
300
L_vec += coeff * phys_direction
300
301
errorgen .from_vector (L_vec )
301
302
proc_matrix = _spl .expm (errorgen .to_dense ())
302
- return _np .linalg .norm (proc_matrix @ dense_st - dense_state ) + cp_penalty * sum_of_negative_choi_eigenvalues_gate (proc_matrix , basis )
303
+ #basis of to_dense() CHECK if always pp
304
+ dense_basis = Basis .cast ('pp' , (2 ** num_qubits )** 2 )
305
+ return _np .linalg .norm (proc_matrix @ dense_st - dense_state ) + cptp_penalty * sum_of_negative_choi_eigenvalues_gate (proc_matrix , dense_basis )
303
306
304
307
soln = _spo .minimize (_objfn , _np .zeros (len (phys_directions ), 'd' ), method = "Nelder-Mead" , options = {},
305
308
tol = 1e-13 ) # , callback=callback)
0 commit comments