2fa34c394b98de214ea15343b7c846acd7aa2f69
[jalview.git] / src / jalview / math / MatrixI.java
1 package jalview.math;
2
3 import java.io.PrintStream;
4
5 public interface MatrixI
6 {
7   /**
8    * Answers the number of columns
9    * 
10    * @return
11    */
12   int width();
13
14   /**
15    * Answers the number of rows
16    * 
17    * @return
18    */
19   int height();
20
21   /**
22    * Answers the value at row i, column j
23    * 
24    * @param i
25    * @param j
26    * @return
27    */
28   double getValue(int i, int j);
29
30   /**
31    * Sets the value at row i, colum j
32    * 
33    * @param i
34    * @param j
35    * @param d
36    */
37   void setValue(int i, int j, double d);
38
39   /**
40    * Answers a copy of the values in the i'th row
41    * 
42    * @return
43    */
44   double[] getRow(int i);
45
46   MatrixI copy();
47
48   MatrixI transpose();
49
50   MatrixI preMultiply(MatrixI m);
51
52   MatrixI postMultiply(MatrixI m);
53
54   double[] getD();
55
56   double[] getE();
57
58   void print(PrintStream ps, String format);
59
60   void printD(PrintStream ps, String format);
61
62   void printE(PrintStream ps, String format);
63
64   void tqli() throws Exception;
65
66   void tred();
67
68   /**
69    * Reverses the range of the matrix values, so that the smallest values become
70    * the largest, and the largest become the smallest. This operation supports
71    * using a distance measure as a similarity measure, or vice versa.
72    * <p>
73    * If parameter <code>maxToZero</code> is true, then the maximum value becomes
74    * zero, i.e. all values are subtracted from the maximum. This is consistent
75    * with converting an identity similarity score to a distance score - the most
76    * similar (identity) corresponds to zero distance. However note that the
77    * operation is not reversible (unless the original minimum value is zero).
78    * For example a range of 10-40 would become 30-0, which would reverse a
79    * second time to 0-30. Also note that a general similarity measure (such as
80    * BLOSUM) may give different 'identity' scores for different sequences, so
81    * they cannot all convert to zero distance.
82    * <p>
83    * If parameter <code>maxToZero</code> is false, then the values are reflected
84    * about the average of {min, max} (effectively swapping min and max). This
85    * operation <em>is</em> reversible.
86    * 
87    * @param maxToZero
88    */
89   void reverseRange(boolean maxToZero);
90
91   /**
92    * Multiply all entries by the given value
93    * 
94    * @param d
95    */
96   void multiply(double d);
97 }