Skip to content

Preserve operator structure under contraction#185

Merged
mtfishman merged 2 commits into
mainfrom
mf/operator-preserving-contraction
Jun 24, 2026
Merged

Preserve operator structure under contraction#185
mtfishman merged 2 commits into
mainfrom
mf/operator-preserving-contraction

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

* 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. The domain => codomain pairs 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 (the c† * c hopping 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. apply and apply_dag now contract through state, so they are unaffected by the operator-preserving *.

operator also accepts named ranges (such as Indexes) for its codomain and domain, not just dimension names, so callers can pass the ranges they already have.

`*` 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

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.60%. Comparing base (705dcc2) to head (b8e01ca).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/itensoroperator.jl 96.55% 1 Missing ⚠️
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              
Flag Coverage Δ
docs 15.99% <6.89%> (-0.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

`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>
@mtfishman mtfishman enabled auto-merge (squash) June 24, 2026 23:43
@mtfishman mtfishman merged commit fb19c64 into main Jun 24, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/operator-preserving-contraction branch June 24, 2026 23:46
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