Conversation
…524) `+`/`-` for `MPOHamiltonian`s required identical Jordan-tensor types on both sides, so combining a real-scalartype Hamiltonian with a complex-scalartype one (as `variance` does internally) silently fell through to a generic array `+` that can't reconcile differing Jordan-block virtual spaces. Add `promote_rule`s so mismatched Hamiltonians promote before combining, and fix the vector-shift `+` to promote storage type against the shift's eltype too. Also centers `variance(::FiniteMPS, ...)` on the energy before squaring, matching the `InfiniteMPS` branch, to avoid catastrophic cancellation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
+/-forMPOHamiltonians required identical Jordan-tensor types on both sides, so combining a real-scalartype Hamiltonian with a complex-scalartype one (asvariancedoes internally) fell through to a generic array+that can't reconcile differing Jordan-block virtual spaces, causingSpaceMismatch. Fixed by addingpromote_rules forJordanMPOTensor/FiniteMPOHamiltonian/InfiniteMPOHamiltonian, and promoting storage type in the vector-shift+as well.variance(::FiniteMPS, ...)now centersHon its expectation value before squaring (matching theInfiniteMPSbranch), avoiding catastrophic cancellation from computing⟨H²⟩ - ⟨H⟩²directly.Closes #524.
🤖 Generated with Claude Code