-
Notifications
You must be signed in to change notification settings - Fork 61
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
Random orthonormal basis in matrix_props #821
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #821 +/- ##
======================================
Coverage 97.8% 97.8%
======================================
Files 166 168 +2
Lines 3242 3261 +19
Branches 794 800 +6
======================================
+ Hits 3172 3191 +19
Misses 46 46
Partials 24 24 ☔ View full report in Codecov by Sentry. |
31fff60
to
8d6a78e
Compare
if not is_orthonormal(np.array(rand_orth_basis)): | ||
raise ValueError("Random orthonormal basis could not constructed.") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when is_real = False
, perhaps is_orthonormal
requires a tolerance?
return is_mutually_orthogonal(vectors) and np.allclose(np.dot(vectors, vectors.T), np.eye(vectors.shape[0])) |
@vprusso As discussed, here's the minimum working example when
import numpy as np
from toqito.rand import random_unitary
from toqito.matrix_props import is_orthonormal, is_unitary
from toqito.state_props import is_mutually_orthogonal
dim = 4
random_mat = random_unitary(dim, is_real=False)
if is_unitary(random_mat):
print("Random matrix is unitary.")
rand_orth_basis = [random_mat[:, i] for i in range(dim)]
if is_mutually_orthogonal(rand_orth_basis):
print("The generated basis elements are mutually orthogonal.")
if not is_orthonormal(np.array(rand_orth_basis)):
raise ValueError("Random orthonormal basis could not constructed.") Does not worknp.dot(np.array(rand_orth_basis), np.array(rand_orth_basis).T) Worksnp.dot(np.array(rand_orth_basis), np.conjugate(np.array(rand_orth_basis)).T) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment, but aside from that approved! LGTM!
Co-authored-by: Vincent Russo <vincentrusso1@gmail.com>
Description
Fixes #435
Changes
Notable changes that this PR has either accomplished or will accomplish. Feel free to add more lines to the itemized list
below.
Checklist
Before marking your PR ready for review, make sure you checked the following locally. If this is your first PR, you might be notified of some workflow failures after a maintainer has approved the workflow jobs to be run on your PR.
Additional information is available in the documentation.
ruff
for errors related to code style and formatting.pytest
.Sphinx
build can be checked locally for any failures related to your PRlinkcheck
to check for broken links in the documentationdoctest
to verify the examples in the function docstrings work as expected.