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.
This lays the foundation for refactoring the entire indexing implementation. The basic idea is one we already discussed in the very beginning. Essentially, we want to use the following commutation relation for indexed bosonic operators
Similarly, for transition operators, we have
The problem here is the fact that the original product of transition operators on the left-hand side appears again on the right-hand side. This can potentially lead to infinite recursion. Currently, the solution to this problem is to store the fact that in the latter product$r \neq s$ on any sum expression that may occur. This has other problems, mostly the complex implementation and handling all kinds of special cases.
Instead, here I propose to implement the commutation relations using the above relations directly. To prevent infinite recursion on the transition operators, we store an additional field on indexed operators called
merge_events
, which is just aVector{UUID}
. Whenever two indexed transitions get rewritten according to the above, we generate a random UUID, currently usingUUIDs.uuid4()
, and store that on two copies of the original transition operators. Therefore, the operators behave just as they should when multiplied together with other operators, except when we find a shared UUID in themerge_events
. That can only occur when a product of indexed transitions was returned from the*
implementation and thus they have already been merged.To ensure that in products involving three or more indexed transitions, we also sort by the length of the
merge_events
vector.Since this needs to be a full rewrite, I'm opening this as a draft until we add back all the features. If we don't complete the rewrite within this PR, it at least serves as documentation of the fundamental concept, which seems to work.
Feature list:
FYI, @ChristophHotter and @j-moser