Skip to content

Add ones_map and fill_map split constructors#216

Merged
mtfishman merged 1 commit into
mainfrom
mf/ones-fill-map
Jul 24, 2026
Merged

Add ones_map and fill_map split constructors#216
mtfishman merged 1 commit into
mainfrom
mf/ones-fill-map

Conversation

@mtfishman

Copy link
Copy Markdown
Member

Summary

Adds ones_map and fill_map alongside the existing zeros_map/randn_map/rand_map split constructors, plus the flat ones/fill axis-friendly companions they forward through. They follow the same shape as the rest of the family: ones_map([T,] codomain_axes, domain_axes) fills a map-shaped array with ones and fill_map(v, codomain_axes, domain_axes) with a constant value, flattening to (codomain_axes..., conj.(domain_axes)...) and defaulting the element type from T/v. This rounds out the value-filling *_map set so a backend can build a map-shaped (or charged) tensor with any of the standard fills, not only zeros/randn/rand.

Adds `ones_map` and `fill_map` alongside the existing `zeros_map`/`randn_map`/`rand_map` split constructors, plus the flat `ones`/`fill` axis-friendly companions they forward through. They follow the same shape as the rest of the family: `ones_map([T,] codomain_axes, domain_axes)` fills a map-shaped array with ones and `fill_map(v, codomain_axes, domain_axes)` with a constant value, flattening to `(codomain_axes..., conj.(domain_axes)...)` and defaulting the element type from `T`/`v`. This rounds out the value-filling `*_map` set so a backend can build a map-shaped (or charged) tensor with any of the standard fills, not only zeros/randn/rand.
@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.93%. Comparing base (344f8a8) to head (86ef978).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #216      +/-   ##
==========================================
+ Coverage   81.80%   81.93%   +0.12%     
==========================================
  Files          28       28              
  Lines         995     1002       +7     
==========================================
+ Hits          814      821       +7     
  Misses        181      181              
Flag Coverage Δ
docs 21.90% <0.00%> (-0.16%) ⬇️

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
mtfishman merged commit d54e11f into main Jul 24, 2026
21 checks passed
@mtfishman
mtfishman deleted the mf/ones-fill-map branch July 24, 2026 20:22
mtfishman added a commit to ITensor/GradedArrays.jl that referenced this pull request Jul 24, 2026
## Summary

Adds flux-canceling constructors
`randn`/`rand`/`zeros`/`ones`/`fill`(`c, codomain[, domain]`) that build
a symmetric graded array carrying total charge `c`. They append a
multiplicity-1 auxiliary leg carrying `c` to the (implicitly dualized)
domain, dangling last, so the physical axes fuse to `c`, which is sugar
for the split constructor over `(codomain, (domain..., aux))`. The
sector `c` may be a bare `TensorKitSectors.Sector` or a `SectorRange`,
and the two-argument `f(c, codomain)` form is the empty-domain case (all
physical legs in the codomain, aux the sole domain leg).

Builds on the `ones_map`/`fill_map` additions in
ITensor/TensorAlgebra.jl#216.
mtfishman added a commit to ITensor/ITensorBase.jl that referenced this pull request Jul 24, 2026
## Summary

Adds flux-canceling constructors
`randn`/`rand`/`zeros`/`ones`/`fill`(`c, codomain[, domain]`) at the
`Index` level, so an `ITensor` over graded (block-sparse) indices can be
built carrying a nonzero total charge `c`. They mint a fresh auxiliary
`Index` carrying `c` and forward to the map-shaped split constructor,
appending the aux to the domain dangling last so the physical indices
fuse to `c`. The sector may be a bare `TensorKitSectors.Sector` or a
`SectorRange`. These live in a new `ITensorBaseGradedArraysExt`, since
ITensorBase does not depend on the sector types.

Filling out the constructor surface these build on, this also adds the
split `(codomain, domain)` forms of `ones` and `fill` to ITensorBase
core (alongside the existing `zeros`), and lets `randn`/`rand` take a
leading `rng` without an explicit element type (matching
`Base.randn(rng, dims...)`) across the flat, split, and flux forms.

Builds on ITensor/GradedArrays.jl#220 and
ITensor/TensorAlgebra.jl#216.
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