Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 4
0
 public Object clone() throws CloneNotSupportedException {
   Object arrayVector = super.clone();
   ((Vector) arrayVector).fillFromMass(mass);
   return arrayVector;
 }