예제 #1
0
  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);
    }
  }
예제 #2
0
  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);
    }
  }
예제 #3
0
  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;
  }