Refactor entropy function to also use spectrum directly#377
Refactor entropy function to also use spectrum directly#377lkdvos merged 4 commits intoQuantumKitHub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the entanglement entropy computation to allow calling entropy directly on a precomputed entanglement spectrum (e.g. the result of entanglement_spectrum(psi, loc)), instead of always recomputing the spectrum from the MPS.
Changes:
- Refactor
entropy(state, loc)to delegate to a newentropy(spectrum)overload. - Add
entropy(spectrum::AbstractVector{T})implementation that computes von Neumann entropy from the provided spectrum.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return entropy(entanglement_spectrum(state, loc)) | ||
| end | ||
| function entropy(spectrum::AbstractVector{T}) where {T} | ||
| S = zero(T) |
There was a problem hiding this comment.
The docstring above still documents only entropy(state, [site::Int]), but this PR introduces a new public overload entropy(spectrum). Please update the docstring/signature section to mention the spectrum form and clarify what spectrum structure is expected (sectorized vs plain vector).
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
|
Did you request the copilot review or is this another one of these Microsoft deciding to make all of their bullshit opt-out instead of opt-in all of a sudden again? |
|
I did not request anything. |
|
Ok, no worries I'm not against this, I would have just been pretty pissed off if Github all of a sudden would decide to just auto comment on all PRs with copilot. (also, the suggestions are actually not bad 😉 ) |
a0ee44c to
abea721
Compare
|
Will let the tests finish here first, then rebase, update the docstring and merge. |
abea721 to
244f16b
Compare
* Refactor entropy function to also use spectrum directly * specialize to SectorVector and add test * add infinite test * update docstring --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com>
* Refactor entropy function to also use spectrum directly * specialize to SectorVector and add test * add infinite test * update docstring --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com>
* Revert "Adapt extension (#384)" This reverts commit 2db4cb1. * Deep copying MPS with copy (#387) * broadcast copy over arrays * add basic tests for copying mps * fix variable naming mismatch * small fixes * format --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com> * Refactor entropy function to also use spectrum directly (#377) * Refactor entropy function to also use spectrum directly * specialize to SectorVector and add test * add infinite test * update docstring --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com> * Deep copying MPS with copy (#387) * broadcast copy over arrays * add basic tests for copying mps * fix variable naming mismatch * small fixes * format --------- Co-authored-by: Lukas Devos <ldevos98@gmail.com> * fix wrong testcase * alter JordanMPOTensor Adapt implementation * type stability chenanigans * bump TensorKit minimal version * more bypassing of type stability issues... * fix some tests * lost of git struggles * more git misery! * handle storagetype better * disable lts type stability tests --------- Co-authored-by: Akshay Shankar <sakshays.2000@gmail.com> Co-authored-by: Andreas Feuerpfeil <andreas.feuerpfeil@gmail.com>
* update compat to remove broken versions * update changelog * update citation file * update changelog for release
In this PR, I add the functionality to directly supply the entanglement spectrum obtained from e.g.
entanglement_spectrum(psi, loc)to calculate the von Neumann entropy.