zeroDivisors poly
This commit is contained in:
parent
c832ac6197
commit
8eee72c00e
48
Main.java
48
Main.java
@ -23,20 +23,22 @@ public class Main {
|
||||
|
||||
LinkedList<Integer> polynomial = new LinkedList<Integer>();
|
||||
|
||||
//test poly
|
||||
LinkedList<Integer> polynomial2 = new LinkedList<Integer>();
|
||||
|
||||
// wypelnienie wielomianu
|
||||
polynomial = fill(polynomialNumbers, polynomial);
|
||||
|
||||
//test
|
||||
// candidates
|
||||
LinkedList<LinkedList<Integer>> elements = new LinkedList<LinkedList<Integer>>();
|
||||
elements = createCandidates(polynomial,mod);
|
||||
|
||||
// Idemp
|
||||
// output
|
||||
// odwracalne
|
||||
System.out.println(reversible(elements,polynomial,mod));
|
||||
// dzielniki zera
|
||||
System.out.println(zeroDivisors(elements,polynomial,mod));
|
||||
// nilpotenty
|
||||
System.out.println(nilpotent(elements,polynomial,mod));
|
||||
// idempotenty
|
||||
System.out.println(idempotent(elements,polynomial,mod));
|
||||
|
||||
//showPoly(polynomial);
|
||||
}
|
||||
|
||||
// wypelnienie wielomianu
|
||||
@ -347,5 +349,35 @@ public class Main {
|
||||
|
||||
}
|
||||
return p1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static LinkedList<LinkedList<Integer>> zeroDivisors(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> tempSec = new LinkedList<Integer>();
|
||||
LinkedList<Integer> pfinal = new LinkedList<Integer>();
|
||||
|
||||
result.add(elements.get(0));
|
||||
|
||||
for(int i=1; i<elements.size();i++) {
|
||||
|
||||
temp = elements.get(i);
|
||||
|
||||
for(int j=1; j<elements.size(); j++) {
|
||||
|
||||
tempSec = elements.get(j);
|
||||
|
||||
pfinal = polynomialsMultiplication(temp,tempSec);
|
||||
pfinal = modPolynomial(mod,pfinal);
|
||||
|
||||
if(pfinal.equals(expect)) {
|
||||
result.add(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user