public void sum(Vector newVector) throws IncompatibleVectorSizesException { if (size != newVector.getSize()) { throw new IncompatibleVectorSizesException(); } for (int i = 0; i < size; i++) { mass[i] = mass[i] + newVector.getElement(i); } }
public void fillFromVector(Vector newVector) { int newMassLength = newVector.getSize(); if (size != newMassLength) { size = newMassLength; mass = new double[size]; } for (int i = 0; i < size; i++) { mass[i] = newVector.getElement(i); } }
public boolean equal(Vector newVector) { int newMassLength = newVector.getSize(); if (size != newMassLength) { System.out.println("Vectors have different length"); return false; } for (int i = 0; i < newMassLength; i++) { if (mass[i] != newVector.getElement(i)) return false; } return true; }