Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GradedAxes] Introduce GradedUnitRangeDual #1531

Merged
merged 46 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
2869a8c
pass GradedAxes test
ogauthe Sep 5, 2024
b21f404
separate types UnitRangeDual and GradedUnitRangeDual
ogauthe Sep 10, 2024
743592a
pass BlockSparseArrays tests
ogauthe Sep 10, 2024
36e7bfb
test UnitRangeDual
ogauthe Sep 11, 2024
cb1c4d9
fix blocklengths
ogauthe Sep 11, 2024
5a7d4a7
add tests
ogauthe Sep 11, 2024
c373729
fix some slicing
ogauthe Sep 12, 2024
113a1fe
fix tests
ogauthe Sep 16, 2024
14c95ca
generalize gradedisequal
ogauthe Sep 16, 2024
a11107c
remove UnitRangeDual
ogauthe Sep 17, 2024
dc762be
fix tests
ogauthe Sep 17, 2024
32d0f11
add tests
ogauthe Sep 17, 2024
47a9ed1
remove tests on a[:,:]
ogauthe Sep 17, 2024
9b35445
Merge branch 'main' into GradedUnitRangeDual
ogauthe Oct 25, 2024
1131945
WIP
ogauthe Oct 25, 2024
cc6d7ea
Merge branch 'main' into GradedUnitRangeDual
ogauthe Oct 25, 2024
3f6bd2e
passing tests
ogauthe Oct 28, 2024
8a353bd
finish merging
ogauthe Oct 28, 2024
aa1b655
more tests
ogauthe Oct 28, 2024
5c5abd6
more tests
ogauthe Oct 28, 2024
d7e3a8d
reduce diff
ogauthe Oct 29, 2024
efe1c7c
custom type for AbstractGradedUnitRange
ogauthe Oct 29, 2024
3dcdd20
clean new implementation
ogauthe Oct 29, 2024
a184141
custom printing
ogauthe Oct 29, 2024
db71962
fix getindex(a,::Vector{Int}
ogauthe Oct 31, 2024
c57bc02
fix GradedUnitRangeDual tests
ogauthe Oct 31, 2024
032bde4
remove doublets
ogauthe Oct 31, 2024
e716903
use GradedAxes interface
ogauthe Oct 31, 2024
9796676
Base.AbstractUnitRange actually needed
ogauthe Nov 1, 2024
3b8b2b9
fix ambiguities
ogauthe Nov 1, 2024
71cd86a
define label_type
ogauthe Nov 1, 2024
5c36967
improve display
ogauthe Nov 1, 2024
de6080b
simpler display
ogauthe Nov 1, 2024
24fb3c8
fix combine_blockaxes
ogauthe Nov 1, 2024
b2fd32b
fix slicing BlockSparseArrays
ogauthe Nov 1, 2024
705da7d
use blockedunitrange_getindices instead of gradedunitrange_getindices
ogauthe Nov 4, 2024
38a21f6
fix slicing
ogauthe Nov 4, 2024
c1ec06d
fix slicing with BlockVector
ogauthe Nov 4, 2024
5111bb2
use isdual ins tests
ogauthe Nov 4, 2024
a0ddb30
add broken tests
ogauthe Nov 4, 2024
92707fb
remove dead code
ogauthe Nov 5, 2024
23b4fb1
more tests
ogauthe Nov 5, 2024
0953484
remove julia v1.6 code
ogauthe Nov 5, 2024
0c6f7e5
housekeeping
ogauthe Nov 5, 2024
20009e1
use BlockLasts as argument name
ogauthe Nov 5, 2024
d632ff1
Merge branch 'main' into GradedUnitRangeDual
mtfishman Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finish merging
  • Loading branch information
ogauthe committed Oct 28, 2024
commit 8a353bdf7a902a6166412a55394cd03ac2c95b51
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using BlockArrays:
AbstractBlockedUnitRange,
BlockArrays,
Block,
BlockIndexRange,
BlockedVector,
blocklength,
blocksize,
viewblock
BlockArrays, Block, BlockIndexRange, BlockedVector, blocklength, blocksize, viewblock

# This splits `BlockIndexRange{N}` into
# `NTuple{N,BlockIndexRange{1}}`.
Expand Down
21 changes: 6 additions & 15 deletions NDTensors/src/lib/GradedAxes/src/fusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ function fuse_blocklengths(x::LabelledInteger, y::LabelledInteger)
return blockedrange([labelled(x * y, fuse_labels(label(x), label(y)))])
end

flatten_maybe_nested(v::Vector{<:Integer}) = v
flatten_maybe_nested(v::Vector{<:AbstractGradedUnitRange}) = reduce(vcat, blocklengths.(v))

using BlockArrays: blockedrange, blocks
function tensor_product(a1::AbstractBlockedUnitRange, a2::AbstractBlockedUnitRange)
nested = map(Iterators.flatten((Iterators.product(blocks(a1), blocks(a2)),))) do it
Expand All @@ -63,13 +60,8 @@ function tensor_product(a1::AbstractBlockedUnitRange, a2::AbstractBlockedUnitRan
return blockedrange(new_blocklengths)
end

# convention: sort UnitRangeDual according to nondual blocks
function blocksortperm(a::AbstractUnitRange)
return Block.(sortperm(blocklabels(nondual(a))))
end

# convention: sort GradedUnitRangeDual according to nondual blocks
function blocksortperm(a::GradedUnitRangeDual)
function blocksortperm(a::AbstractUnitRange)
return Block.(sortperm(blocklabels(nondual(a))))
end

Expand Down Expand Up @@ -102,14 +94,13 @@ end
function blockmergesort(g::AbstractGradedUnitRange)
glabels = blocklabels(g)
gblocklengths = blocklengths(g)
new_blocklengths = map(
la -> labelled(sum(gblocklengths[findall(==(la), glabels)]; init=0), la),
sort(unique(glabels)),
)
return GradedAxes.gradedrange(new_blocklengths)
new_blocklengths = map(sort(unique(glabels))) do la
return labelled(sum(gblocklengths[findall(==(la), glabels)]; init=0), la)
end
return gradedrange(new_blocklengths)
end

blockmergesort(g::GradedUnitRangeDual) = dual(blockmergesort(flip(g)))
blockmergesort(g::GradedUnitRangeDual) = flip(blockmergesort(flip(g)))

# fusion_product produces a sorted, non-dual GradedUnitRange
function fusion_product(g1, g2)
Expand Down
Loading