How can I divide bitsets?

Mefgaif Grertgy

I use two bitsets to store two polynomials. I want one of them to be divided by 2nd and I want to get remainder after division. For example if I would like it on the paper:

w1= 110011010000000
w2 = 1111001

           101000100
     110011010000000 : 1111001
     1111001
     --1111110
       1111001
       ----1110000
           1111001
           ---100100 = remainder
Chris Dodd

Very few CPUs have builtin instructions for GF(2) division like this, so you'll need to implement it yourself with shifts and xors. Basically, you implement it exactly like you did it on paper -- shift the divisor up until its top bit matches that of dividend, then xor and shift back down, recording each position where you need an xor as a bit of the quotient. If all the polynomials in question fit in a single word, you can just use unsigned integer types for it. Otherwise, you'll need some multiprecision bitset type. The C++ std::bitset can be used for this, despite its problems (no easy way to convert between bitsets of different sizes, no bitscan functions).

template<size_t N> int top_bit_set(const bitset<N> &a) {
    int i;
    for (i = N-1; i >= 0; i--)
        if (a.test(i)) break;
    return i;
}


template<size_t N>
bitset<N> gf2_div(bitset<N> dividend, bitset<N> divisor, bitset<N> &remainder) {
    bitset<N> quotient(0);
    int divisor_size = top_bit_set(divisor);
    if (divisor_size < 0) throw divide_by_zero();
    int bit;
    while ((bit = top_bit_set(dividend)) >= divisor_size) {
        quotient.set(bit - divisor_size);
        dividend ^= divisor << (bit - divisor_size); }
    remainder = dividend;
    return quotient;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I divide bitsets?

From Dev

How can I divide the partitions?

From Dev

How can I divide up a pandas dataframe?

From Dev

How can I "divide" words with regular expressions?

From Dev

How can I divide into threads using ExecuterService?

From Dev

How can I divide two table fields?

From Dev

How can I divide up a pandas dataframe?

From Dev

How can I divide output with delimiter?

From Dev

How can I divide two table fields?

From Dev

How I can divide two statement in PHP

From Dev

How can I divide a vector in c++

From Dev

How can I update and divide column values?

From Dev

How can I divide a List into tokens by comma

From Dev

How can I multiply or divide value under the cursor by a repeat count?

From Dev

how can i divide two columns in SQL using java?

From Dev

How can I make git commit messages divide into multiple lines?

From Dev

How can I divide 2 series in Grafana with CloudWatch?

From Dev

How can i output divide sign through php

From Dev

How can I divide a vector into two equal vectors?

From Dev

How can I divide grouped data by date in do columns

From Dev

How can I divide the sum of my array elements with their amount?

From Dev

How can I divide processes amongst multiple computers

From Dev

How can I divide a number string by 1000 without converting to number?

From Dev

How can I divide my pivot columns by the total across the row?

From Dev

How can I divide two sentence including web page address?

From Dev

How can i divide the parts of the image attached here for bootstrap support?

From Dev

How can I divide the sum of my array elements with their amount?

From Dev

how can i divide two columns in SQL using java?

From Dev

How can i divide two expressions in Microsoft SQL Server

Related Related

  1. 1

    How can I divide bitsets?

  2. 2

    How can I divide the partitions?

  3. 3

    How can I divide up a pandas dataframe?

  4. 4

    How can I "divide" words with regular expressions?

  5. 5

    How can I divide into threads using ExecuterService?

  6. 6

    How can I divide two table fields?

  7. 7

    How can I divide up a pandas dataframe?

  8. 8

    How can I divide output with delimiter?

  9. 9

    How can I divide two table fields?

  10. 10

    How I can divide two statement in PHP

  11. 11

    How can I divide a vector in c++

  12. 12

    How can I update and divide column values?

  13. 13

    How can I divide a List into tokens by comma

  14. 14

    How can I multiply or divide value under the cursor by a repeat count?

  15. 15

    how can i divide two columns in SQL using java?

  16. 16

    How can I make git commit messages divide into multiple lines?

  17. 17

    How can I divide 2 series in Grafana with CloudWatch?

  18. 18

    How can i output divide sign through php

  19. 19

    How can I divide a vector into two equal vectors?

  20. 20

    How can I divide grouped data by date in do columns

  21. 21

    How can I divide the sum of my array elements with their amount?

  22. 22

    How can I divide processes amongst multiple computers

  23. 23

    How can I divide a number string by 1000 without converting to number?

  24. 24

    How can I divide my pivot columns by the total across the row?

  25. 25

    How can I divide two sentence including web page address?

  26. 26

    How can i divide the parts of the image attached here for bootstrap support?

  27. 27

    How can I divide the sum of my array elements with their amount?

  28. 28

    how can i divide two columns in SQL using java?

  29. 29

    How can i divide two expressions in Microsoft SQL Server

HotTag

Archive