Skip to content

Commit c0caddf

Browse files
committed
add bounds to what A4Object can be defined as
1 parent f8d45c3 commit c0caddf

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/bimodulesector.jl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ struct BimoduleSector{Name} <: Sector
22
i::Int
33
j::Int
44
label::Int
5+
function BimoduleSector{:A4}(i::Int, j::Int, label::Int)
6+
i <= 12 && j <= 12 || throw(DomainError("object outside the matrix A4"))
7+
return label <= _numlabels(BimoduleSector{:A4}, i, j) ? new{:A4}(i, j, label) : throw(DomainError("label outside category A4($i, $j)"))
8+
end
59
end
610
BimoduleSector{Name}(data::NTuple{3,Int}) where {Name} = BimoduleSector{Name}(data...)
7-
#TODO: place bound on what BimoduleSectors can be made
8-
# currently you can define A4Object(anyint, anyint, anyint)
911
const A4Object = BimoduleSector{:A4}
10-
# function A4Object(i::Int, j::Int, label::Int)
11-
# i <= 12 && j <= 12 || throw(DomainError("object outside the matrix"))
12-
# return BimoduleSector{A4Object}(i, j, label)
13-
# end
1412

1513
# Utility implementations
1614
# -----------------------
@@ -25,7 +23,6 @@ end
2523
Base.IteratorSize(::Type{SectorValues{<:BimoduleSector}}) = Base.SizeUnknown()
2624

2725
# TODO: generalize?
28-
# TODO: numlabels?
2926
function Base.iterate(iter::SectorValues{A4Object}, (I, label)=(1, 1))
3027
I > 12 * 12 && return nothing
3128
i, j = CartesianIndices((12, 12))[I].I
@@ -49,8 +46,8 @@ function TensorKitSectors.:⊗(a::A4Object, b::A4Object)
4946
if (a_l == a.label && b_l == b.label)]
5047
end
5148

52-
function _numlabels(::Type{A4Object}, i, j)
53-
return Ncache = _get_Ncache(A4Object)
49+
function _numlabels(::Type{T}, i, j) where {T<:BimoduleSector}
50+
return length(_get_dual_cache(T)[2][i,j])
5451
end
5552

5653
# Data from files
@@ -284,4 +281,4 @@ function TensorKitSectors.Fsymbol(a::I, b::I, c::I, d::I, e::I,
284281
return get(colordict, (a.label, b.label, c.label, d.label, e.label, f.label)) do
285282
return colordict[(a.label, b.label, c.label, d.label, e.label, f.label)]
286283
end
287-
end
284+
end

0 commit comments

Comments
 (0)