Skip to content

Commit

Permalink
qu. discord: increase maxiter
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmgray committed Jan 24, 2024
1 parent cdcdbcb commit e32accc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions quimb/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ def quantum_discord(
sysb=1,
method="COBYLA",
tol=1e-12,
maxiter=2**14,
):
"""Quantum Discord for two qubit density operator.
Expand Down Expand Up @@ -996,6 +997,9 @@ def trial_qd(a):
method=method,
bounds=((0, pi), (0, 2 * pi)),
tol=tol,
options=dict(
maxiter=maxiter,
),
)
if opt.success:
return opt.fun
Expand Down
6 changes: 4 additions & 2 deletions tests/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,10 @@ def test_auto_trace_out(self):
qd = qu.quantum_discord(p, [2, 2, 2], 0, 2)
assert 0 <= qd and qd <= 1

def test_qu_discord_diagonal(self):
p = np.random.rand(4)
@pytest.mark.parametrize("seed", range(10))
def test_qu_discord_diagonal(self, seed):
rng = np.random.RandomState(seed)
p = rng.random(size=4)
p /= np.sum(p)
rho = np.diag(p)
assert qu.quantum_discord(rho) < 1e-10
Expand Down

0 comments on commit e32accc

Please sign in to comment.