X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fmath%2FMatrix.java;h=647fc3ad082db043ca3b4d24112a1dfc0c3c8bd1;hb=05d2ce87440717d47ba3dc6ef293e25e4543fdd1;hp=28b9d67e443d04c54adb458465da55540266d837;hpb=8b844f70b97629d597be49cb6ac0d83c8da007c9;p=jalview.git diff --git a/src/jalview/math/Matrix.java b/src/jalview/math/Matrix.java index 28b9d67..647fc3a 100755 --- a/src/jalview/math/Matrix.java +++ b/src/jalview/math/Matrix.java @@ -26,22 +26,23 @@ 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 { - /** - * SMJSPUBLIC + /* + * the cell values in row-major order */ public double[][] value; - /** DOCUMENT ME!! */ + /* + * the number of rows + */ public int rows; - /** DOCUMENT ME!! */ + /* + * the number of columns + */ public int cols; /** DOCUMENT ME!! */ @@ -60,10 +61,10 @@ public class Matrix * Creates a new Matrix object. For example * *
-   *   new Matrix(new double[][] {{2, 3}, {4, 5}, 2, 2)
+   *   new Matrix(new double[][] {{2, 3, 4}, {5, 6, 7})
    * constructs
-   *   (2 3)
-   *   (4 5)
+   *   (2 3 4)
+   *   (5 6 7)
    * 
* * Note that ragged arrays (with not all rows, or columns, of the same @@ -72,13 +73,11 @@ public class Matrix * * @param values * the matrix values in row-major order - * @param rows - * @param cols */ - public Matrix(double[][] values, int rows, int cols) + public Matrix(double[][] values) { - this.rows = rows; - this.cols = cols; + this.rows = values.length; + this.cols = this.rows == 0 ? 0 : values[0].length; this.value = values; } @@ -99,7 +98,7 @@ public class Matrix } } - return new Matrix(out, cols, rows); + return new Matrix(out); } /** @@ -155,7 +154,7 @@ public class Matrix } } - return new Matrix(tmp, in.rows, this.cols); + return new Matrix(tmp); } /** @@ -218,13 +217,9 @@ public class Matrix for (int i = 0; i < rows; i++) { System.arraycopy(value[i], 0, newmat[i], 0, value[i].length); - // for (int j = 0; j < cols; j++) - // { - // newmat[i][j] = value[i][j]; - // } } - return new Matrix(newmat, rows, cols); + return new Matrix(newmat); } /**