File tree 1 file changed +1
-27
lines changed
tutorials-v5/optimal-control
1 file changed +1
-27
lines changed Original file line number Diff line number Diff line change 179
179
```
180
180
181
181
``` python
182
- def overlap (U_target , U_f ):
183
- """
184
- Calculate the overlap between the target unitary U_target and
185
- the final unitary U_f.
186
-
187
- Parameters:
188
- U_target (qutip.Qobj): Target unitary operator.
189
- U_f (qutip.Qobj): Final unitary operator.
190
-
191
- Returns:
192
- float: Real part of the overlap value.
193
- float: Fidelity (absolute square of the overlap).
194
- """
195
- # dividing over U_target.shape[0] is for normalization
196
- overlap_value = (U_target.dag() * U_f).tr() / U_target.shape[0 ]
197
- fidelity = abs (overlap_value) ** 2
198
- return overlap_value.real, fidelity
199
-
200
-
201
- # Example usage
202
- overlap_real, fidelity = overlap(U_target, U_f)
203
- print (f " Overlap (real part): { overlap_real} " )
204
- print (f " Fidelity: { fidelity} " )
205
- ```
206
-
207
- ``` python
208
- np.shape(U_f)
182
+ print (f " Fidelity: { qt.process_fidelity(U_f, U_target)} " )
209
183
```
210
184
211
185
## Proceess tomography
You can’t perform that action at this time.
0 commit comments