-
Notifications
You must be signed in to change notification settings - Fork 89
feat: add Fast Walsh–Hadamard Transform for Pauli-Liouville conversion #1736
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
base: master
Are you sure you want to change the base?
Conversation
| def _fht(vec): | ||
| """In-place 1D Fast Walsh–Hadamard Transform.""" | ||
| n = len(vec) | ||
| h = 1 | ||
| while h < n: | ||
| for i in range(0, n, h * 2): | ||
| for j in range(i, i + h): | ||
| a = vec[j] | ||
| b = vec[j + h] | ||
| vec[j] = a + b | ||
| vec[j + h] = a - b | ||
| h *= 2 | ||
| return vec |
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.
The 1D FWHT is already implemented in quantum_info.utils
https://qibo.science/qibo/stable/_modules/qibo/quantum_info/utils.html#hadamard_transform
|
|
||
| # Normalize if required (divide by sqrt of dimension) | ||
| if normalize: | ||
| import math |
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.
This does not need to be outside toplevel
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1736 +/- ##
==========================================
- Coverage 99.09% 98.92% -0.17%
==========================================
Files 80 80
Lines 13083 13106 +23
==========================================
+ Hits 12964 12965 +1
- Misses 119 141 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR introduces a new helper function
_to_pauli_liouville_fhtthat uses the Fast Walsh–Hadamard Transform to convert a Liouville superoperator to its Pauli‑Liouville representation in O(N log N) time. The function applies the transform along rows and columns and optionally normalizes the result. No existing functionality is removed; the new helper can be called by existing conversion routines for improved performance.Resolves or addresses issue #1632 (Fast conversion to and from Pauli basis). Adds 46 lines of code.