Skip to content

Add named project for building symmetry-restricted tensors#208

Merged
mtfishman merged 5 commits into
mainfrom
mf/named-project
Jul 2, 2026
Merged

Add named project for building symmetry-restricted tensors#208
mtfishman merged 5 commits into
mainfrom
mf/named-project

Conversation

@mtfishman

@mtfishman mtfishman commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds methods extending TensorAlgebra.project and TensorAlgebra.checked_project (added in ITensor/TensorAlgebra.jl#203) that build a named tensor from a dense array and the indices to attach. The three-argument form takes a codomain/domain split (an operator), and the two-argument form takes a flat list of indices (a state, i.e. an empty domain). The index axes select the backend, so the same call builds an Array on dense indices, a block-sparse array on graded indices, and a TensorMap on TensorKit spaces. The named entry strips to the unnamed array plus axes, lowers to TensorAlgebra.project, and reattaches the names.

This is the named-index projection primitive for building symmetric operators and states from a dense basis matrix: project(Sz, (i',), (i,)) for an operator, project(v, (i,)) for a state.

@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.62%. Comparing base (ca0d801) to head (c1df9a5).

Files with missing lines Patch % Lines
src/tensoralgebra.jl 77.77% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #208      +/-   ##
==========================================
+ Coverage   74.58%   74.62%   +0.03%     
==========================================
  Files          30       30              
  Lines        1519     1537      +18     
==========================================
+ Hits         1133     1147      +14     
- Misses        386      390       +4     
Flag Coverage Δ
docs 23.78% <0.00%> (-0.29%) ⬇️

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/TensorAlgebra.jl that referenced this pull request Jul 2, 2026
…support (#203)

## Summary

Adds `project`, an owned convenience over the existing `project_map`
hook for building a symmetry-restricted array from a dense one. The
three-argument form takes an explicit codomain/domain split and the
two-argument form takes a flat list of axes (an empty domain), both
forwarding to `project_map`, and `checked_project` is the verified
counterpart of `checked_project_map`. This mirrors the
`zeros`/`zeros_map` pairing, where the unsuffixed name is the
convenience that also accepts the codomain/domain split.

Also adds the `TensorMap` path in the TensorKit extension so `project`
can build a `TensorMap` from a dense array: `similar_map` allocates a
same-device buffer whose block storage type follows the dense prototype,
`projectto!` fills the symmetry-allowed blocks through
`project_symmetric!` and discards the rest, and `checked_projectto!`
verifies the projection by densifying the result and reusing the dense
path's elementwise `isapprox(src, dest)` check, so it keeps one
`InexactError`/`kwargs` contract across backends.

The named-index `project` for `AbstractITensor` is added in
ITensor/ITensorBase.jl#208.
@mtfishman mtfishman changed the title [WIP] Add named project for building symmetry-restricted tensors Add named project for building symmetry-restricted tensors Jul 2, 2026
@mtfishman mtfishman marked this pull request as ready for review July 2, 2026 22:23
@mtfishman mtfishman enabled auto-merge (squash) July 2, 2026 22:23
mtfishman added 5 commits July 2, 2026 18:57
Adds methods extending TensorAlgebra's `project` and `checked_project` that
build a named tensor from a dense array and the indices to attach. The
three-argument form takes a codomain/domain split (an operator), the
two-argument form a flat list of indices (a state). The index axes select the
backend, so the same call builds an `Array`, a block-sparse array, or a
`TensorMap`. The named entry strips to the unnamed array plus axes, lowers to
`TensorAlgebra.project`, and reattaches the names.
Route `project`/`checked_project` through a shared `project_nameddims` /
`checked_project_nameddims` helper and add the empty-codomain method, so an
all-domain projection (`project(a, (), (i,))`, the mirror of the flat
all-codomain state) strips names correctly instead of falling through to the
unnamed-axis generic. This matches the two-dispatch-entry pattern of the
`similar_map` construction hooks.
@mtfishman mtfishman merged commit 091773d into main Jul 2, 2026
18 checks passed
@mtfishman mtfishman deleted the mf/named-project branch July 2, 2026 23:31
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