Preserve operator structure under contraction#185
Merged
Conversation
`*` between an `ITensorOperator` and another tensor now returns an `ITensorOperator` whose codomain and domain are composed from the operands, rather than decaying to the bare wrapped state. Co-authored-by: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #185 +/- ##
==========================================
+ Coverage 71.14% 71.60% +0.45%
==========================================
Files 28 28
Lines 1428 1451 +23
==========================================
+ Hits 1016 1039 +23
Misses 412 412
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
`operator` now accepts named ranges (such as `Index`es) for its codomain and domain, mapping `name` over the inputs, so callers can pass the ranges they already have instead of mapping `name` first. Co-authored-by: Claude <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
*between anITensorOperatorand another tensor now returns anITensorOperatorwhose codomain and domain are composed from the operands, rather than decaying to the bare wrapped state. Thedomain => codomainpairs of both operands form a graph of maximum degree two (each name is paired at most once per operand), so the result's codomain/domain is found by following each surviving domain name's pairing forward through any contracted shared names. A leg whose chain dead-ends on a contracted index is left dangling, so the product is well defined for any contraction, including a shared dangling link (thec† * chopping pattern) and a paired index that chains two operators together.The product is always an
ITensorOperator, even when its codomain and domain both come out empty, so the contraction is type-stable regardless of which names happen to contract.applyandapply_dagnow contract throughstate, so they are unaffected by the operator-preserving*.operatoralso accepts named ranges (such asIndexes) for its codomain and domain, not just dimension names, so callers can pass the ranges they already have.