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

Commit

Permalink
minor rewrites to use existing stuff better
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 25, 2016
1 parent c430158 commit 7eb93e1
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sage/combinat/k_regular_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ def subsequence(self, a, b, minimize=True):
from sage.matrix.constructor import Matrix
from sage.modules.free_module_element import vector
P = self.parent()
k = self.parent().k
A = P.alphabet()
k = P.k
dim = self.dimension()

# Below, we use a dynamic approach to find the shifts of the
Expand All @@ -445,11 +446,11 @@ def mu_line(r, i, c):
kernel.append(d)
return pad(tuple(self.mu[f].rows()[i]), d)

lines = dict((r, []) for r in srange(k))
lines = dict((r, []) for r in A)
ci = 0
while ci < len(kernel):
c = kernel[ci]
for r in srange(k):
for r in A:
for i in srange(dim):
lines[r].append(mu_line(r, i, c))
ci += 1
Expand All @@ -459,7 +460,7 @@ def mu_line(r, i, c):
P,
dict((r, Matrix([pad_right(row, ndim, zero=zero)
for row in lines[r]]))
for r in srange(k)),
for r in A),
sum(c_j * vector(
pad_right(pad(tuple(self.left), b_j), ndim, zero=zero))
for b_j, c_j in iteritems(b)),
Expand Down Expand Up @@ -608,25 +609,24 @@ def partial_sums(self, include_n=False, minimize=True):
[ 0 0 0 1], [0 0 0 1], (1, 0, -1, 0), (1, 1, 1, 1)
)
"""
from sage.arith.srange import srange
from sage.matrix.constructor import Matrix
from sage.matrix.special import zero_matrix
from sage.modules.free_module_element import vector

P = self.parent()
k = self.parent().k
A = P.alphabet()
k = P.k
dim = self.dimension()

B = dict((r, sum(self.mu[a] for a in srange(r, k)))
for r in srange(k))
B = dict((r, sum(self.mu[a] for a in A[r:])) for r in A)
Z = zero_matrix(dim)
B[k] = Z
W = B[0].stack(Z)

result = P.element_class(
P,
dict((r, W.augment((-B[r+1]).stack(self.mu[r])))
for r in srange(k)),
for r in A),
vector(tuple(self.left) +
(dim*(0,) if include_n else tuple(-self.left))),
vector(2*tuple(self.right)))
Expand Down

0 comments on commit 7eb93e1

Please sign in to comment.