multiplication of galois field polynomials in c# / c++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • awais888
    New Member
    • Mar 2010
    • 3

    multiplication of galois field polynomials in c# / c++

    i need a code to multiply two polynomials in galois field 2 in c# or c++,
    polynomials will be entered by user in integer (decimal values).
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Have you written any code for it? What problem you are getting?

    Regards
    Dheeraj Joshi

    Comment

    • awais888
      New Member
      • Mar 2010
      • 3

      #3
      yes, i have written the code.
      code is in 2 parts, i made 2 methods for it: please check it out

      Code:
      // xtime method
        static uint xtime(uint a)
              {
                  a = a << 1;
                  uint m = 1;
                  int d = degree(a); //it determines the degree of polynomial
                  uint f = (uint)((1 << d) | 3);
                  m = m << d - 1;
                  if ((a & m) == m)
                      return (a ^ f);
                  else
                      return a;  
              }

      // multiplication

      Code:
      static uint mult(uint a, uint b)
              {
                  
                  uint val = a;
                  if (b % 2 == 0)
                  {
                      for (uint i = 1; i < b; i *= 2)
                      {
                          val = xtime(val);
                      }
                  }
                  else
                  {
                      for (uint i = 1; i < b; i *= 2)
                      {
                          val = xtime(val) ^ val; ;
                      }
                  }
                  return val;
              }
      Last edited by tlhintoq; Mar 31 '10, 11:38 AM. Reason: [CODE] ...Your code goes between code tags [/CODE]

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        You already have code for something you say you need.
        No mention of problems, errors, exceptions or the issue you are trying to solve. Just what is it you are in need of?
        Please visit the Posting Guidelines for tips on how to ask questions to get the best help.

        Comment

        • Dheeraj Joshi
          Recognized Expert Top Contributor
          • Jul 2009
          • 1129

          #5
          Yep, What problem you are facing?

          Regards
          Dheeraj Joshi

          Comment

          • awais888
            New Member
            • Mar 2010
            • 3

            #6
            hi
            its answer is incorrect,
            i dont know where is the mistake, can u detect error or you have any other method to solve it..?

            Comment

            • tlhintoq
              Recognized Expert Specialist
              • Mar 2008
              • 3532

              #7
              So you are saying that the code runs, but that it doesn't calculate the correct answer that you expected?

              This is very obviously a homework/school/class/course assignment. We've gone about as far out as we can. But in the end, we can't do your homework for you.

              Comment

              Working...