-
Notifications
You must be signed in to change notification settings - Fork 33
Refactor expectation_value implementations
#423
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
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1ee9641
Slight reorganization
leburgel 01f20b9
Remove environment type restriction in expectation value
leburgel f0da3af
Reuse corner absorption
leburgel 5ba32fe
Split off local expectation value hook, and route dense TensorMap ver…
leburgel 35788f4
Evaluate `BPEnv` expectation values in exactly the same way, and add …
leburgel e5facb8
Remove unused `contract_local_operator`
leburgel 496f063
Add vanity line break
leburgel 463f48d
Drop more environment type specifiers
leburgel 00c33b6
Remove unused method (accidentally missed during deprecation)
leburgel e1cf86e
Drop more type specs
leburgel 15d2330
Restore contract_local_operator for future use
leburgel f9b10f2
More merging
leburgel 9b24a74
Reorganize `expectation_value` code
leburgel 16bdf9d
Fix absorb docstrings
leburgel 3a0af9c
Fix typo
leburgel f1b38d6
Fix up more docstrings
leburgel 4d021cd
Add network type annotation
leburgel c00fe08
Revert docstring to match implementation
leburgel d92d6c2
Clarify use of supertrace and add explicit reference.
leburgel 68b6514
Try to make docstrings more specific
leburgel 68002ce
Merge branch 'main' into lb/expval
leburgel cd81b82
Update BP patch contraction comment
leburgel 1685a57
Remove `contractcheck` altogether
leburgel d8ef1b6
Fix typo
leburgel 7f4b40b
Reorganize files
leburgel fc4f877
Merge branch 'main' into lb/expval
leburgel 42c39ab
Make `absorb` docstrings more accurate
leburgel 741bd39
Be explicit about supertrace usage
leburgel 6c24758
Move basic label generators up into `util`
leburgel da75332
Remove non-existing default value from docstring
leburgel c5a0ead
Always point to generic `_contract_densitymatrix` fallback
leburgel 80a3efb
Be more explicit about supertrace again
leburgel 49496f4
Docstring cleanups
Yue-Zhengyuan 814667f
Latest runic v1.10 formatting
Yue-Zhengyuan 15548b3
Merge remote-tracking branch 'origin/main' into lb/expval
leburgel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Absorption of matrices into tensor legs | ||
| # --------------------------------------- | ||
|
|
||
| """ | ||
| absorb_left( | ||
| A::AbstractTensorMap{<:Any, S}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
|
|
||
| Absorb a matrix `C` into the left of a tensor map `A` by contracting the first index of `A` with the last index of `C`. | ||
| """ | ||
| function absorb_left( | ||
| A::AbstractTensorMap{<:Any, S}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
| pC = (codomainind(C), domainind(C)) | ||
| pA = ((codomainind(A)[1],), (codomainind(A)[2:end]..., domainind(A)...)) | ||
| pCA = (codomainind(A), domainind(A)) | ||
| return tensorcontract(C, pC, false, A, pA, false, pCA) | ||
| end | ||
| function absorb_left( | ||
| P::AbstractTensorMap{<:Any, S, 1, N}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S, N} | ||
| return twistnondual(C, 2) * P | ||
| end | ||
|
|
||
| """ | ||
| absorb_right( | ||
| A::AbstractTensorMap{<:Any, S}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
|
|
||
| Absorb a matrix `C` into the right of a tensor map `A` by contracting the first index in the domain of `A` with the first index of `C`. | ||
| In the case where `A` has only one space in its domain, this can be interpreted as contracting the last leg of `A` with the first leg of `C`. | ||
| """ | ||
| function absorb_right( | ||
| A::AbstractTensorMap{<:Any, S}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
| pA = ((codomainind(A)..., domainind(A)[2:end]...), (domainind(A)[1],)) | ||
| pC = (codomainind(C), domainind(C)) | ||
| pAC = (codomainind(A), (domainind(A)[end], domainind(A)[1:(end - 1)]...)) | ||
| return tensorcontract(A, pA, false, C, pC, false, pAC) | ||
| end | ||
| function absorb_right( | ||
| E::AbstractTensorMap{<:Any, S, N, 1}, C::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S, N} | ||
| return E * twistdual(C, 1) | ||
| end | ||
|
|
||
| """ | ||
| absorb_left_right( | ||
| A::AbstractTensorMap{<:Any, S}, | ||
| CL::AbstractTensorMap{<:Any, S, 1, 1}, | ||
| CR::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
|
|
||
| Absorb matrices `CL` and `CR` into the left and right of a tensor map `A` by contracting the first leg of `A` with the second leg of `CL` and the first domain index of `A` with the first leg of `CR`. | ||
| """ | ||
| function absorb_left_right( | ||
| A::AbstractTensorMap{<:Any, S}, | ||
| CL::AbstractTensorMap{<:Any, S, 1, 1}, | ||
| CR::AbstractTensorMap{<:Any, S, 1, 1} | ||
| ) where {S} | ||
| return absorb_right(absorb_left(A, CL), CR) | ||
| end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.