automaton.lweight(weight, algo="auto")

The left scalar product of an automaton by a weight.

The algo parameter must be one of these:

  • "auto": default parameter, same as "standard".
  • "general": puts the weight on the initial transitions.
  • "standard": does not put the weight on the initial transitions.

Postconditions:

  • "standard": when applied to standard automata, the result is standard.

See also:

In [1]:
import vcsn
a = vcsn.context('lal_char, q').expression('<2>a<3>b<4>', 'none').standard()
a
Out[1]:
%3 I0 0 0 I0->0 F3 1 1 0->1 ⟨2⟩a 3 3 1->3 ⟨3⟩b 3->F3 ⟨4⟩
In [2]:
a.lweight(a.context().weight('5'))
Out[2]:
%3 I0 0 0 I0->0 F2 1 1 0->1 ⟨10⟩a 2 2 1->2 ⟨3⟩b 2->F2 ⟨4⟩

Instead of a.lweight(a.context().weight('5')), you may write 5 * a.

In [3]:
5 * a
Out[3]:
%3 I0 0 0 I0->0 F2 1 1 0->1 ⟨10⟩a 2 2 1->2 ⟨3⟩b 2->F2 ⟨4⟩

To force the execution of the general algorithm you can do it this way.

In [4]:
a.lweight(a.context().weight('5'), 'general')
Out[4]:
%3 I0 0 0 I0->0 ⟨5⟩ F2 1 1 0->1 ⟨2⟩a 2 2 1->2 ⟨3⟩b 2->F2 ⟨4⟩