X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fmath%2FMatrixI.java;h=4fe31eae1b9bcbe8a17c9edbd613d2e6d375a39a;hb=f96e6a945e2df8a844f428c08cfc08210d937fc0;hp=f0603dd3cb0dc36a09996661610c0daa132fc35f;hpb=582493a5b56d3e01d901c6da9906685c31a32abb;p=jalview.git diff --git a/src/jalview/math/MatrixI.java b/src/jalview/math/MatrixI.java index f0603dd..4fe31ea 100644 --- a/src/jalview/math/MatrixI.java +++ b/src/jalview/math/MatrixI.java @@ -1,7 +1,31 @@ +/* + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 + * of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. + */ package jalview.math; import java.io.PrintStream; +/** + * An interface that describes a rectangular matrix of double values and + * operations on it + */ public interface MatrixI { /** @@ -28,7 +52,7 @@ public interface MatrixI double getValue(int i, int j); /** - * Sets the value at row i, colum j + * Sets the value at row i, column j * * @param i * @param j @@ -42,19 +66,68 @@ public interface MatrixI * @return */ 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 + * column + */ + double[][] getValues(); + + /** + * 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. + *

+ * 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); @@ -87,4 +160,22 @@ public interface MatrixI * @param maxToZero */ void reverseRange(boolean maxToZero); + + /** + * Multiply all entries by the given value + * + * @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); }