JAL-2403 JAL-1483 push 'reverseRange' inside Matrix
[jalview.git] / src / jalview / math / MatrixI.java
index d74a98b..d7a1b70 100644 (file)
@@ -28,6 +28,15 @@ public interface MatrixI
   double getValue(int i, int j);
 
   /**
+   * Sets the value at row i, colum j
+   * 
+   * @param i
+   * @param j
+   * @param d
+   */
+  void setValue(int i, int j, double d);
+
+  /**
    * Answers a copy of the values in the i'th row
    * 
    * @return
@@ -56,4 +65,26 @@ public interface MatrixI
 
   void tred();
 
+  /**
+   * Reverses the range of the matrix values, so that the smallest values become
+   * the largest, and the largest become the smallest. This operation supports
+   * using a distance measure as a similarity measure, or vice versa.
+   * <p>
+   * If parameter <code>maxToZero</code> is true, then the maximum value becomes
+   * zero, i.e. all values are subtracted from the maximum. This is consistent
+   * with converting a similarity score to a distance score - the most similar
+   * (identity) corresponds to zero distance. However note that the operation is
+   * not reversible (unless the original minimum value is zero). For example a
+   * range of 10-40 would become 30-0, which would reverse a second time to
+   * 0-30. Also note that a similarity measure (such as BLOSUM) may give
+   * different identity scores for different sequences, so they cannot all
+   * convert to zero distance.
+   * <p>
+   * If parameter <code>maxToZero</code> is false, then the values are reflected
+   * about the average of {min, max} (effectively swapping min and max). This
+   * operation <em>is</em> reversible.
+   * 
+   * @param maxToZero
+   */
+  void reverseRange(boolean maxToZero);
 }