EigenvalueDecomposition { static boolean isSymmetric(final double[][] a) { final int len = a.length; if (len == 0) { return true; } if (a[0].length != len) { return false; } for (int j = 1; j < len; j++) { if (a[j].length != len) { return false; } for (int i = 0; i < j; i++) { if (a[i][j] != a[j][i]) { return false; } } } return true; } EigenvalueDecomposition(final Matrix matrix); Matrix getD(); double[] getImagEigenvalues(); double[] getRealEigenvalues(); Matrix getV();  }
@Test public void testIsSymmetric() { assertTrue( "An empty matrix should be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { })); assertFalse( "An matrix with a row but no values should not be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { } })); assertTrue( "A singleton matrix should be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 0 } })); assertFalse( "A malformed matrix should not be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 0, 1 } })); assertTrue( "This simple matrix should be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 0, 1 }, { 1, 0 }, })); assertFalse( "This simple matrix should not be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 0, 1 }, { 2, 0 }, })); assertTrue( "This matrix should be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 0, 1, 3, 8 }, { 1, 5, 7, 1 }, { 3, 7, 9, 0 }, { 8, 1, 0, 6 }, })); assertFalse( "This matrix should not be symmetric", EigenvalueDecomposition.isSymmetric(new double[][] { { 8, 1, 0, 6 }, { 3, 7, 9, 0 }, { 1, 5, 7, 1 }, { 0, 1, 3, 8 }, })); }