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

Commit

Permalink
Add functions shiftOP and unshift, and suppress shift.
Browse files Browse the repository at this point in the history
  • Loading branch information
mercatp committed Jul 18, 2016
1 parent effde91 commit 2a2c283
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
50 changes: 26 additions & 24 deletions src/sage/combinat/words/cautomata.pyx
Expand Up @@ -773,35 +773,17 @@ cdef class FastAutomaton:
r2.A = Av
return [r.emonde().minimise(), r2.emonde().minimise()]

#return the automaton recognizing the langage shifted
def shift (self, verb=False):
#détermine la liste des successeurs de l'état initial
cdef int i
cdef int e
l = set()
for j in range(self.a.na):
e = self.a.e[self.a.i].f[j]
if e != -1:
l.add(e)
l = list(l)
if verb:
print "états à considérer : %s"%l
#calcule l'union des automates
a = self.copy()
a.set_initial_state(l[0])
a = a.emonde().minimise()
for i in range(1, len(l)):
b = self.copy()
b.set_initial_state(l[i])
b = b.emonde().minimise()
a = a.union(b)
return a

#modify the automaton to recognize the langage shifted by a (letter given by its index)
def shift1OP (self, int a, verb=False):
if self.a.i != -1:
self.a.i = self.a.e[self.a.i].f[a]

#modify the automaton to recognize the langage shifted by a (letter given by its index)
def shiftOP (self, int a, int np, verb=False):
for i in range(np):
if self.a.i != -1:
self.a.i = self.a.e[self.a.i].f[a]

def unshift1 (self, int a, final=False):
r = FastAutomaton(None)
sig_on()
Expand All @@ -817,6 +799,26 @@ cdef class FastAutomaton:
r.a[0] = aut
r.A = self.A
return r

def unshift (self, int a, int np, final=False):
r = FastAutomaton(None)
sig_on()
cdef Automaton aut
aut = CopyAutomaton(self.a[0], self.a.n+np, self.a.na)
cdef int i
cdef int ne = self.a.n
for j in range(np):
for i in range(aut.na):
aut.e[ne+j].f[i] = -1
if j > 0:
aut.e[ne+j].f[a] = ne+j-1
else:
aut.e[ne+j].f[a] = self.a.i
aut.e[ne+j].final = final
aut.i = ne+np-1
r.a[0] = aut
r.A = self.A
return r

def determinise_proj (self, dict d, noempty=True, onlyfinals=False, nof=False, verb=False):
sig_on()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/monoids/beta_adic_monoid.pyx
Expand Up @@ -182,7 +182,7 @@ cdef InfoBetaAdic initInfoBetaAdic (self, Cd=None, plus=True, verb=False) except
#convert the data in C
n = K.degree()
na = len(parch)
ncmax = 100
ncmax = len(set([c-c2 for c in self.C for c2 in self.C]))
cdef InfoBetaAdic i
if verb: print "alloc..."
i = allocInfoBetaAdic(n, na, ncmax, verb)
Expand Down

0 comments on commit 2a2c283

Please sign in to comment.