Skip to content

Conversation

@vaferreiQMT
Copy link

Howdy! This is the first of two PRs on transformations of PauliStrSums mainly focusing on improving the accuracy of Trotter methods. This PR specifically introduces methods to sort the terms within a PauliStrSum.

Main changes:

  • Core: added methods to calculate and apply permutations to sort a PauliStrSum.
  • API: Added methods to sort lexicographically and by magnitude (along with tests).
  • Documentation: added a Setters section for Pauli docs, for the sorting methods and future methods that transform Pauli strings.

Key details:

  • Since the sorting logic is only expected to be used outside hot loops, I have tried to keep the permutation logic as simple as possible and not reinvent the wheel, e.g. using std::sort rather than some custom implementation.
  • When applying the permutations we require both some temporary storage to construct and invert the permutation, however since the number of terms in a PauliStrSum generally only scales polynomially, this shouldn't be an issue (e.g. even for extremely large chemical systems this additional memory would be negligible)

I think that about covers it. As always happy to tweak, move or update stuff if anything jumps out at you.

Cheers!

@vaferreiQMT vaferreiQMT changed the title Pauli sorting Implement Pauli sorting Jan 21, 2026
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

Successfully merging this pull request may close these issues.

1 participant