From ba302836b7699ba2bf92ab2a0004f1e4f67d14bd Mon Sep 17 00:00:00 2001 From: Paul Mercat Date: Thu, 18 Jun 2015 10:56:32 +0200 Subject: [PATCH] Improve function is_final() and convert function get_la() to use FastAutomaton and not Automaton. Load class FastAutomaton at start. --- src/sage/combinat/words/all.py | 1 + src/sage/combinat/words/cautomata.pyx | 7 +++++-- src/sage/monoids/beta_adic_monoid.pyx | 18 +++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/sage/combinat/words/all.py b/src/sage/combinat/words/all.py index 119377da22e..870916d83e2 100644 --- a/src/sage/combinat/words/all.py +++ b/src/sage/combinat/words/all.py @@ -5,3 +5,4 @@ from word_options import WordOptions from word_generators import words from words import Words +from cautomata import FastAutomaton \ No newline at end of file diff --git a/src/sage/combinat/words/cautomata.pyx b/src/sage/combinat/words/cautomata.pyx index effa924d25f..a1946c5111d 100644 --- a/src/sage/combinat/words/cautomata.pyx +++ b/src/sage/combinat/words/cautomata.pyx @@ -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 diff --git a/src/sage/monoids/beta_adic_monoid.pyx b/src/sage/monoids/beta_adic_monoid.pyx index b5d52f5d4b4..655334a9e38 100644 --- a/src/sage/monoids/beta_adic_monoid.pyx +++ b/src/sage/monoids/beta_adic_monoid.pyx @@ -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: @@ -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() @@ -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: