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

Commit

Permalink
flag to skip multiplication with left/right
Browse files Browse the repository at this point in the history
  • Loading branch information
dkrenn committed Aug 23, 2016
1 parent 0f538a9 commit 1794766
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/sage/combinat/recognizable_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def _latex_(self):


@cached_method
def coefficient_of_word(self, w):
def coefficient_of_word(self, w, multiply_left=True, multiply_right=True):
r"""
Return the coefficient to word `w` of this series.
Expand All @@ -439,6 +439,12 @@ def coefficient_of_word(self, w):
- ``w`` -- a word over the parent's
:meth:`~RecognizableSeriesSpace.alphabet`.
- ``multiply_left`` -- (default: ``True``) a boolean. If ``False``,
then multiplication by :meth:`left <left>` is skipped.
- ``multiply_right`` -- (default: ``True``) a boolean. If ``False``,
then multiplication by :meth:`right <right>` is skipped.
OUTPUT:
An element in the parent's
Expand All @@ -453,7 +459,12 @@ def coefficient_of_word(self, w):
sage: S[W(7.digits(2))]
3
"""
return self.left * self._mu_of_word_(w) * self.right
result = self._mu_of_word_(w)
if multiply_left:
result = self.left * result
if multiply_right:
result = result * self.right
return result


__getitem__ = coefficient_of_word
Expand Down Expand Up @@ -826,12 +837,12 @@ def _minimized_left_(self):
from sage.rings.integer_ring import ZZ

pcs = PrefixClosedSet(self.parent().indices())
left = self.left * self._mu_of_word_(pcs.elements[0])
left = self.coefficient_of_word(pcs.elements[0], multiply_right=False)
if left.is_zero():
return self.parent().zero()
Left = [left]
for p in pcs.populate_interactive():
left = self.left * self._mu_of_word_(p)
left = self.coefficient_of_word(p, multiply_right=False)
try:
Matrix(Left).solve_left(left)
except ValueError:
Expand All @@ -844,7 +855,7 @@ def _minimized_left_(self):
ML = Matrix(Left)

def alpha(c):
return ML.solve_left(self.left * self._mu_of_word_(c))
return ML.solve_left(self.coefficient_of_word(c, multiply_right=False))

def mu_prime_entry(a, p, q, iq):
c = p + a
Expand Down

0 comments on commit 1794766

Please sign in to comment.