| |
- add_bit_expressions(bit_expressions)
- Adds n bits, which can be arbitrary expressions, the first n variables of the ring are reversed for usage in this function.
>>> from polybori import *
>>> r=Ring(20)
>>> add_bit_expressions([r.variable(i) for i in xrange(10,13)])
[x(10) + x(11) + x(12), x(10)*x(11) + x(10)*x(12) + x(11)*x(12)]
>>> add_bit_expressions([r.variable(i) for i in xrange(10,13)])
[x(10) + x(11) + x(12), x(10)*x(11) + x(10)*x(12) + x(11)*x(12)]
>>> add_bit_expressions([r.variable(11), r.variable(11)])
[0, x(11)]
>>> add_bit_expressions([r.variable(11),r.variable(12),r.variable(13)])
[x(11) + x(12) + x(13), x(11)*x(12) + x(11)*x(13) + x(12)*x(13)]
- add_bits(bits)
- Adds n bit variables, by Lucas theorem
>>> from polybori import *
>>> r=Ring(10)
>>> add_bits([r.variable(i) for i in xrange(3)])
[x(0) + x(1) + x(2), x(0)*x(1) + x(0)*x(2) + x(1)*x(2)]
>>> add_bits([r.variable(i) for i in xrange(4)])
[x(0) + x(1) + x(2) + x(3), x(0)*x(1) + x(0)*x(2) + x(0)*x(3) + x(1)*x(2) + x(1)*x(3) + x(2)*x(3), x(0)*x(1)*x(2)*x(3)]
>>> add_bits([r.variable(0)])
[x(0)]
- add_bits_old(bits)
- Adds n bits
>>> from polybori import *
>>> r=Ring(10)
>>> add_bits_old([r.variable(i) for i in xrange(3)])
[x(0) + x(1) + x(2), x(0)*x(1) + x(0)*x(2) + x(1)*x(2)]
>>> add_bits_old([r.variable(i) for i in xrange(4)])
[x(0) + x(1) + x(2) + x(3), x(0)*x(1) + x(0)*x(2) + x(0)*x(3) + x(1)*x(2) + x(1)*x(3) + x(2)*x(3)]
- add_words(words)
- def adds n words, this words are supposed to consists of list of their bits.
>>> from polybori import *
>>> r=Ring(1000)
>>> add_words([[r.variable(100+i*3+j) for i in xrange(2)] for j in xrange(3)])
[x(100) + x(101) + x(102), x(100)*x(101) + x(100)*x(102) + x(101)*x(102) + x(103) + x(104) + x(105), x(100)*x(101)*x(103) + x(100)*x(101)*x(104) + x(100)*x(101)*x(105) + x(100)*x(102)*x(103) + x(100)*x(102)*x(104) + x(100)*x(102)*x(105) + x(101)*x(102)*x(103) + x(101)*x(102)*x(104) + x(101)*x(102)*x(105) + x(103)*x(104) + x(103)*x(105) + x(104)*x(105), x(100)*x(101)*x(103)*x(104)*x(105) + x(100)*x(102)*x(103)*x(104)*x(105) + x(101)*x(102)*x(103)*x(104)*x(105)]
>>> res=add_words([[r.variable(100+i*9+j) for i in xrange(4)] for j in xrange(9)])
>>> [len(p) for p in res]
[9, 45, 495, 12870, 735462, 70285482, 1891358892, 6435]
>>> [p.deg() for p in res]
[1, 2, 4, 8, 12, 18, 25, 33]
>>> [p.n_nodes() for p in res]
[9, 25, 54, 100, 153, 211, 249, 100]
- ll_red_nf_redsb(...)
- ll_red_nf_redsb( (Polynomial)arg1, (BooleSet)arg2) -> Polynomial :
C++ signature :
polybori::BoolePolynomial ll_red_nf_redsb(polybori::BoolePolynomial,polybori::BooleSet)
- multiply_by_addition(word_a, word_b)
- Multiply two words
>>> from polybori import Ring
>>> r=Ring(1000)
>>> x = r.variable
>>> n=7
>>> res=multiply_by_addition([x(200+2*i) for i in xrange(n)], [x(200+2*i+1) for i in xrange(n)])
>>> [p.n_nodes() for p in res]
[2, 4, 7, 17, 38, 85, 222, 630, 1358, 1702, 1713, 1430, 875, 214, 0]
|