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

Audit implementations of functions in matrixtools.py. #429

Closed
rileyjmurray opened this issue Apr 24, 2024 · 2 comments
Closed

Audit implementations of functions in matrixtools.py. #429

rileyjmurray opened this issue Apr 24, 2024 · 2 comments
Milestone

Comments

@rileyjmurray
Copy link
Contributor

The matrixtools.py file is almost 3000 lines long. Some functions in this file are much less efficient than they could be. For example, the check for a valid density matrix is implemented as follows:

return is_hermitian(mx, tol) and is_pos_def(mx, tol) and abs(trace(mx) - 1.0) < tol

This is inefficient because Python will evaluate the boolean conditions from left to right, so we should start with the cheapest check and end with the most expensive check. What we actually see is that the cheapest check happens at the end and the most expensive check (requiring an eigendecomposition) happens in the middle.

I suspect there are many functions with subtle inefficiencies like this. I'm creating this issue so that I can make sure to sit down and do a proper audit of these functions, rather than identifying inefficiencies and fixing them piecemeal.

@rileyjmurray
Copy link
Contributor Author

This is handled in PR #442.

@sserita
Copy link
Contributor

sserita commented Sep 24, 2024

Fixed with #442

@sserita sserita closed this as completed Sep 24, 2024
@sserita sserita added the fixed but not in release yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Sep 24, 2024
@sserita sserita removed the fixed but not in release yet Bug has been fixed, but isn't in an official release yet (just exists on a development branch) label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants