weight.multiply¶This function is overloaded, it supports these signatures:
weight.multiply(w)
The product of two weights.
weight.multiply(num)
The repeated multiplication (power) of a weight with itself. Exponent -1 denotes the infinity.
weight.multiply((min,max))
The sum of repeated multiplications of an expression: w.multiply((2,4)) = $w^2 + w^3 + w^4$. When min = -1, it denotes 0, when max = -1, it denotes the infinity.
Preconditions:
min <= maximport vcsn
weight = vcsn.context('law_char, q').weight
Instead of a.multiply(b), you may write a * b.
weight('1/2') * weight('3')
weight('1/2').multiply(weight('3'))
Instead of w.multiply(3), you may write w ** 3.
half = weight('1/2')
half ** 3
half ** 0
Use the exponent -1 to mean infinity. Alternatively, you may invoke w.star instead of w ** -1.
half ** -1
half.star()
Instead of w.multiply((2, 4)), you may write w ** (2, 4). Again, use exponent max = -1 to denotes infinity.
half ** (2, 2)
half ** (2, 4)
half ** 2 + half ** 3 + half ** 4
half ** (0, 2)
half ** (1, -1)