示例#1
0
  public Vector getColumn(int index) {
    validateRowIndex(index);

    Vector column = new Vector(rows.length);
    for (int i = 0; i < rows.length; ++i) {
      column.setValue(i, rows[i].getValue(index));
    }
    return column;
  }
示例#2
0
  public Vector multiplicationOnVector(Vector vector) {
    try {
      if (vector.getSize() != rows[0].getSize()) {
        throw new Exception("Длинна вектора не совпадает с колличеством столбцов в матрице");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    Vector resultVector = new Vector(vector.getSize());

    for (int i = 0; i < rows.length; ++i) {
      double result = 0;

      for (int j = 0; j < rows[i].getSize(); ++j) {
        result += rows[i].getValue(j) * vector.getValue(j);
      }

      resultVector.setValue(i, result);
    }
    return resultVector;
  }