From: gmungoc Date: Thu, 26 Jan 2017 09:47:42 +0000 (+0000) Subject: Merge branch 'develop' into features/JAL-2379pcaMemory X-Git-Tag: Release_2_10_3b1~343^2~10 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0ce9577d119e1cc646f4b0d2e961f698d994fcc5;p=jalview.git Merge branch 'develop' into features/JAL-2379pcaMemory Conflicts: src/jalview/analysis/PCA.java src/jalview/math/Matrix.java test/jalview/math/MatrixTest.java --- 0ce9577d119e1cc646f4b0d2e961f698d994fcc5 diff --cc src/jalview/analysis/PCA.java index 9fc6027,eaea7bf..7d6b822 --- a/src/jalview/analysis/PCA.java +++ b/src/jalview/analysis/PCA.java @@@ -151,10 -152,10 +151,10 @@@ public class PCA implements Runnabl /** * Returns the matrix used in PCA calculation * -- * @return java.math.Matrix object ++ * @return */ - public Matrix getM() + public MatrixI getM() { return m; } diff --cc src/jalview/math/Matrix.java index 2b2314b,647fc3a..ee74b9b --- a/src/jalview/math/Matrix.java +++ b/src/jalview/math/Matrix.java @@@ -26,17 -26,14 +26,14 @@@ import jalview.util.MessageManager import java.io.PrintStream; /** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision$ + * A class to model rectangular matrices of double values and operations on them */ -public class Matrix +public class Matrix implements MatrixI { /* - * the [row][column] values in the matrix + * the cell values in row-major order */ - public double[][] value; + private double[][] value; /* * the number of rows @@@ -46,13 -43,13 +43,11 @@@ /* * the number of columns */ - public int cols; + protected int cols; -- /** DOCUMENT ME!! */ - public double[] d; // Diagonal + protected double[] d; // Diagonal -- /** DOCUMENT ME!! */ - public double[] e; // off diagonal + protected double[] e; // off diagonal /** * maximum number of iterations for tqli @@@ -372,7 -345,7 +364,7 @@@ for (k = 1; k <= l; k++) { - double x = addValue(k - 1, j - 1, -(g * getValue(k - 1, i - 1))); - value[k - 1][j - 1] -= (g * value[k - 1][i - 1]); ++ addValue(k - 1, j - 1, -(g * getValue(k - 1, i - 1))); } } } diff --cc test/jalview/math/MatrixTest.java index bd5614f,a4acbd0..961602d --- a/test/jalview/math/MatrixTest.java +++ b/test/jalview/math/MatrixTest.java @@@ -163,12 -150,32 +164,32 @@@ public class MatrixTes * and check premultiply equivalent */ m3 = m2.preMultiply(m1); - assertEquals(m3.rows, 1); - assertEquals(m3.cols, 2); - assertEquals(m3.value[0][0], 56d); - assertEquals(m3.value[0][1], 25d); + assertEquals(m3.height(), 1); + assertEquals(m3.width(), 2); + assertEquals(m3.getRow(0)[0], 56d); + assertEquals(m3.getRow(0)[1], 25d); } + @Test(groups = "Functional") + public void testCopy() + { + Random r = new Random(); + int rows = 5; + int cols = 11; + double[][] in = new double[rows][cols]; + + for (int i = 0; i < rows; i++) + { + for (int j = 0; j < cols; j++) + { + in[i][j] = r.nextDouble(); + } + } + Matrix m1 = new Matrix(in); - Matrix m2 = m1.copy(); ++ Matrix m2 = (Matrix) m1.copy(); + assertTrue(matrixEquals(m1, m2)); + } + /** * main method extracted from Matrix *