diff --git a/src/sage/combinat/words/automataC.c b/src/sage/combinat/words/automataC.c index 123ba900501..7bb1b1982b3 100644 --- a/src/sage/combinat/words/automataC.c +++ b/src/sage/combinat/words/automataC.c @@ -98,9 +98,9 @@ Automaton NewAutomaton (int n, int na) Automaton a; a.n = n; a.na = na; + a.i = -1; if (n == 0) { - a.i = -1; a.e = NULL; return a; } @@ -111,7 +111,7 @@ Automaton NewAutomaton (int n, int na) printf("Out of memory !"); exit(6); } - int i; + int i,j; for (i=0;i= nv) + nv = d.e[i]+1; + } + // + if (verb) + printf("Pas d'état initial !\n"); + if (nof) + { + r = NewAutomaton(1, nv); + r.i = 0; + r.e[0].final = true; + for (i=0;i= self.a.n: raise ValueError("L'etat %s n'existe pas."%i) + if j >= self.a.n: raise ValueError("L'etat %s n'existe pas."%j) + try: + k = self.A.index(l) + except: + raise ValueError("La lettre %s n'existe pas."%l) + self.a.e[i].f[k] = j + def n_states (self): return self.a.n diff --git a/src/sage/monoids/beta_adic_monoid.pyx b/src/sage/monoids/beta_adic_monoid.pyx index f7848368f9b..c810e7aaaa6 100644 --- a/src/sage/monoids/beta_adic_monoid.pyx +++ b/src/sage/monoids/beta_adic_monoid.pyx @@ -1514,6 +1514,13 @@ class BetaAdicMonoid(Monoid_class): Cd is the set of differences A-B where A and B are the alphabets to compare. t is the translation of one of the side (initial state of the automaton). ext : automate des relations à l'infini ou pas. + + + TESTS:: + + sage: pi = x^3-x^2-x-1 + sage: b = pi.roots(ring=QQbar)[1][0] + sage: m = BetaAdicMonoid(b, [0,1]).relations_automaton3() """ if Cd is None: Cd = Set([c-c2 for c in self.C for c2 in self.C]) @@ -2626,16 +2633,21 @@ class BetaAdicMonoid(Monoid_class): #compute the relations automaton with translation t ar = self.relations_automaton4(t=t, A=A, B=B, couples=True, verb=verb) #compute the product of a and b + if verb: print("product...") ap = a.product(b) #compute the intersections + if verb: print("intersection...") ai = ar.intersection(ap) + if verb: print("min...") ai = ai.minimise() #project on one side d={} for c1 in A: for c2 in B: d[(c1,c2)] = c2 + if verb: print("determinise...") ai = ai.determinise_proj(d, verb=verb) + if verb: print("min") return ai.minimise() #Not well tested !!!! diff --git a/src/sage/monoids/relations.c b/src/sage/monoids/relations.c index aefc8c781a4..902f55b7ca3 100644 --- a/src/sage/monoids/relations.c +++ b/src/sage/monoids/relations.c @@ -22,7 +22,7 @@ Automate NewAutomaton (int n, int na) printf("Out of memory !"); exit(6); } - int i; + int i, j; for (i=0;i npile) + if (n >= npile) { - printf("Erreur : dépassement de la pile !!!\n"); + printf("*****************************************\n*** Erreur : dépassement de la pile !!! ***\n*****************************************\n"); } }else {//on retombe sur un état déjà vu @@ -612,13 +643,6 @@ Automate RelationsAutomatonT (InfoBetaAdic iba2, Element t, bool isvide, bool ex //créé l'automate Automate r = NewAutomaton(compteur, iba.nc); - for (i=0;i