Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #1998. #2082

Merged
merged 2 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/2082.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed bug were some matrices were wrongly found to be hermitian.
4 changes: 2 additions & 2 deletions qutip/cy/spmath.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ def zcsr_isherm(object A not None, double tol = qset.atol):
col = col_index[ptr]
nxt = out_row_index[col]
out_row_index[col] += 1
# We tested the structure already, so we can guarantee that
# these two elements correspond.
if row != col_index[nxt]:
return _zcsr_isherm_full(data, col_index, row_index, nrows, tolsq)
if not _conj_feq(data[ptr], data[nxt], tolsq):
return False
return True
Expand Down
11 changes: 11 additions & 0 deletions qutip/tests/test_spmath.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,16 @@ def test_zcsr_isherm_compare_implicit_zero():
assert not zcsr_isherm(base.T, tol=tol)


def test_issue_1998():
tol = 1e-12
base = sp.csr_matrix(np.array([[1,1,0],
[0,1,1],
[1,0,1]],
dtype=np.complex128))
base = fast_csr_matrix((base.data, base.indices, base.indptr), base.shape)
assert not zcsr_isherm(base, tol=tol)
assert not zcsr_isherm(base.T, tol=tol)


if __name__ == "__main__":
run_module_suite()