add nilpotent

This commit is contained in:
Krystian Madra 2018-06-28 07:53:40 +02:00
parent 4fc2ee088c
commit 7b0bd3d83c

View File

@ -270,6 +270,43 @@ public class Main {
return result; return result;
} }
public static LinkedList<LinkedList<Integer>> nilpotent(LinkedList<LinkedList<Integer>> elements,LinkedList<Integer> expect, int mod) {
LinkedList<LinkedList<Integer>> result = new LinkedList<LinkedList<Integer>>();
LinkedList<Integer> temp = new LinkedList<Integer>();
LinkedList<Integer> tempPow = new LinkedList<Integer>();
result.add(elements.get(0));
for(int i=1; i<elements.size();i++) {
temp = elements.get(i);
for(int j=2; j<mod; j++)
tempPow = temp;
temp = polynomialsMultiplication(tempPow,temp);
// mod
temp = modPolynomial(mod,temp);
if(temp.size() >= expect.size()) {
temp = dividePolynomials(temp, expect, mod);
}
else continue;
if(temp.size() == 1 && temp.getFirst() == 0) {
result.add(elements.get(i));
}
}
return result;
}
} }