Beispiel #1
0
 public static HashMap<PolyBase, PolyBase> revElemeMap(int fl) {
   ArrayList<PolyBase> elems = PolyBase.getFieldElems(fl);
   HashMap<PolyBase, PolyBase> elemRevMap = new HashMap<>();
   for (PolyBase elem : elems) {
     elemRevMap.put(elem, PolyBase.revElem(elem, fl));
   }
   return elemRevMap;
 }
Beispiel #2
0
 public static ArrayList<PolyBase> getFieldElems(Integer st) {
   ArrayList<PolyBase> res = new ArrayList<>();
   for (int i = 0; i < Math.pow(2, st); i++) {
     PolyBase t = new PolyBase(Integer.toBinaryString(i));
     t.number = i;
     t.getBigger();
     res.add(t);
   }
   return res;
 }
Beispiel #3
0
 public static ArrayList<Integer> errorFlow(int n) {
   ArrayList<Integer> result = new ArrayList<>();
   for (int i = 0; i < fl; i++) {
     int co = 0;
     for (int j = 0; j < elems.size(); j++) {
       PolyBase el = sum(elems.get(j), getEi(i));
       el.getBigger();
       co += (getf(n, j) + getf(n, elems.indexOf(el))) % 2;
     }
     result.add(co);
   }
   System.out.println("ErrorFlow counted");
   return result;
 }
Beispiel #4
0
 public static PolyBase bigGenLength(PolyBase a) {
   PolyBase oldGen = new PolyBase(generator.toString());
   Integer dif = a.decomposition.size() - oldGen.decomposition.size();
   for (int i = 0; i < dif; i++) {
     oldGen.decomposition.add(0);
   }
   return oldGen;
 }
Beispiel #5
0
  public static PolyBase gornerMeth2(PolyBase a, int b, Integer fl) {
    PolyBase temp = new PolyBase(a.toString());
    PolyBase result = one(fl);
    String pow = Integer.toBinaryString(b);
    for (int i = 0; i < pow.length(); i++) {
      result = square(result);
      if (pow.charAt(i) == '1') {
        result = multiplication(result, temp);
      }
    }

    return result;
  }
Beispiel #6
0
 public static ArrayList<PolyBase> getFuncRes(ArrayList<PolyBase> elts, String fc) {
   ArrayList<PolyBase> result = new ArrayList<>();
   int o = 0;
   int all = (int) Math.pow(2, fl);
   if (fc.equals("rev")) {
     for (PolyBase i : elts) {
       System.out.println("Element " + i + " started");
       i.getBigger();
       PolyBase t = revElem(i, fl);
       t.getBigger();
       result.add(t);
       System.out.println("Element " + t + " added");
       o++;
       System.out.println((all - o) + " elements to go");
     }
   }
   if (fc.equals("sec")) {
     for (PolyBase i : elts) {
       i.getBigger();
       PolyBase t = new PolyBase(i.toString());
       t = gornerMeth2(t, (int) Math.pow(2, fl) - 3, fl);
       t.getBigger();
       result.add(t);
     }
   }
   if (fc.equals("15")) {
     for (PolyBase i : elts) {
       i.getBigger();
       PolyBase t = new PolyBase(i.toString());
       t = gornerMeth2(t, 131, fl);
       t.getBigger();
       result.add(t);
     }
   }
   return result;
 }