Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Start shifted Knuth
Browse files Browse the repository at this point in the history
  • Loading branch information
ChamanAgrawal committed Jul 21, 2019
1 parent e53e9a8 commit b70aa65
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "local/bin/python3.7"
}
112 changes: 112 additions & 0 deletions src/sage/combinat/rsk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2523,6 +2523,118 @@ def _backward_format_output(self, lower_row, upper_row, output,
raise ValueError("invalid output option")


class RuleshiftedKnuth(RuleSuperRSK):
r"""
"""
def to_pairs(self, obj1=None, obj2=None, check=True):
r"""
"""
from sage.combinat.shifted_primed_tableau import PrimedEntry
if obj2 is None:
try:
itr = obj1._rsk_iter()
except AttributeError:
# If this is (something which looks like) a matrix
# then build the generalized permutation
try:
t = []
b = []
for i, row in enumerate(obj1):
for j, mult in enumerate(row):
mult = PrimedEntry(mult)
if mult > 0 and m.is_primed():
t.extend([PrimedEntry(i+1)])
b.extend([PrimedEntry(j+0.5)])
mult = mult - 1
if mult > 0:
t.extend(PrimedEntry([i+1])*mult)
b.extend(PrimedEntry([j+1])*mult)
itr = zip(t, b)
except TypeError:
# set recording list to default value [1, 2, 3, ...]
rec = range(1, len(obj1)+1)
# Converting entries to PrimedEntry
for i in range(len(obj1)):
obj1[i] = PrimedEntry(obj1[i])
rec[i] = PrimedEntry(rec[i])
itr = zip(rec, obj1)
else:
# Converting entries of obj1 to PrimedEntry
for i in range(len(obj1)):
obj1[i] = PrimedEntry(obj1[i])
# Converting entries of obj2 to PrimedEntry
for i in range(len(obj2)):
obj2[i] = PrimedEntry(obj2[i])
if check:
if len(obj1) != len(obj2):
raise ValueError("the two arrays must be the same length")
for i in range(len(obj2)):
if i.is_primed():
raise ValueError("the top row of biword should be unprimed")
itr = zip(obj1, obj2)
return itr

def forward_rule(self, obj1, obj2, check_standard=False, check=True):
r"""
"""
itr = self.to_pairs(obj1, obj2, check=check)
p = [] # the "insertion" tableau
q = [] # the "recording" tableau
for i, j in itr:
# loop
row_index = -1
col_index = -1
epsilon = 0
while True:
if epsilon == 0:
# row insertion
row_index += 1
if row_index == len(p):
p.append([j])
q.append([i])
break
else:
j1, col_index = self.insertion(j, p[row_index], epsilon=epsilon)
if row_index == col_index:
epsilon = 1
if j1 is None:
p[row_index].append(j)
q[row_index].append(i)
break
j = j1
else:
# column insertion
col_index += 1
if not p or col_index == len(p[0]):
self._set_col(p, col_index, [j])
self._set_col(q, col_index, [i])
break
else:
# retrieve column
c = self._get_col(p, col_index)
j1, row_index = self.insertion(j, c, epsilon=epsilon)
if j1 is None:
c.append(j)
self._set_col(p, col_index, c)
if col_index == 0:
q.append([])
q[row_index].append(i)
break
else:
j = j1
self._set_col(p, col_index, c)
return self._forward_format_output(p, q, check_standard=check_standard)

def _forward_format_output(self, p, q, check_standard):
r"""
"""
from sage.combinat.shifted_primed_tableau import ShiftedPrimedTableau

if not p:
return [StandardTableau([]), StandardTableau([])]
if check_standard:


class InsertionRules(object):
r"""
Catalog of rules for RSK-like insertion algorithms.
Expand Down

0 comments on commit b70aa65

Please sign in to comment.