2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.io.PrintStream;
26 * An interface that describes a rectangular matrix of double values and
29 public interface MatrixI
32 * Answers the number of columns
39 * Answers the number of rows
46 * Answers the value at row i, column j
52 double getValue(int i, int j);
55 * Sets the value at row i, colum j
61 void setValue(int i, int j, double d);
64 * Answers a copy of the values in the i'th row
68 double[] getRow(int i);
71 * Answers a new matrix with a copy of the values in this one
78 * Returns a new matrix which is the transpose of this one
85 * Returns a new matrix which is the result of premultiplying this matrix by
86 * the supplied argument. If this of size AxB (A rows and B columns), and the
87 * argument is CxA (C rows and A columns), the result is of size CxB.
92 * @throws IllegalArgumentException
93 * if the number of columns in the pre-multiplier is not equal to
94 * the number of rows in the multiplicand (this)
96 MatrixI preMultiply(MatrixI m);
99 * Returns a new matrix which is the result of postmultiplying this matrix by
100 * the supplied argument. If this of size AxB (A rows and B columns), and the
101 * argument is BxC (B rows and C columns), the result is of size AxC.
103 * This method simply returns the result of in.preMultiply(this)
108 * @throws IllegalArgumentException
109 * if the number of rows in the post-multiplier is not equal to the
110 * number of columns in the multiplicand (this)
111 * @see #preMultiply(Matrix)
113 MatrixI postMultiply(MatrixI m);
119 void setD(double[] v);
121 void setE(double[] v);
123 void print(PrintStream ps, String format);
125 void printD(PrintStream ps, String format);
127 void printE(PrintStream ps, String format);
129 void tqli() throws Exception;
134 * Reverses the range of the matrix values, so that the smallest values become
135 * the largest, and the largest become the smallest. This operation supports
136 * using a distance measure as a similarity measure, or vice versa.
138 * If parameter <code>maxToZero</code> is true, then the maximum value becomes
139 * zero, i.e. all values are subtracted from the maximum. This is consistent
140 * with converting an identity similarity score to a distance score - the most
141 * similar (identity) corresponds to zero distance. However note that the
142 * operation is not reversible (unless the original minimum value is zero).
143 * For example a range of 10-40 would become 30-0, which would reverse a
144 * second time to 0-30. Also note that a general similarity measure (such as
145 * BLOSUM) may give different 'identity' scores for different sequences, so
146 * they cannot all convert to zero distance.
148 * If parameter <code>maxToZero</code> is false, then the values are reflected
149 * about the average of {min, max} (effectively swapping min and max). This
150 * operation <em>is</em> reversible.
154 void reverseRange(boolean maxToZero);
157 * Multiply all entries by the given value
161 void multiply(double d);
164 * Answers true if the two matrices have the same dimensions, and corresponding values all differ by no
165 * more than delta (which should be a positive value), else false
171 boolean equals(MatrixI m2, double delta);