Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if n1 != n2:
raise ValueError("Covariance matrix must be square.")
nmodes = n1 // 2
prev_prob = 1.0
mu = np.zeros(n1)
for k in range(nmodes):
probs1 = np.zeros([2], dtype=np.float64)
kk = np.arange(k + 1)
_, V_red = reduced_gaussian(mu, cov, kk)
Q = Qmat(V_red, hbar=hbar)
A = Amat(Q, hbar=hbar, cov_is_qmat=True)
O = Xmat(k + 1) @ A
indices = result + [0]
ind2 = indices + indices
probs1[0] = tor(np.complex128(reduction(O, ind2))).real
indices = result + [1]
ind2 = indices + indices
pref = np.sqrt(np.linalg.det(Q).real)
probs1a = probs1 / pref
probs2 = probs1a / prev_prob
probs2[1] = 1.0 - probs2[0]
probs1a[1] = probs2[1] * prev_prob
probs3 = np.maximum(
probs2, np.zeros_like(probs2)
if n1 != n2:
raise ValueError("Covariance matrix must be square.")
nmodes = n1 // 2
prev_prob = 1.0
mu = np.zeros(n1)
for k in range(nmodes):
probs1 = np.zeros([2], dtype=np.float64)
kk = np.arange(k + 1)
_, V_red = reduced_gaussian(mu, cov, kk)
Q = Qmat(V_red, hbar=hbar)
A = Amat(Q, hbar=hbar, cov_is_qmat=True)
O = Xmat(k + 1) @ A
indices = result + [0]
ind2 = indices + indices
probs1[0] = tor(np.complex128(reduction(O, ind2))).real
indices = result + [1]
ind2 = indices + indices
pref = np.sqrt(np.linalg.det(Q).real)
probs1a = probs1 / pref
probs2 = probs1a / prev_prob
probs2[1] = 1.0 - probs2[0]
probs1a[1] = probs2[1] * prev_prob
probs3 = np.maximum(
probs2, np.zeros_like(probs2)