示例#1
0
 public static PolyBase mod(PolyBase a) {
   PolyBase rest = a;
   while (rest.decomposition.size() >= bigGenLength(rest).decomposition.size()) {
     rest = sum(rest, bigGenLength(rest));
     clear(rest);
   }
   return rest;
 }
示例#2
0
 public static PolyBase multiplication(PolyBase a, PolyBase b) {
   PolyBase result = new PolyBase();
   result.decomposition.setSize(a.decomposition.size() + b.decomposition.size() - 1);
   nullToZero(result);
   for (int i = 0; i < a.decomposition.size(); i++) {
     for (int j = 0; j < b.decomposition.size(); j++) {
       if (a.decomposition.get(i) == 1 && b.decomposition.get(j) == 1) {
         result.decomposition.set(i + j, result.decomposition.get(i + j) ^ 1);
       }
     }
   }
   clear(result);
   return mod(result);
 }