modified: src/de/dhbwstuttgart/typeinference/unify/TypeUnifyTask.java
modified: test/javFiles/Matrix.jav Rekursive Berechnung des Kartesischen Produkts
This commit is contained in:
parent
1f269918fb
commit
e4fbd17a55
@ -155,9 +155,32 @@ public class TypeUnifyTask extends RecursiveTask<Set<Set<UnifyPair>>> {
|
|||||||
}
|
}
|
||||||
topLevelSets.add(flat);
|
topLevelSets.add(flat);
|
||||||
}
|
}
|
||||||
|
return computeCartesianRecursive(new HashSet<>(), new ArrayList<>(topLevelSets));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Set<UnifyPair>> computeCartesianRecursive(Set<Set<UnifyPair>> fstElems, ArrayList<Set<Set<UnifyPair>>> sets) {
|
||||||
|
ArrayList<Set<Set<UnifyPair>>> newSets = new ArrayList<>(sets);
|
||||||
|
Set<Set<UnifyPair>> set = newSets.remove(0);
|
||||||
|
ArrayList<Set<UnifyPair>> newSet = new ArrayList<>(set);
|
||||||
|
Set<Set<UnifyPair>> result = null;
|
||||||
|
for(Set<UnifyPair> a : newSet) {
|
||||||
|
Set<Set<UnifyPair>> elems = new HashSet<Set<UnifyPair>>(fstElems);
|
||||||
|
elems.add(a);
|
||||||
|
if (newSets.isEmpty()) {
|
||||||
|
result = unify2(elems);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = computeCartesianRecursive(elems,newSets);
|
||||||
|
}
|
||||||
|
if (!result.isEmpty()) break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<Set<UnifyPair>> unify2(Set<Set<UnifyPair>> setToFlatten) {
|
||||||
|
//Set<Set<UnifyPair>> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
|
||||||
Set<Set<UnifyPair>> setToFlatten = topLevelSets.stream().map(x -> x.iterator().next()).collect(Collectors.toCollection(HashSet::new));
|
|
||||||
// Cartesian product over all (up to 10) top level sets
|
// Cartesian product over all (up to 10) top level sets
|
||||||
//Set<Set<Set<UnifyPair>>> eqPrimeSet = setOps.cartesianProduct(topLevelSets)
|
//Set<Set<Set<UnifyPair>>> eqPrimeSet = setOps.cartesianProduct(topLevelSets)
|
||||||
//.stream().map(x -> new HashSet<>(x))
|
//.stream().map(x -> new HashSet<>(x))
|
||||||
|
@ -11,13 +11,13 @@ class Matrix extends Vector<Vector<Integer>> {
|
|||||||
var v2 = new Vector<Integer>();
|
var v2 = new Vector<Integer>();
|
||||||
var j = 0;
|
var j = 0;
|
||||||
while(j < v1.size()) {
|
while(j < v1.size()) {
|
||||||
var erg = 0;
|
//var erg = 0;
|
||||||
var k = 0;
|
//var k = 0;
|
||||||
while(k < v1.size()) {
|
//while(k < v1.size()) {
|
||||||
erg = erg + v1.elementAt(k)
|
//erg = erg + v1.elementAt(k)
|
||||||
* m.elementAt(k).elementAt(j);
|
// * m.elementAt(k).elementAt(j);
|
||||||
k++; }
|
//k++; }
|
||||||
v2.addElement(new Integer(erg));
|
//v2.addElement(new Integer(erg));
|
||||||
j++; }
|
j++; }
|
||||||
ret.addElement(v2);
|
ret.addElement(v2);
|
||||||
i++; }
|
i++; }
|
||||||
|
Loading…
Reference in New Issue
Block a user