-
Notifications
You must be signed in to change notification settings - Fork 23
Linear form network #228
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
Merged
Linear form network #228
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c845947
Blah
JoeyT1994 90c7251
Merge remote-tracking branch 'origin/main'
JoeyT1994 86f3087
Merge remote-tracking branch 'upstream/main'
JoeyT1994 6ff0cd5
Bug fix in current ortho. Change test
JoeyT1994 34e8e5e
Merge remote-tracking branch 'upstream/main'
JoeyT1994 d096722
Fix bug
JoeyT1994 70a3f7e
Merge remote-tracking branch 'upstream/main'
JoeyT1994 9d64fe8
Merge remote-tracking branch 'upstream/main'
JoeyT1994 9d6c1bc
File removed
JoeyT1994 ae17245
Merge remote-tracking branch 'upstream/main'
JoeyT1994 b648353
Merge remote-tracking branch 'upstream/main'
JoeyT1994 4e7d189
Merge remote-tracking branch 'upstream/main'
JoeyT1994 dd2bd21
LinearFormNetwork
JoeyT1994 3bae597
Version bump
JoeyT1994 d7c4b44
Default link index map -> prime
JoeyT1994 96350be
Bug fix
JoeyT1994 c890f20
Only update ket vertex
JoeyT1994 de261df
Formatting
JoeyT1994 dbf0b55
Update
JoeyT1994 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| name = "ITensorNetworks" | ||
| uuid = "2919e153-833c-4bdc-8836-1ea460a35fc7" | ||
| authors = ["Matthew Fishman <[email protected]>, Joseph Tindall <[email protected]> and contributors"] | ||
| version = "0.13.2" | ||
| version = "0.13.3" | ||
|
|
||
| [deps] | ||
| AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" | ||
|
|
||
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
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
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 @@ | ||
| using ITensors: ITensor, prime | ||
|
|
||
| default_dual_link_index_map = prime | ||
|
|
||
| struct LinearFormNetwork{ | ||
| V,TensorNetwork<:AbstractITensorNetwork{V},BraVertexSuffix,KetVertexSuffix | ||
| } <: AbstractFormNetwork{V} | ||
| tensornetwork::TensorNetwork | ||
| bra_vertex_suffix::BraVertexSuffix | ||
| ket_vertex_suffix::KetVertexSuffix | ||
| end | ||
|
|
||
| function LinearFormNetwork( | ||
| bra::AbstractITensorNetwork, | ||
| ket::AbstractITensorNetwork; | ||
| bra_vertex_suffix=default_bra_vertex_suffix(), | ||
| ket_vertex_suffix=default_ket_vertex_suffix(), | ||
| dual_link_index_map=default_dual_link_index_map, | ||
| ) | ||
| bra_mapped = dual_link_index_map(bra; sites=[]) | ||
| tn = disjoint_union(bra_vertex_suffix => dag(bra_mapped), ket_vertex_suffix => ket) | ||
| return LinearFormNetwork(tn, bra_vertex_suffix, ket_vertex_suffix) | ||
| end | ||
|
|
||
| function LinearFormNetwork(blf::BilinearFormNetwork) | ||
| bra, ket, operator = subgraph(blf, bra_vertices(blf)), | ||
| subgraph(blf, ket_vertices(blf)), | ||
| subgraph(blf, operator_vertices(blf)) | ||
| bra_suffix, ket_suffix = bra_vertex_suffix(blf), ket_vertex_suffix(blf) | ||
| operator = rename_vertices(v -> bra_vertex_map(blf)(v), operator) | ||
| tn = union(bra, ket, operator) | ||
| return LinearFormNetwork(tn, bra_suffix, ket_suffix) | ||
| end | ||
|
|
||
| bra_vertex_suffix(lf::LinearFormNetwork) = lf.bra_vertex_suffix | ||
| ket_vertex_suffix(lf::LinearFormNetwork) = lf.ket_vertex_suffix | ||
| # TODO: Use `NamedGraphs.GraphsExtensions.parent_graph`. | ||
| tensornetwork(lf::LinearFormNetwork) = lf.tensornetwork | ||
|
|
||
| function Base.copy(lf::LinearFormNetwork) | ||
| return LinearFormNetwork( | ||
| copy(tensornetwork(lf)), bra_vertex_suffix(lf), ket_vertex_suffix(lf) | ||
| ) | ||
| end | ||
|
|
||
| function update( | ||
| lf::LinearFormNetwork, | ||
| original_bra_state_vertex, | ||
| original_ket_state_vertex, | ||
| bra_state::ITensor, | ||
| ket_state::ITensor, | ||
JoeyT1994 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
| lf = copy(lf) | ||
| # TODO: Maybe add a check that it really does preserve the graph. | ||
| setindex_preserve_graph!( | ||
| tensornetwork(lf), bra_state, bra_vertex(blf, original_bra_state_vertex) | ||
| ) | ||
| setindex_preserve_graph!( | ||
| tensornetwork(lf), ket_state, ket_vertex(blf, original_ket_state_vertex) | ||
| ) | ||
| return lf | ||
| end | ||
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
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.