Skip to content

Apply the conjugation op to destination axes in bipermutedimsopadd!#184

Open
mtfishman wants to merge 5 commits into
mainfrom
mf/conj-dualizes-axes
Open

Apply the conjugation op to destination axes in bipermutedimsopadd!#184
mtfishman wants to merge 5 commits into
mainfrom
mf/conj-dualizes-axes

Conversation

@mtfishman

@mtfishman mtfishman commented Jun 26, 2026

Copy link
Copy Markdown
Member

Summary

bipermutedimsopadd! and permutedimsop now apply their element-wise op to the destination axes, so a conjugating permutation (op = conj) dualizes graded axes and keeps axes and data in sync. op acts as a conjugation flag, either identity or conj: on a graded axis conj dualizes, and on a dense axis it is a no-op, so dense arrays are unaffected. check_input rejects any other op with an informative error. Transposition is carried by the permutation arguments rather than by op.

This also adds linearbroadcasted(*, ::Number, ::ConjBroadcasted), so scaling a conjugated broadcast operand such as conj.(a) ./ β lowers correctly instead of erroring.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 79.28%. Comparing base (f558047) to head (cb40f44).

Files with missing lines Patch % Lines
src/linearbroadcasted.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #184      +/-   ##
==========================================
- Coverage   79.37%   79.28%   -0.09%     
==========================================
  Files          20       20              
  Lines         669      671       +2     
==========================================
+ Hits          531      532       +1     
- Misses        138      139       +1     
Flag Coverage Δ
docs 30.37% <83.33%> (+0.17%) ⬆️

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.

mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jun 26, 2026
## Summary

Makes `conj` dualize graded axes consistently across GradedArrays, matching `Base.conj(::AbelianGradedArray)`. The materialization path (`bipermutedimsopadd!` on an `AbstractSectorArray` with `op = conj`) now routes through `Base.conj`, which dualizes the sectors and carries the fermionic reversal phase that a bare block-data conjugation drops. The `SectorStyle` broadcast picks up the same behavior: `broadcasted_sector` is op-aware, so `conj.(x)` dualizes the result axes, and a broadcast that conjugates only some operands such as `conj.(s) .- t` now errors as a sector mismatch rather than silently keeping the original axes. `Base.conj` on the structural factors `AbelianSectorDelta` and `SectorIdentity` dualizes their axes.

Builds on ITensor/TensorAlgebra.jl#184, which makes the `bipermutedimsopadd!` and `permutedimsop` `op` apply to the destination axes.

## TODO

- [ ] Drop the `[sources]` pin on TensorAlgebra and confirm the `0.11.2` compat floor once ITensor/TensorAlgebra.jl#184 merges and registers.
@mtfishman mtfishman force-pushed the mf/conj-dualizes-axes branch from 239efed to a0fc687 Compare June 26, 2026 19:45
@mtfishman mtfishman enabled auto-merge (squash) June 26, 2026 19:45
## Summary

`bipermutedimsopadd!` and `permutedimsop` now apply their element-wise `op` to the destination axes, so a conjugating permutation (`op = conj`) dualizes graded axes and keeps axes and data in sync. `op` acts as a conjugation flag, either `identity` or `conj`: on a graded axis `conj` dualizes, and on a dense axis it is a no-op, so dense arrays are unaffected. Transposition is carried by the permutation arguments rather than by `op`.

This also adds `linearbroadcasted(*, ::Number, ::ConjBroadcasted)`, so scaling a conjugated broadcast operand such as `conj.(a) ./ β` lowers correctly instead of erroring.
`bipermutedimsopadd!`'s `op` is a conjugation flag, either `identity` or `conj`. `check_input` now rejects any other function with an `ArgumentError`, so an unsupported `op` fails with a clear message at the boundary rather than later as a `MethodError` from applying it to an axis.
@mtfishman mtfishman force-pushed the mf/conj-dualizes-axes branch from a0fc687 to 9b0c83f Compare June 26, 2026 19:53
Added a compatibility function for bipermutedimsopadd! to maintain backward compatibility.
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