示例#1
0
  /** @return an element */
  public double getElement(int row, int column) {

    if (!distancesKnown) {
      calculateDistances();
    }

    return distances[row][column];
  }
示例#2
0
  /** set an element - this overwrites any existing elements */
  public void setElement(int row, int column, double value) {

    if (!distancesKnown) {
      calculateDistances();
    }

    distances[row][column] = value;
  }
示例#3
0
  /** Returns the mean pairwise distance of this matrix */
  public double getMeanDistance() {
    if (!distancesKnown) {
      calculateDistances();
    }

    double dist = 0.0;
    int count = 0;
    for (int i = 0; i < dimension; i++) {
      for (int j = 0; j < dimension; j++) {
        if (i != j) {
          dist += distances[i][j];
          count += 1;
        }
      }
    }
    return dist / (double) count;
  }