Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
r""" Rigged Partitions
Class and methods of the rigged partition which are used by the rigged configuration class. This is an internal class used by the rigged configurations and KR tableaux during the bijection, and is not to be used by the end-user.
We hold the partitions as an 1-dim array of positive integers where each value corresponds to the length of the row. This is the shape of the partition which can be accessed by the regular index.
The data for the vacancy number is also stored in a 1-dim array which each entry corresponds to the row of the tableau, and similarly for the partition values.
AUTHORS:
- Travis Scrimshaw (2010-09-26): Initial version
.. TODO::
Convert this to using multiplicities `m_i` (perhaps with a dictionary?)? """
#***************************************************************************** # Copyright (C) 2010-2012 Travis Scrimshaw <tscrim@ucdavis.edu> # # Distributed under the terms of the GNU General Public License (GPL) # # This code is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # The full text of the GPL is available at: # # http://www.gnu.org/licenses/ #*****************************************************************************
from sage.misc.latex import latex from sage.structure.richcmp cimport richcmp
cdef class RiggedPartition(SageObject): r""" The RiggedPartition class which is the data structure of a rigged (i.e. marked or decorated) Young diagram of a partition.
Note that this class as a stand-alone object does not make sense since the vacancy numbers are calculated using the entire rigged configuration. For more, see :class:`RiggedConfigurations`.
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] sage: RP 0[ ][ ]0 -1[ ]-1 <BLANKLINE> """
def __init__(self, shape=None, rigging_list=None, vacancy_nums=None): r""" Initialize by the rigged partition.
Note that this only performs checks to see that the sizes match up.
INPUT:
- ``shape`` -- (default: ``None``) the shape - ``rigging_list`` -- (default: ``None``) the riggings - ``vacancy_nums`` -- (default: ``None``) the vacancy numbers
TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: RiggedPartition() (/) <BLANKLINE> sage: RP = RiggedPartition([2,1], [0,0], [1, 0]) sage: RP 1[ ][ ]0 0[ ]0 <BLANKLINE> sage: TestSuite(RP).run() """
raise ValueError("mismatch between shape and vacancy numbers")
else:
raise ValueError("mismatch between shape and rigging list")
else:
def _repr_(self): """ Return a string representation of ``self``.
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: elt = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] sage: elt 0[ ][ ]0 -1[ ]-1 <BLANKLINE> sage: Partitions.options.convention="french" sage: elt -1[ ]-1 0[ ][ ]0 <BLANKLINE> sage: Partitions.options._reset() """ # If it is empty, return saying so
else:
def _latex_(self): r""" Returns LaTeX representation of ``self``.
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: latex(RC(partition_list=[[2],[2,2],[2,1],[2]])[2]) { \begin{array}[t]{r|c|c|l} \cline{2-3} 0 &\phantom{|}&\phantom{|}& 0 \\ \cline{2-3} -1 &\phantom{|}& \multicolumn{2 }{l}{ -1 } \\ \cline{2-2} \end{array} }
TESTS:
Check that this prints using the French convention::
sage: RC = RiggedConfigurations(['D',5,1], [[2,1], [1,2]]) sage: RiggedConfigurations.options.convention='French' sage: latex(RC(partition_list=[[3],[3,1],[1,1],[1],[1]])[1]) { \begin{array}[t]{r|c|c|c|l} \cline{2-2} 0 &\phantom{|}& \multicolumn{3 }{l}{ 0 } \\ \cline{2-4} -2 &\phantom{|}&\phantom{|}&\phantom{|}& -2 \\ \cline{2-4} \end{array} } sage: RiggedConfigurations.options._reset() """
else:
else:
else:
def _clone(self): r""" Makes a (deep) copy of this rigged partition.
TESTS::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2]; RP 0[ ][ ]0 -1[ ]-1 <BLANKLINE> sage: RP2 = RP._clone(); RP2 0[ ][ ]0 -1[ ]-1 <BLANKLINE> sage: RP == RP2 True sage: RP is RP2 False """ # TODO: Perhaps we can be better by not copying data as much and do it # more on-demand cdef RiggedPartition res
def __richcmp__(self, other, int op): r""" Return true if ``self`` equals ``rhs``.
TESTS::
sage: RC = RiggedConfigurations(['A',2,1], [[1,1],[1,1],[1,1]]) sage: x = RC(partition_list=[[1], []], rigging_list=[[0], []]) sage: y = RC(partition_list=[[1], []], rigging_list=[[1], []]) sage: x == y False """ return False
# TODO: Cythonize CombinatorialObject?
def __hash__(self): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition() sage: h = hash(nu) sage: _ = nu.insert_cell(2) sage: h == hash(nu) False """
def __nonzero__(self): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition() sage: bool(nu) False sage: nu = RiggedPartition([1]) sage: bool(nu) True """
def __len__(self): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition() sage: len(nu) 0 sage: nu = RiggedPartition([3,2,2,1]) sage: len(nu) 4 """
def __getitem__(self, key): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition([3,2,1]) sage: nu[2] 1 """
def __iter__(self): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition([3,2,1]) sage: list(nu) [3, 2, 1] """
def __reduce__(self): """ TESTS::
sage: from sage.combinat.rigged_configurations.rigged_partition import RiggedPartition sage: nu = RiggedPartition([3,2,1]) sage: loads(dumps(nu)) == nu True """
# Should we move these functions to the CP -> RC bijections?
cpdef get_num_cells_to_column(self, int end_column, t=1): r""" Get the number of cells in all columns before the ``end_column``.
INPUT:
- ``end_column`` -- The index of the column to end at
- ``t`` -- The scaling factor
OUTPUT:
- The number of cells
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] sage: RP.get_num_cells_to_column(1) 2 sage: RP.get_num_cells_to_column(2) 3 sage: RP.get_num_cells_to_column(3) 3 sage: RP.get_num_cells_to_column(3, 2) 5 """ # Sum up from the reverse (the smallest row sizes)
# Add the remaining cells
cpdef insert_cell(self, int max_width): r""" Insert a cell given at a singular value as long as its less than the specified width.
Note that :meth:`insert_cell` does not update riggings or vacancy numbers, but it does prepare the space for them. Returns the width of the row we inserted at.
INPUT:
- ``max_width`` -- The maximum width (i.e. row length) that we can insert the cell at
OUTPUT:
- The width of the row we inserted at.
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] sage: RP.insert_cell(2) 2 sage: RP 0[ ][ ][ ]None -1[ ]-1 <BLANKLINE> """ cdef Py_ssize_t i
# Go through our partition until we find a length of greater than 1
cpdef remove_cell(self, row, int num_cells=1): r""" Removes a cell at the specified ``row``.
Note that :meth:`remove_cell` does not set/update the vacancy numbers or the riggings, but guarantees that the location has been allocated in the returned index.
INPUT:
- ``row`` -- the row to remove the cell from
- ``num_cells`` -- (default: 1) the number of cells to remove
OUTPUT:
- The location of the newly constructed row or ``None`` if unable to remove row or if deleted a row.
EXAMPLES::
sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: RP = RC(partition_list=[[2],[2,2],[2,1],[2]])[2] sage: RP.remove_cell(0) 0 sage: RP None[ ]None -1[ ]-1 <BLANKLINE> """
# Find the beginning of the next block we want # If we are at the end, just do a simple remove
cdef Py_ssize_t i # If the next row is a block change, just reduce by num_cells
# Otherwise we need to "move" the row # These should be updated (so there should be no need to carry them over)
# We need to "move" the row to the end of the partition
# Placeholders as above
cdef class RiggedPartitionTypeB(RiggedPartition): r""" Rigged partitions for type `B_n^{(1)}` which has special printing rules which comes from the fact that the `n`-th partition can have columns of width `\frac{1}{2}`. """ def __init__(self, arg0, arg1=None, arg2=None): """ Initialize ``self``.
EXAMPLES::
sage: RP = sage.combinat.rigged_configurations.rigged_partition.RiggedPartition([2,1], [0,0], [1, 0]) sage: B = sage.combinat.rigged_configurations.rigged_partition.RiggedPartitionTypeB(RP); B 1[][]0 0[]0 <BLANKLINE> sage: TestSuite(B).run() """
def _repr_(self): """ Return a string representation of ``self``.
INPUT:
- ``half_width_boxes`` -- (Default: ``True``) Display the partition using half width boxes
EXAMPLES::
sage: RC = RiggedConfigurations(['B', 2, 1], [[2, 2]]) sage: elt = RC(partition_list=[[2],[2,1]])[1] sage: elt -2[][]-2 -2[]-2 <BLANKLINE> sage: RiggedConfigurations.options.half_width_boxes_type_B=False sage: elt -2[ ][ ]-2 -2[ ]-2 <BLANKLINE> sage: RiggedConfigurations.options._reset() """ # If it is empty, return saying so
itr = reversed(list(enumerate(self._list))) else:
else:
def _latex_(self): r""" Returns LaTeX representation of ``self``.
INPUT:
- ``half_width_boxes`` -- (Default: ``True``) Display the partition using half width boxes
EXAMPLES::
sage: RC = RiggedConfigurations(['B', 2, 1], [[1, 1]]) sage: RP = RC(partition_list=[[],[2]])[1] sage: latex(RP) { \begin{array}[t]{r|c|c|l} \cline{2-3} -4 &\phantom{a}&\phantom{a}& -4 \\ \cline{2-3} \end{array} } sage: RiggedConfigurations.options.half_width_boxes_type_B=False sage: latex(RP) { \begin{array}[t]{r|c|c|l} \cline{2-3} -4 &\phantom{X|}&\phantom{X|}& -4 \\ \cline{2-3} \end{array} } sage: RiggedConfigurations.options._reset() """ return "{\\emptyset}"
else:
else: ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) ret_string += "}{l}{" + latex(self.rigging[i]) + "}"
ret_string += latex(self.vacancy_numbers[i + 1]) else: for i, row_len in enumerate(reversed(self._list)): ret_string += "\\cline{2-%s} "%(1 + row_len) ret_string += latex(self.vacancy_numbers[-i-1]) ret_string += " &" + box_str*row_len
if num_cols == row_len: ret_string += " " + latex(self.rigging[-i-1]) else: ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) ret_string += "}{l}{" + latex(self.rigging[-i-1]) + "}"
ret_string += " \\\\\n" ret_string += "\\cline{2-%s}\n\\end{array}\n}"%(1 + num_cols)
|