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

Commit

Permalink
Improve function is_final() and convert function get_la() to use Fast…
Browse files Browse the repository at this point in the history
…Automaton and not Automaton. Load class FastAutomaton at start.
  • Loading branch information
mercatp committed Jun 18, 2015
1 parent b590f0e commit ba30283
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/sage/combinat/words/all.py
Expand Up @@ -5,3 +5,4 @@
from word_options import WordOptions
from word_generators import words
from words import Words
from cautomata import FastAutomaton
7 changes: 5 additions & 2 deletions src/sage/combinat/words/cautomata.pyx
Expand Up @@ -468,8 +468,11 @@ cdef class FastAutomaton:
raise ValueError("%d is not a state !"%f)
self.a.e[f].final = 1

def is_final (self, e):
return Bool(self.a.e[e].final)
def is_final (self, int e):
if e >= 0 and e < self.a.n:
return Bool(self.a.e[e].final)
else:
return False

def set_final_state (self, int e, final=True):
self.a.e[e].final = final
Expand Down
18 changes: 9 additions & 9 deletions src/sage/monoids/beta_adic_monoid.pyx
Expand Up @@ -542,11 +542,11 @@ class BetaAdicMonoid(Monoid_class):
#raise ValueError("la, ss, or tss must be defined !")
if verb:
print "Compute the transposition of tss=%s..."%tss
ss = tss.transpose().determinize()
ss = tss.transpose().determinise() #ze()
if verb:
print ss
print "simplify..."
ss = ss.emonde0_simplify()
ss = ss.emonde_inf() #emonde0_simplify()
if verb:
print ss
if tss is None:
Expand All @@ -555,26 +555,26 @@ class BetaAdicMonoid(Monoid_class):
#raise ValueError("la, ss, or tss must be defined !")
if verb:
print "Compute the transposition of ss=%s..."%ss
tss = ss.transpose().determinize()
tss = ss.transpose().determinise() #ze()
if verb:
print tss
print "simplify..."
tss = tss.emonde0_simplify()
tss = tss.emonde_inf() #0_simplify()
if verb:
print tss
#compute la
a = {}
for v in ss.vertices():
a[v] = Automaton(ss)
for v in ss.states(): #ss.vertices():
a[v] = Automaton(ss) ##################################################################################
a[v].I = [list(ss.I)[0]]
a[v].F = [v]
if verb:
print "Compute the transposition..."
a[v] = a[v].transpose().determinize()
a[v] = a[v].transpose().determinise() #ze()
if verb:
print a[v]
print "simplify..."
a[v] = a[v].emonde0_simplify()
a[v] = a[v].emonde_inf()
if verb:
print a[v]
return [tss]+a.values()
Expand Down Expand Up @@ -1846,7 +1846,7 @@ class BetaAdicMonoid(Monoid_class):
arel = self.relations_automaton3(Cd=Cd, ext=False)
arel = arel.emonde()
if transpose:
arel = arel.transpose()
arel = arel.transpose_det()
if verb:
print "arel = %s"%arel
if step == 1:
Expand Down

0 comments on commit ba30283

Please sign in to comment.