@@ -517,8 +517,8 @@ def _jacobian_fn(gauge_group_el):
517
517
# d(op_term) = S_inv * (-dS * S_inv * G * S + G * dS) = S_inv * (-dS * G' + G * dS)
518
518
# Note: (S_inv * G * S) is G' (transformed G)
519
519
wt = item_weights .get (lbl , opWeight )
520
- left = - 1 * _np .dot (dS , mdl_post .operations [lbl ].to_dense (on_space = 'minimal' )) # shape (n,d1,d2)
521
- right = _np .swapaxes (_np .dot (G .to_dense (on_space = 'minimal' ), dS ), 0 , 1 ) # shape (d1,n,d2) -> (n,d1,d2)
520
+ left = - 1 * _np .dot (dS , mdl_post .operations [lbl ].to_dense ('minimal' )) # shape (n,d1,d2)
521
+ right = _np .swapaxes (_np .dot (G .to_dense ('minimal' ), dS ), 0 , 1 ) # shape (d1,n,d2) -> (n,d1,d2)
522
522
result = _np .swapaxes (_np .dot (S_inv , left + right ), 1 , 2 ) # shape (d1, d2, n)
523
523
result = result .reshape ((d ** 2 , n )) # must copy b/c non-contiguous
524
524
my_jacMx [start :start + d ** 2 ] = wt * result
@@ -530,8 +530,8 @@ def _jacobian_fn(gauge_group_el):
530
530
wt = item_weights .get (ilbl , opWeight )
531
531
for lbl , G in Inst .items ():
532
532
# same calculation as for operation terms
533
- left = - 1 * _np .dot (dS , mdl_post .instruments [ilbl ][lbl ].to_dense (on_space = 'minimal' )) # (n,d1,d2)
534
- right = _np .swapaxes (_np .dot (G .to_dense (on_space = 'minimal' ), dS ), 0 , 1 ) # (d1,n,d2) -> (n,d1,d2)
533
+ left = - 1 * _np .dot (dS , mdl_post .instruments [ilbl ][lbl ].to_dense ('minimal' )) # (n,d1,d2)
534
+ right = _np .swapaxes (_np .dot (G .to_dense ('minimal' ), dS ), 0 , 1 ) # (d1,n,d2) -> (n,d1,d2)
535
535
result = _np .swapaxes (_np .dot (S_inv , left + right ), 1 , 2 ) # shape (d1, d2, n)
536
536
result = result .reshape ((d ** 2 , n )) # must copy b/c non-contiguous
537
537
my_jacMx [start :start + d ** 2 ] = wt * result
@@ -544,7 +544,7 @@ def _jacobian_fn(gauge_group_el):
544
544
# Note: (S_inv * rho) is transformed rho
545
545
wt = item_weights .get (lbl , spamWeight )
546
546
Sinv_dS = _np .dot (S_inv , dS ) # shape (d1,n,d2)
547
- result = - 1 * _np .dot (Sinv_dS , rho .to_dense (on_space = 'minimal' )) # shape (d,n)
547
+ result = - 1 * _np .dot (Sinv_dS , rho .to_dense ('minimal' )) # shape (d,n)
548
548
my_jacMx [start :start + d ] = wt * result
549
549
start += d
550
550
@@ -554,7 +554,7 @@ def _jacobian_fn(gauge_group_el):
554
554
for lbl , E in povm .items ():
555
555
# d(ET_term) = E.T * dS
556
556
wt = item_weights .get (povmlbl + "_" + lbl , spamWeight )
557
- result = _np .dot (E .to_dense (on_space = 'minimal' )[None , :], dS ).T # shape (1,n,d2).T => (d2,n,1)
557
+ result = _np .dot (E .to_dense ('minimal' )[None , :], dS ).T # shape (1,n,d2).T => (d2,n,1)
558
558
my_jacMx [start :start + d ] = wt * result .squeeze (2 ) # (d2,n)
559
559
start += d
560
560
@@ -851,7 +851,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
851
851
852
852
#get sgn(denMx) == d(|denMx|_Tr)/d(denMx) in std basis
853
853
# dmDim = denMx.shape[0]
854
- denMx = _tools .vec_to_stdmx (prepvec .to_dense (on_space = 'minimal' )[:, None ], op_basis )
854
+ denMx = _tools .vec_to_stdmx (prepvec .to_dense ('minimal' )[:, None ], op_basis )
855
855
assert (_np .linalg .norm (denMx - denMx .T .conjugate ()) < 1e-4 ), \
856
856
"denMx should be Hermitian!"
857
857
@@ -865,7 +865,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
865
865
# get d(prepvec')/dp = d(S_inv * prepvec)/dp in op_basis [shape == (n,dim)]
866
866
# = (-S_inv*dS*S_inv) * prepvec = -S_inv*dS * prepvec'
867
867
Sinv_dS = _np .dot (S_inv , dS ) # shape (d1,n,d2)
868
- dVdp = - 1 * _np .dot (Sinv_dS , prepvec .to_dense (on_space = 'minimal' )[:, None ]).squeeze (2 ) # shape (d,n,1) => (d,n)
868
+ dVdp = - 1 * _np .dot (Sinv_dS , prepvec .to_dense ('minimal' )[:, None ]).squeeze (2 ) # shape (d,n,1) => (d,n)
869
869
assert (dVdp .shape == (d , n ))
870
870
871
871
# denMx = sum( spamvec[i] * Bmx[i] )
@@ -890,7 +890,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
890
890
for lbl , effectvec in povm .items ():
891
891
892
892
#get sgn(EMx) == d(|EMx|_Tr)/d(EMx) in std basis
893
- EMx = _tools .vec_to_stdmx (effectvec .to_dense (on_space = 'minimal' )[:, None ], op_basis )
893
+ EMx = _tools .vec_to_stdmx (effectvec .to_dense ('minimal' )[:, None ], op_basis )
894
894
# dmDim = EMx.shape[0]
895
895
assert (_np .linalg .norm (EMx - EMx .T .conjugate ()) < 1e-4 ), \
896
896
"denMx should be Hermitian!"
@@ -905,7 +905,7 @@ def _spam_penalty_jac_fill(spam_penalty_vec_grad_to_fill, mdl_pre, mdl_post,
905
905
# get d(effectvec')/dp = [d(effectvec.T * S)/dp].T in op_basis [shape == (n,dim)]
906
906
# = [effectvec.T * dS].T
907
907
# OR = dS.T * effectvec
908
- pre_effectvec = mdl_pre .povms [povmlbl ][lbl ].to_dense (on_space = 'minimal' )[:, None ]
908
+ pre_effectvec = mdl_pre .povms [povmlbl ][lbl ].to_dense ('minimal' )[:, None ]
909
909
dVdp = _np .dot (pre_effectvec .T , dS ).squeeze (0 ).T
910
910
# shape = (1,d) * (n, d1,d2) = (1,n,d2) => (n,d2) => (d2,n)
911
911
assert (dVdp .shape == (d , n ))
0 commit comments