Published by Graham Sutherland / Polynomial

published

Graham Sutherland / Polynomial's Post

In Reply To: this post

spoiler/help

I think if you do the polynomial product A(x)∙B(x) to get C'(x), then interpret the coefficients of C'(x) and P(x) as bit vectors, you can do the modulo reduction as follows:

```
c = c'
while c >= 2^3:
sh = msb(c)-msb(p)
p' = p<<sh
c ^= p'
```

where msb() returns the index of the MSB.

so in his example of C'(x)=x^4+x^3+x+1 and P(x)=x^3+x+1, the steps are:

p=1011 (x^3+x+1)
c'=11011 (x^4+x^3+x+1)
c=11011
c>=2^3
sh=1
p'=10110
c=1101
c>=2^3
sh=0
p'=1011
c=110
c<2^3

thus, c=x^2+x


Likes: 0
Boosts: 0
Hashtags:
Mentions:

Comments

Displaying 0 of 0 comments