Merge branch 'develop' into features/JAL-2379pcaMemory
[jalview.git] / test / jalview / math / MatrixTest.java
index bd5614f..961602d 100644 (file)
@@ -1,6 +1,7 @@
 package jalview.math;
 
 import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.fail;
 
 import java.util.Arrays;
@@ -32,8 +33,8 @@ public class MatrixTest
   @Test(groups = "Functional")
   public void testPreMultiply()
   {
-    MatrixI m1 = new Matrix(new double[][] { { 2, 3, 4 } }); // 1x3
-    MatrixI m2 = new Matrix(new double[][] { { 5 }, { 6 }, { 7 } }); // 3x1
+    Matrix m1 = new Matrix(new double[][] { { 2, 3, 4 } }); // 1x3
+    Matrix m2 = new Matrix(new double[][] { { 5 }, { 6 }, { 7 } }); // 3x1
 
     /*
      * 1x3 times 3x1 is 1x1
@@ -169,6 +170,26 @@ public class MatrixTest
     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 = (Matrix) m1.copy();
+    assertTrue(matrixEquals(m1, m2));
+  }
+
   /**
    * main method extracted from Matrix
    *