mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdunn...@apache.org
Subject svn commit: r1222514 - /mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java
Date Thu, 22 Dec 2011 23:51:31 GMT
Author: tdunning
Date: Thu Dec 22 23:51:31 2011
New Revision: 1222514

URL: http://svn.apache.org/viewvc?rev=1222514&view=rev
Log:
MAHOUT-792 - Additional test for QR decomposition.

Modified:
    mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java

Modified: mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java
URL: http://svn.apache.org/viewvc/mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java?rev=1222514&r1=1222513&r2=1222514&view=diff
==============================================================================
--- mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java (original)
+++ mahout/trunk/math/src/test/java/org/apache/mahout/math/QRDecompositionTest.java Thu Dec
22 23:51:31 2011
@@ -17,10 +17,27 @@
 
 package org.apache.mahout.math;
 
+import org.apache.mahout.math.function.DoubleDoubleFunction;
 import org.apache.mahout.math.function.Functions;
 import org.junit.Test;
 
 public final class QRDecompositionTest extends MahoutTestCase {
+  @Test
+  public void rank1() {
+    Matrix x = new DenseMatrix(3, 3);
+    x.viewRow(0).assign(new double[]{1, 2, 3});
+    x.viewRow(1).assign(new double[]{2, 4, 6});
+    x.viewRow(2).assign(new double[]{3, 6, 9});
+
+    QRDecomposition qr = new QRDecomposition(x);
+    assertFalse(qr.hasFullRank());
+    assertEquals(0, new DenseVector(new double[]{3.741657, 7.483315, 11.22497}).aggregate(qr.getR().viewRow(0),
Functions.PLUS, new DoubleDoubleFunction() {
+      @Override
+      public double apply(double arg1, double arg2) {
+        return Math.abs(arg1) - Math.abs(arg2);
+      }
+    }), 1e-5);
+  }
 
   @Test
   public void fullRankTall() {



Mime
View raw message