Merge branch 'kjvdh/features/PhylogenyViewer_tabbedsupport' into merge/2_11_2/kjvdh...
[jalview.git] / src / jalview / math / MatrixI.java
index 840e93b..4fe31ea 100644 (file)
@@ -22,6 +22,10 @@ package jalview.math;
 
 import java.io.PrintStream;
 
+/**
+ * An interface that describes a rectangular matrix of double values and
+ * operations on it
+ */
 public interface MatrixI
 {
   /**
@@ -64,6 +68,13 @@ public interface MatrixI
   double[] getRow(int i);
 
   /**
+   * Answers a new matrix with a copy of the values in this one
+   * 
+   * @return
+   */
+  MatrixI copy();
+
+  /**
    * Answers all values present in the Matrix ordered by row,column
    * 
    * @return the double array containing the values ordered in {row values} per
@@ -71,19 +82,52 @@ public interface MatrixI
    */
   double[][] getValues();
 
-
-  MatrixI copy();
-
+  /**
+   * Returns a new matrix which is the transpose of this one
+   * 
+   * @return
+   */
   MatrixI transpose();
 
+  /**
+   * Returns a new matrix which is the result of premultiplying this matrix by
+   * the supplied argument. If this of size AxB (A rows and B columns), and the
+   * argument is CxA (C rows and A columns), the result is of size CxB.
+   * 
+   * @param in
+   * 
+   * @return
+   * @throws IllegalArgumentException
+   *           if the number of columns in the pre-multiplier is not equal to
+   *           the number of rows in the multiplicand (this)
+   */
   MatrixI preMultiply(MatrixI m);
 
+  /**
+   * Returns a new matrix which is the result of postmultiplying this matrix by
+   * the supplied argument. If this of size AxB (A rows and B columns), and the
+   * argument is BxC (B rows and C columns), the result is of size AxC.
+   * <p>
+   * This method simply returns the result of in.preMultiply(this)
+   * 
+   * @param in
+   * 
+   * @return
+   * @throws IllegalArgumentException
+   *           if the number of rows in the post-multiplier is not equal to the
+   *           number of columns in the multiplicand (this)
+   * @see #preMultiply(Matrix)
+   */
   MatrixI postMultiply(MatrixI m);
 
   double[] getD();
 
   double[] getE();
 
+  void setD(double[] v);
+
+  void setE(double[] v);
+
   void print(PrintStream ps, String format);
 
   void printD(PrintStream ps, String format);
@@ -123,4 +167,15 @@ public interface MatrixI
    * @param d
    */
   void multiply(double d);
+
+  /**
+   * Answers true if the two matrices have the same dimensions, and
+   * corresponding values all differ by no more than delta (which should be a
+   * positive value), else false
+   * 
+   * @param m2
+   * @param delta
+   * @return
+   */
+  boolean equals(MatrixI m2, double delta);
 }