Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 8 additions & 4 deletions src/Combinatorics/EnumerativeCombinatorics/tableaux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ young_tableau

function young_tableau(::Type{T}, v::Vector{Vector{TT}}; check::Bool = true) where {T <: IntegerUnion, TT <: IntegerUnion}
if check
@req _defines_partition(map(length, v)) "The input does not define a Young tableau"
@req _defines_partition(map(length, v)) "The input does not define a Young tableau: lengths of rows must be weakly decreasing"
end
return YoungTableau{T}(v)
end
Expand Down Expand Up @@ -222,20 +222,24 @@ Return the shape of the tableau `tab`, i.e. the partition given by the lengths
of the rows of the tableau.
"""
function shape(tab::YoungTableau{T}) where T
return partition(T[ length(tab[i]) for i = 1:length(tab) ], check = false)
# Line below DOES NOT CHECK that the lengths of the rows are weakly decreasing
return partition(T[ length(tab[i]) for i = 1:length(tab) ]; check = false)
end

@doc raw"""
weight(tab::YoungTableau)

Return the weight of the tableau `tab` as an array whose `i`-th element gives
the number of times the integer `i` appears in the tableau.
Return the weight sequence of the tableau `tab` as an array whose `i`-th element
gives the number of times the integer `i` appears in the tableau.
"""
function weight(tab::YoungTableau)
@req is_semistandard(tab) "Tableau must be (semi-)standard"

if isempty(tab)
return Int[]
end

# Computation of max must be changed if we want to permit non-semi-standard YT
max = 0
for i = 1:length(tab)
if max < tab[i][end]
Expand Down
4 changes: 2 additions & 2 deletions test/Combinatorics/EnumerativeCombinatorics/tableaux.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
@test reading_word(young_tableau(Array{Int,1}[])) == Int[]

# weight
@test weight(young_tableau([[1,2,3],[1,2],[1]])) == [3,2,1]
@test weight(young_tableau([[1,2,3],[2,3],[3]])) == [1,2,3]
@test weight(young_tableau([[1,2,3,4,5]])) == [1,1,1,1,1]
@test weight(young_tableau([[1],[1],[1]])) == [3]
@test_throws ArgumentError weight(young_tableau([[1],[1],[1]]))
@test weight(young_tableau(Array{Int,1}[])) == Int[]

# is_standard
Expand Down