|
|
@ -1,10 +1,8 @@ |
|
|
|
public class CheckSparseVector { |
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
|
|
|
|
// (ausgelagert) |
|
|
|
|
|
|
|
// erstellen des this.Vektors = control Vector |
|
|
|
SparseVector controlVector = new SparseVector(10); |
|
|
|
controlVector.setElement(0, 10.0); |
|
|
@ -78,8 +76,8 @@ public class CheckSparseVector { |
|
|
|
} |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
|
|
|
|
|
// Testen des this. Vektors --> testen Methoden wie getLength(), getElement(), setElement(), removeElement() |
|
|
|
// Testen des this. Vektors --> testen Methoden wie getLength(), getElement(), |
|
|
|
// setElement(), removeElement() |
|
|
|
System.out.println("die Länge des controlVector ist: " + controlVector.getLength()); // 10 |
|
|
|
System.out.println("der Wert des controlVector an der Position 5 ist: " + controlVector.getElement(5)); // 123.213 |
|
|
|
System.out.println("der Wert des controlVector an der Position 0 ist: " + controlVector.getElement(0)); // 10.0 |
|
|
@ -96,7 +94,8 @@ public class CheckSparseVector { |
|
|
|
} |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
|
// testen equal(), wenn die beiden Vektoren identisch sind → should be true, not anymore :) |
|
|
|
// testen equal(), wenn die beiden Vektoren identisch sind → should be true, not |
|
|
|
// anymore :) |
|
|
|
System.out.println(controlVector.equals(otherVector1)); |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
@ -114,7 +113,8 @@ public class CheckSparseVector { |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
|
// testen equals(other) --> nicht identisch |
|
|
|
System.out.println(controlVector.equals(otherVector1)); // should be false, weil der Wert an Index 5 zu 100 gesetzt wurde |
|
|
|
System.out.println(controlVector.equals(otherVector1)); // should be false, weil der Wert an Index 5 zu 100 gesetzt |
|
|
|
// wurde |
|
|
|
System.out.println(controlVector.equals(otherVector2)); // should be false |
|
|
|
System.out.println(controlVector.equals(otherVector3)); // should be false |
|
|
|
System.out.println(controlVector.equals(otherVector4)); // should be false |
|
|
@ -122,19 +122,25 @@ public class CheckSparseVector { |
|
|
|
|
|
|
|
otherVector1.setElement(5, 100); |
|
|
|
System.out.println("der Wert des otherVector1 an der Position 5 ist: " + otherVector1.getElement(5)); // 100.0 |
|
|
|
System.out.println(otherVector1.equals(controlVector));// should be true, weil der Wert an Index 5 von this und other Vektor gleich 100 |
|
|
|
System.out.println(otherVector1.equals(controlVector));// should be true, weil der Wert an Index 5 von this und |
|
|
|
// other Vektor gleich 100 |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
|
|
|
|
|
// testen add() |
|
|
|
controlVector.add(otherVector1); |
|
|
|
|
|
|
|
System.out.println("die Länge des controlVector ist: " + controlVector.getLength()); // 10 |
|
|
|
System.out.println("der Wert des controlVector an der Position 0 ist: "+ controlVector.getElement(0)); // 10 + 10 = 20 |
|
|
|
System.out.println("der Wert des controlVector an der Position 5 ist: " + controlVector.getElement(5)); // 100 + 100 = 200 |
|
|
|
System.out.println("der Wert des controlVector an der Position 0 ist: " + controlVector.getElement(0)); // 10 + 10 = |
|
|
|
// 20 |
|
|
|
System.out.println("der Wert des controlVector an der Position 5 ist: " + controlVector.getElement(5)); // 100 + 100 |
|
|
|
// = 200 |
|
|
|
System.out.println("der Wert des controlVector an der Position 6 ist: " + controlVector.getElement(6)); // 0.0 |
|
|
|
System.out.println("der Wert des controlVector an der Position 8 ist: " + controlVector.getElement(8)); // 65.01 + 65.01 = 130.02 |
|
|
|
System.out.println("der Wert des controlVector an der Position 9 ist: " + controlVector.getElement(9)); // 112.79 + 112.79 = 225.58 |
|
|
|
System.out.println("der Wert des controlVector an der Position 8 ist: " + controlVector.getElement(8)); // 65.01 + |
|
|
|
// 65.01 = |
|
|
|
// 130.02 |
|
|
|
System.out.println("der Wert des controlVector an der Position 9 ist: " + controlVector.getElement(9)); // 112.79 + |
|
|
|
// 112.79 = |
|
|
|
// 225.58 |
|
|
|
System.out.println("\n"); |
|
|
|
|
|
|
|
controlVector.add(otherVector2); |
|
|
|