@@ -0,0 +1,2096 @@
+/*%0A * This file is part of ELKI:%0A * Environment for Developing KDD-Applications Supported by Index-Structures%0A * %0A * Copyright (C) 2017%0A * ELKI Development Team%0A * %0A * This program is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A * %0A * This program is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the%0A * GNU Affero General Public License for more details.%0A * %0A * You should have received a copy of the GNU Affero General Public License%0A * along with this program. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage de.lmu.ifi.dbs.elki.math.linearalgebra;%0A%0Aimport static org.junit.Assert.*;%0A%0Aimport org.junit.Test;%0A%0Aimport static de.lmu.ifi.dbs.elki.math.linearalgebra.VMath.*;%0A%0A/**%0A * Simple unit test for singular value decomposition.%0A *%0A * Copied from Jama, please contribute a more complex test example!%0A *%0A * @author Erich Schubert%0A */%0Apublic class SingularValueDecompositionTest %7B%0A  @Test%0A  public void testJamaExample() %7B%0A    double%5B%5D%5B%5D A = new double%5B%5D%5B%5D %7B %7B 1., 2., 3., 4. %7D, %7B 5., 6., 7., 8. %7D, %7B 9., 10., 11., 12. %7D %7D;%0A    double%5B%5D%5B%5D M = transpose(A);%0A    SingularValueDecomposition svd = new SingularValueDecomposition(M);%0A    // M = U * S * V%5ET%0A    double%5B%5D%5B%5D M2 = times(svd.getU(), timesTranspose(svd.getS(), svd.getV()));%0A    assertTrue(%22Not a proper decomposition.%22, almostEquals(M, M2, 1e-14));%0A  %7D%0A%0A  @Test%0A  public void testJamaCond() %7B%0A    double%5B%5D%5B%5D condmat = %7B %7B 1., 3. %7D, %7B 7., 9. %7D %7D;%0A    SingularValueDecomposition svd = new SingularValueDecomposition(condmat);%0A    double%5B%5D singularvalues = svd.getSingularValues();%0A    double cond = svd.cond();%0A    double check = singularvalues%5B0%5D / singularvalues%5BMath.min(getRowDimensionality(condmat), getColumnDimensionality(condmat)) - 1%5D;%0A    assertEquals(%22Matrix condition.%22, cond, check, 0.);%0A  %7D%0A%7D%0A

Add a simple unit test for SVD.