You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by ra...@apache.org on 2018/06/29 16:10:46 UTC
[02/18] mahout git commit: MAHOUT-2033 Fixed Map-Reduce Refactor
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/CholeskyDecompositionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/CholeskyDecompositionTest.java b/core/src/test/java/org/apache/mahout/math/CholeskyDecompositionTest.java
index d648a1e..e5c23af 100644
--- a/core/src/test/java/org/apache/mahout/math/CholeskyDecompositionTest.java
+++ b/core/src/test/java/org/apache/mahout/math/CholeskyDecompositionTest.java
@@ -1,152 +1,152 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one or more
-// * contributor license agreements. See the NOTICE file distributed with
-// * this work for additional information regarding copyright ownership.
-// * The ASF licenses this file to You under the Apache License, Version 2.0
-// * (the "License"); you may not use this file except in compliance with
-// * the License. You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-// */
-//
-//package org.apache.mahout.math;
-//
-//import org.apache.mahout.common.RandomUtils;
-//import org.apache.mahout.math.function.DoubleDoubleFunction;
-//import org.apache.mahout.math.function.DoubleFunction;
-//import org.apache.mahout.math.function.Functions;
-//import org.junit.Assert;
-//import org.junit.Test;
-//
-//import java.util.Random;
-//
-//public class CholeskyDecompositionTest 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});
-//
-// CholeskyDecomposition rr = new CholeskyDecomposition(x.transpose().times(x), false);
-// assertEquals(0, new DenseVector(new double[]{3.741657, 7.483315, 11.22497}).aggregate(rr.getL().transpose().viewRow(0), Functions.PLUS, new DoubleDoubleFunction() {
-// @Override
-// public double apply(double arg1, double arg2) {
-// return Math.abs(arg1) - Math.abs(arg2);
-// }
-// }), 1.0e-5);
-//
-// assertEquals(0, rr.getL().viewPart(0, 3, 1, 2).aggregate(Functions.PLUS, Functions.ABS), 1.0e-9);
-// }
-//
-// @Test
-// public void test1() {
-//
-// final Random rand = RandomUtils.getRandom();
-//
-// Matrix z = new DenseMatrix(100, 100);
-// z.assign(new DoubleFunction() {
-// @Override
-// public double apply(double arg1) {
-// return rand.nextDouble();
-// }
-// });
-//
-// Matrix A = z.times(z.transpose());
-//
-// for (boolean type = false; !type; type=true) {
-// CholeskyDecomposition cd = new CholeskyDecomposition(A, type);
-// Matrix L = cd.getL();
-//// Assert.assertTrue("Positive definite", cd.isPositiveDefinite());
-//
-// Matrix Abar = L.times(L.transpose());
-//
-// double error = A.minus(Abar).aggregate(Functions.MAX, Functions.ABS);
-// Assert.assertEquals("type = " + type, 0, error, 1.0e-10);
-//
-// // L should give us a quick and dirty LQ decomposition
-// Matrix q = cd.solveLeft(z);
-// Matrix id = q.times(q.transpose());
-// for (int i = 0; i < id.columnSize(); i++) {
-// Assert.assertEquals("type = " + type, 1, id.get(i, i), 1.0e-9);
-// Assert.assertEquals("type = " + type, 1, id.viewRow(i).norm(1), 1.0e-9);
-// }
-//
-// // and QR as well
-// q = cd.solveRight(z.transpose());
-// id = q.transpose().times(q);
-// for (int i = 0; i < id.columnSize(); i++) {
-// Assert.assertEquals("type = " + type, 1, id.get(i, i), 1.0e-9);
-// Assert.assertEquals("type = " + type, 1, id.viewRow(i).norm(1), 1.0e-9);
-// }
-// }
-// }
-//
-// @Test
-// public void test2() {
-// // Test matrix from Nicholas Higham's paper at http://eprints.ma.man.ac.uk/1199/01/covered/MIMS_ep2008_116.pdf
-// double[][] values = new double[3][];
-// values[0] = new double[]{1, -1, 1};
-// values[1] = new double[]{-1, 1, -1};
-// values[2] = new double[]{1, -1, 2};
-//
-// Matrix A = new DenseMatrix(values);
-//
-// // without pivoting
-// CholeskyDecomposition cd = new CholeskyDecomposition(A, false);
-// assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-//
-// // with pivoting
-// cd = new CholeskyDecomposition(A);
-// assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-// }
-//
-//
-// @Test
-// public void testRankDeficient() {
-// Matrix A = rank4Matrix();
-//
-// CholeskyDecomposition cd = new CholeskyDecomposition(A);
-//
-// PivotedMatrix Ax = new PivotedMatrix(A, cd.getPivot());
-// CholeskyDecomposition cd2 = new CholeskyDecomposition(Ax, false);
-//
-// assertEquals(0, cd2.getL().times(cd2.getL().transpose()).minus(Ax).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-// assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-//
-// Assert.assertFalse(cd.isPositiveDefinite());
-// Matrix L = cd.getL();
-// Matrix Abar = L.times(L.transpose());
-// double error = A.minus(Abar).aggregate(Functions.MAX, Functions.ABS);
-// Assert.assertEquals(0, error, 1.0e-10);
-// }
-//
-// private static Matrix rank4Matrix() {
-// final Random rand = RandomUtils.getRandom();
-//
-// Matrix u = new DenseMatrix(10, 4);
-// u.assign(new DoubleFunction() {
-// @Override
-// public double apply(double arg1) {
-// return rand.nextDouble();
-// }
-// });
-//
-// Matrix v = new DenseMatrix(10, 4);
-// v.assign(new DoubleFunction() {
-// @Override
-// public double apply(double arg1) {
-// return rand.nextDouble();
-// }
-// });
-//
-// Matrix z = u.times(v.transpose());
-// return z.times(z.transpose());
-// }
-//}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.mahout.math;
+
+import org.apache.mahout.common.RandomUtils;
+import org.apache.mahout.math.function.DoubleDoubleFunction;
+import org.apache.mahout.math.function.DoubleFunction;
+import org.apache.mahout.math.function.Functions;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Random;
+
+public class CholeskyDecompositionTest 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});
+
+ CholeskyDecomposition rr = new CholeskyDecomposition(x.transpose().times(x), false);
+ assertEquals(0, new DenseVector(new double[]{3.741657, 7.483315, 11.22497}).aggregate(rr.getL().transpose().viewRow(0), Functions.PLUS, new DoubleDoubleFunction() {
+ @Override
+ public double apply(double arg1, double arg2) {
+ return Math.abs(arg1) - Math.abs(arg2);
+ }
+ }), 1.0e-5);
+
+ assertEquals(0, rr.getL().viewPart(0, 3, 1, 2).aggregate(Functions.PLUS, Functions.ABS), 1.0e-9);
+ }
+
+ @Test
+ public void test1() {
+
+ final Random rand = RandomUtils.getRandom();
+
+ Matrix z = new DenseMatrix(100, 100);
+ z.assign(new DoubleFunction() {
+ @Override
+ public double apply(double arg1) {
+ return rand.nextDouble();
+ }
+ });
+
+ Matrix A = z.times(z.transpose());
+
+ for (boolean type = false; !type; type=true) {
+ CholeskyDecomposition cd = new CholeskyDecomposition(A, type);
+ Matrix L = cd.getL();
+// Assert.assertTrue("Positive definite", cd.isPositiveDefinite());
+
+ Matrix Abar = L.times(L.transpose());
+
+ double error = A.minus(Abar).aggregate(Functions.MAX, Functions.ABS);
+ Assert.assertEquals("type = " + type, 0, error, 1.0e-10);
+
+ // L should give us a quick and dirty LQ decomposition
+ Matrix q = cd.solveLeft(z);
+ Matrix id = q.times(q.transpose());
+ for (int i = 0; i < id.columnSize(); i++) {
+ Assert.assertEquals("type = " + type, 1, id.get(i, i), 1.0e-9);
+ Assert.assertEquals("type = " + type, 1, id.viewRow(i).norm(1), 1.0e-9);
+ }
+
+ // and QR as well
+ q = cd.solveRight(z.transpose());
+ id = q.transpose().times(q);
+ for (int i = 0; i < id.columnSize(); i++) {
+ Assert.assertEquals("type = " + type, 1, id.get(i, i), 1.0e-9);
+ Assert.assertEquals("type = " + type, 1, id.viewRow(i).norm(1), 1.0e-9);
+ }
+ }
+ }
+
+ @Test
+ public void test2() {
+ // Test matrix from Nicholas Higham's paper at http://eprints.ma.man.ac.uk/1199/01/covered/MIMS_ep2008_116.pdf
+ double[][] values = new double[3][];
+ values[0] = new double[]{1, -1, 1};
+ values[1] = new double[]{-1, 1, -1};
+ values[2] = new double[]{1, -1, 2};
+
+ Matrix A = new DenseMatrix(values);
+
+ // without pivoting
+ CholeskyDecomposition cd = new CholeskyDecomposition(A, false);
+ assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+
+ // with pivoting
+ cd = new CholeskyDecomposition(A);
+ assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+ }
+
+
+ @Test
+ public void testRankDeficient() {
+ Matrix A = rank4Matrix();
+
+ CholeskyDecomposition cd = new CholeskyDecomposition(A);
+
+ PivotedMatrix Ax = new PivotedMatrix(A, cd.getPivot());
+ CholeskyDecomposition cd2 = new CholeskyDecomposition(Ax, false);
+
+ assertEquals(0, cd2.getL().times(cd2.getL().transpose()).minus(Ax).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+ assertEquals(0, cd.getL().times(cd.getL().transpose()).minus(A).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+
+ Assert.assertFalse(cd.isPositiveDefinite());
+ Matrix L = cd.getL();
+ Matrix Abar = L.times(L.transpose());
+ double error = A.minus(Abar).aggregate(Functions.MAX, Functions.ABS);
+ Assert.assertEquals(0, error, 1.0e-10);
+ }
+
+ private static Matrix rank4Matrix() {
+ final Random rand = RandomUtils.getRandom();
+
+ Matrix u = new DenseMatrix(10, 4);
+ u.assign(new DoubleFunction() {
+ @Override
+ public double apply(double arg1) {
+ return rand.nextDouble();
+ }
+ });
+
+ Matrix v = new DenseMatrix(10, 4);
+ v.assign(new DoubleFunction() {
+ @Override
+ public double apply(double arg1) {
+ return rand.nextDouble();
+ }
+ });
+
+ Matrix z = u.times(v.transpose());
+ return z.times(z.transpose());
+ }
+}
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/DenseSymmetricTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/DenseSymmetricTest.java b/core/src/test/java/org/apache/mahout/math/DenseSymmetricTest.java
index b987f0e..189bf55 100644
--- a/core/src/test/java/org/apache/mahout/math/DenseSymmetricTest.java
+++ b/core/src/test/java/org/apache/mahout/math/DenseSymmetricTest.java
@@ -18,11 +18,9 @@
package org.apache.mahout.math;
import org.apache.mahout.math.function.Functions;
-//import org.apache.mahout.math.solver.EigenDecomposition;
+import org.apache.mahout.math.solver.EigenDecomposition;
import org.junit.Test;
-import static org.junit.Assert.*;
-
public class DenseSymmetricTest extends MahoutTestCase {
@Test
public void testBasics() {
@@ -46,22 +44,22 @@ public class DenseSymmetricTest extends MahoutTestCase {
assertEquals(0, m.plus(m).minus(a.plus(a)).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
}
-// @Test
-// public void testEigen() {
-// Matrix a = new DenseSymmetricMatrix(new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, false);
-// Matrix b = new DenseMatrix(a.numRows(), a.numCols());
-// b.assign(a);
-//
-// assertEquals(0, a.minus(b).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-//
-// EigenDecomposition edA = new EigenDecomposition(a);
-// EigenDecomposition edB = new EigenDecomposition(b);
-//
-// System.out.println(edA.getV());
-//
-// assertEquals(0, edA.getV().minus(edB.getV()).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-// assertEquals(0, edA.getRealEigenvalues().minus(edA.getRealEigenvalues()).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
-//
-// }
+ @Test
+ public void testEigen() {
+ Matrix a = new DenseSymmetricMatrix(new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, false);
+ Matrix b = new DenseMatrix(a.numRows(), a.numCols());
+ b.assign(a);
+
+ assertEquals(0, a.minus(b).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+
+ EigenDecomposition edA = new EigenDecomposition(a);
+ EigenDecomposition edB = new EigenDecomposition(b);
+
+ System.out.println(edA.getV());
+
+ assertEquals(0, edA.getV().minus(edB.getV()).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+ assertEquals(0, edA.getRealEigenvalues().minus(edA.getRealEigenvalues()).aggregate(Functions.PLUS, Functions.ABS), 1.0e-10);
+
+ }
}
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/DiagonalMatrixTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/DiagonalMatrixTest.java b/core/src/test/java/org/apache/mahout/math/DiagonalMatrixTest.java
index e3944f5..2ca7be0 100644
--- a/core/src/test/java/org/apache/mahout/math/DiagonalMatrixTest.java
+++ b/core/src/test/java/org/apache/mahout/math/DiagonalMatrixTest.java
@@ -22,7 +22,6 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.Iterator;
-import static org.junit.Assert.*;
public class DiagonalMatrixTest extends MahoutTestCase {
@Test
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/FileBasedMatrixTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/FileBasedMatrixTest.java b/core/src/test/java/org/apache/mahout/math/FileBasedMatrixTest.java
index aac8668..dbea80c 100644
--- a/core/src/test/java/org/apache/mahout/math/FileBasedMatrixTest.java
+++ b/core/src/test/java/org/apache/mahout/math/FileBasedMatrixTest.java
@@ -19,14 +19,13 @@ package org.apache.mahout.math;
import org.apache.mahout.common.RandomUtils;
import org.apache.mahout.math.function.Functions;
-//import org.apache.mahout.math.random.MultiNormal;
+import org.apache.mahout.math.random.MultiNormal;
import org.junit.Assume;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.Random;
-import static org.junit.Assert.*;
public class FileBasedMatrixTest extends MahoutTestCase {
// 10 million rows x 40 columns x 8 bytes = 3.2GB of data
@@ -65,26 +64,26 @@ public class FileBasedMatrixTest extends MahoutTestCase {
return (i * 88513) % 10000;
}
-// @Test
-// public void testSetData() throws IOException {
-// File f = File.createTempFile("matrix", ".m", getTestTempDir());
-// f.deleteOnExit();
-//
-// Matrix m0 = new DenseMatrix(100000, 30);
-// MultiNormal gen = new MultiNormal(30);
-// for (MatrixSlice row : m0) {
-// row.vector().assign(gen.sample());
-// }
-// FileBasedMatrix.writeMatrix(f, m0);
-//
-// FileBasedMatrix m = new FileBasedMatrix(100000, 30);
-// m.setData(f, true);
-//
-// assertEquals(0, m0.minus(m).aggregate(Functions.MAX, Functions.ABS), 1.0e-8);
-//
-// int i = 0;
-// for (MatrixSlice row : m) {
-// assertEquals(0, row.vector().minus(m0.viewRow(i++)).norm(1), 1.0e-8);
-// }
-// }
+ @Test
+ public void testSetData() throws IOException {
+ File f = File.createTempFile("matrix", ".m", getTestTempDir());
+ f.deleteOnExit();
+
+ Matrix m0 = new DenseMatrix(100000, 30);
+ MultiNormal gen = new MultiNormal(30);
+ for (MatrixSlice row : m0) {
+ row.vector().assign(gen.sample());
+ }
+ FileBasedMatrix.writeMatrix(f, m0);
+
+ FileBasedMatrix m = new FileBasedMatrix(100000, 30);
+ m.setData(f, true);
+
+ assertEquals(0, m0.minus(m).aggregate(Functions.MAX, Functions.ABS), 1.0e-8);
+
+ int i = 0;
+ for (MatrixSlice row : m) {
+ assertEquals(0, row.vector().minus(m0.viewRow(i++)).norm(1), 1.0e-8);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/FileBasedSparseBinaryMatrixTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/FileBasedSparseBinaryMatrixTest.java b/core/src/test/java/org/apache/mahout/math/FileBasedSparseBinaryMatrixTest.java
index 38e6145..67daa32 100644
--- a/core/src/test/java/org/apache/mahout/math/FileBasedSparseBinaryMatrixTest.java
+++ b/core/src/test/java/org/apache/mahout/math/FileBasedSparseBinaryMatrixTest.java
@@ -23,7 +23,6 @@ import java.util.Random;
import org.apache.mahout.common.RandomUtils;
import org.junit.Test;
-import static org.junit.Assert.*;
public class FileBasedSparseBinaryMatrixTest extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MahoutTestCase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MahoutTestCase.java b/core/src/test/java/org/apache/mahout/math/MahoutTestCase.java
index 366e5a9..7909b1c 100644
--- a/core/src/test/java/org/apache/mahout/math/MahoutTestCase.java
+++ b/core/src/test/java/org/apache/mahout/math/MahoutTestCase.java
@@ -20,19 +20,17 @@ package org.apache.mahout.math;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
-//
+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakAction;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakLingering;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakZombies;
import com.carrotsearch.randomizedtesting.annotations.TimeoutSuite;
import org.apache.lucene.util.TimeUnits;
-import junit.framework.TestCase;
import org.apache.mahout.common.RandomUtils;
import org.junit.After;
import org.junit.Before;
-import static org.junit.Assert.*;
import com.carrotsearch.randomizedtesting.RandomizedTest;
/**
@@ -47,7 +45,7 @@ public abstract class MahoutTestCase extends RandomizedTest {
/** "Close enough" value for floating-point comparisons. */
public static final double EPSILON = 0.000001;
-
+
private File testTempDir;
@Before
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MatricesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MatricesTest.java b/core/src/test/java/org/apache/mahout/math/MatricesTest.java
index 2ef3306..9405429 100644
--- a/core/src/test/java/org/apache/mahout/math/MatricesTest.java
+++ b/core/src/test/java/org/apache/mahout/math/MatricesTest.java
@@ -20,7 +20,6 @@ package org.apache.mahout.math;
import org.apache.mahout.math.function.Functions;
import org.apache.mahout.math.function.IntIntFunction;
import org.junit.Test;
-import static org.junit.Assert.*;
public class MatricesTest extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MatrixTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MatrixTest.java b/core/src/test/java/org/apache/mahout/math/MatrixTest.java
index 0de55dd..fe8ace2 100644
--- a/core/src/test/java/org/apache/mahout/math/MatrixTest.java
+++ b/core/src/test/java/org/apache/mahout/math/MatrixTest.java
@@ -28,8 +28,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Random;
-import static org.junit.Assert.*;
-
public abstract class MatrixTest extends MahoutTestCase {
protected static final int ROW = AbstractMatrix.ROW;
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MatrixVectorViewTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MatrixVectorViewTest.java b/core/src/test/java/org/apache/mahout/math/MatrixVectorViewTest.java
index 573eeaf..400df8d 100644
--- a/core/src/test/java/org/apache/mahout/math/MatrixVectorViewTest.java
+++ b/core/src/test/java/org/apache/mahout/math/MatrixVectorViewTest.java
@@ -19,7 +19,6 @@ package org.apache.mahout.math;
import org.apache.mahout.math.function.Functions;
import org.junit.Test;
-import static org.junit.Assert.*;
public class MatrixVectorViewTest extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java b/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java
index ca9eba3..ba9f9c4 100644
--- a/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java
+++ b/core/src/test/java/org/apache/mahout/math/MurmurHash3Test.java
@@ -12,7 +12,6 @@
package org.apache.mahout.math;
import org.junit.Test;
-import static org.junit.Assert.*;
public final class MurmurHash3Test extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/MurmurHashTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/MurmurHashTest.java b/core/src/test/java/org/apache/mahout/math/MurmurHashTest.java
index 4e561e6..e758f8a 100644
--- a/core/src/test/java/org/apache/mahout/math/MurmurHashTest.java
+++ b/core/src/test/java/org/apache/mahout/math/MurmurHashTest.java
@@ -23,7 +23,7 @@ import org.junit.Test;
import java.io.UnsupportedEncodingException;
-public class MurmurHashTest extends MahoutTestCase {
+public class MurmurHashTest extends org.apache.mahout.math.MahoutTestCase {
@Test
public void testForLotsOfChange64() throws UnsupportedEncodingException {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/OldQRDecompositionTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/OldQRDecompositionTest.java b/core/src/test/java/org/apache/mahout/math/OldQRDecompositionTest.java
index b9372e1..95c1f31 100644
--- a/core/src/test/java/org/apache/mahout/math/OldQRDecompositionTest.java
+++ b/core/src/test/java/org/apache/mahout/math/OldQRDecompositionTest.java
@@ -1,187 +1,187 @@
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one or more
-// * contributor license agreements. See the NOTICE file distributed with
-// * this work for additional information regarding copyright ownership.
-// * The ASF licenses this file to You under the Apache License, Version 2.0
-// * (the "License"); you may not use this file except in compliance with
-// * the License. You may obtain a copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software
-// * distributed under the License is distributed on an "AS IS" BASIS,
-// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// * See the License for the specific language governing permissions and
-// * limitations under the License.
-// */
-//
-//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 OldQRDecompositionTest 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});
-//
-// OldQRDecomposition qr = new OldQRDecomposition(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);
-// }
-// }), 1.0e-5);
-// }
-//
-// @Test
-// public void fullRankTall() {
-// Matrix x = matrix();
-// OldQRDecomposition qr = new OldQRDecomposition(x);
-// assertTrue(qr.hasFullRank());
-// Matrix rRef = reshape(new double[]{
-// -2.99129686445138, 0, 0, 0, 0,
-// -0.0282260628674372, -2.38850244769059, 0, 0, 0,
-// 0.733739310355871, 1.48042000631646, 2.29051263117895, 0, 0,
-// -0.0394082168269326, 0.282829484207801, -0.00438521041803086, -2.90823198084203, 0,
-// 0.923669647838536, 1.76679276072492, 0.637690104222683, -0.225890909498753, -1.35732293800944},
-// 5, 5);
-// Matrix r = qr.getR();
-// assertEquals(rRef, r, 1.0e-8);
-//
-// Matrix qRef = reshape(new double[]{
-// -0.165178287646573, 0.0510035857637869, 0.13985915987379, -0.120173729496501,
-// -0.453198314345324, 0.644400679630493, -0.503117990820608, 0.24968739845381,
-// 0.323968339146224, -0.465266080134262, 0.276508948773268, -0.687909700644343,
-// 0.0544048888907195, -0.0166677718378263, 0.171309755790717, 0.310339001630029,
-// 0.674790532821663, 0.0058166082200493, -0.381707516461884, 0.300504956413142,
-// -0.105751091334003, 0.410450870871096, 0.31113446615821, 0.179338172684956,
-// 0.361951807617901, 0.763921725548796, 0.380327892605634, -0.287274944594054,
-// 0.0311604042556675, 0.0386096858143961, 0.0387156960650472, -0.232975755728917,
-// 0.0358178276684149, 0.173105775703199, 0.327321867815603, 0.328671945345279,
-// -0.36015879836344, -0.444261660176044, 0.09438499563253, 0.646216148583769
-// }, 8, 5);
-//
-// printMatrix("qRef", qRef);
-//
-// Matrix q = qr.getQ();
-// printMatrix("q", q);
-//
-// assertEquals(qRef, q, 1.0e-8);
-//
-// Matrix x1 = qr.solve(reshape(new double[]{
-// -0.0178247686747641, 0.68631714634098, -0.335464858468858, 1.50249941751569,
-// -0.669901640772149, -0.977025038942455, -1.18857546169856, -1.24792900492054
-// }, 8, 1));
-// Matrix xref = reshape(new double[]{
-// -0.0127440093664874, 0.655825940180799, -0.100755415991702, -0.0349559562697406,
-// -0.190744297762028
-// }, 5, 1);
-//
-// printMatrix("x1", x1);
-// printMatrix("xref", xref);
-//
-// assertEquals(xref, x1, 1.0e-8);
-// }
-//
-// @Test
-// public void fullRankWide() {
-// Matrix x = matrix().transpose();
-// OldQRDecomposition qr = new OldQRDecomposition(x);
-// assertFalse(qr.hasFullRank());
-// Matrix rActual = qr.getR();
-//
-// Matrix rRef = reshape(new double[]{
-// -2.42812464965842, 0, 0, 0, 0,
-// 0.303587286111356, -2.91663643494775, 0, 0, 0,
-// -0.201812474153156, -0.765485720168378, 1.09989373598954, 0, 0,
-// 1.47980701097885, -0.637545820524326, -1.55519859337935, 0.844655127991726, 0,
-// 0.0248883129453161, 0.00115010570270549, -0.236340588891252, -0.092924118200147, 1.42910099545547,
-// -1.1678472412429, 0.531245845248056, 0.351978196071514, -1.03241474816555, -2.20223861735426,
-// -0.887809959067632, 0.189731251982918, -0.504321849233586, 0.490484123999836, 1.21266692336743,
-// -0.633888169775463, 1.04738559065986, 0.284041239547031, 0.578183510077156, -0.942314870832456
-// }, 5, 8);
-// printMatrix("rRef", rRef);
-// printMatrix("rActual", rActual);
-// assertEquals(rRef, rActual, 1.0e-8);
-//
-// Matrix qRef = reshape(new double[]{
-// -0.203489262374627, 0.316761677948356, -0.784155643293468, 0.394321494579, -0.29641971170211,
-// 0.0311283614803723, -0.34755265020736, 0.137138511478328, 0.848579887681972, 0.373287266507375,
-// -0.39603700561249, -0.787812566647329, -0.377864833067864, -0.275080943427399, 0.0636764674878229,
-// 0.0763976893309043, -0.318551137554327, 0.286407036668598, 0.206004127289883, -0.876482672226889,
-// 0.89159476695423, -0.238213616975551, -0.376141107880836, -0.0794701657055114, 0.0227025098210165
-// }, 5, 5);
-//
-// Matrix q = qr.getQ();
-//
-// printMatrix("qRef", qRef);
-// printMatrix("q", q);
-//
-// assertEquals(qRef, q, 1.0e-8);
-//
-// Matrix x1 = qr.solve(b());
-// Matrix xRef = reshape(new double[]{
-// -0.182580239668147, -0.437233627652114, 0.138787653097464, 0.672934739896228, -0.131420217069083, 0, 0, 0
-// }, 8, 1);
-//
-// printMatrix("xRef", xRef);
-// printMatrix("x", x1);
-// assertEquals(xRef, x1, 1.0e-8);
-// }
-//
-// private static void assertEquals(Matrix ref, Matrix actual, double epsilon) {
-// assertEquals(0, ref.minus(actual).aggregate(Functions.MAX, Functions.ABS), epsilon);
-// }
-//
-// private static void printMatrix(String name, Matrix m) {
-// int rows = m.numRows();
-// int columns = m.numCols();
-// System.out.printf("%s - %d x %d\n", name, rows, columns);
-// for (int i = 0; i < rows; i++) {
-// for (int j = 0; j < columns; j++) {
-// System.out.printf("%10.5f", m.get(i, j));
-// }
-// System.out.printf("\n");
-// }
-// System.out.printf("\n");
-// System.out.printf("\n");
-// }
-//
-// private static Matrix matrix() {
-// double[] values = {
-// 0.494097293912641, -0.152566866170993, -0.418360266395271, 0.359475300232312,
-// 1.35565069667582, -1.92759373242903, 1.50497526839076, -0.746889132087904,
-// -0.769136838293565, 1.10984954080986, -0.664389974392489, 1.6464660350229,
-// -0.11715420616969, 0.0216221197371269, -0.394972730980765, -0.748293157213142,
-// 1.90402764664962, -0.638042862848559, -0.362336344669668, -0.418261074380526,
-// -0.494211543128429, 1.38828971158414, 0.597110366867923, 1.05341387608687,
-// -0.957461740877418, -2.35528802598249, -1.03171458944128, 0.644319090271635,
-// -0.0569108993041965, -0.14419465550881, -0.0456801828174936,
-// 0.754694392571835, 0.719744008628535, -1.17873249802301, -0.155887528905918,
-// -1.5159868405466, 0.0918931582603128, 1.42179027361583, -0.100495054250176,
-// 0.0687986548485584
-// };
-// return reshape(values, 8, 5);
-// }
-//
-// private static Matrix reshape(double[] values, int rows, int columns) {
-// Matrix m = new DenseMatrix(rows, columns);
-// int i = 0;
-// for (double v : values) {
-// m.set(i % rows, i / rows, v);
-// i++;
-// }
-// return m;
-// }
-//
-// private static Matrix b() {
-// return reshape(new double[]
-// {-0.0178247686747641, 0.68631714634098, -0.335464858468858, 1.50249941751569, -0.669901640772149}, 5, 1);
-// }
-//}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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 OldQRDecompositionTest 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});
+
+ OldQRDecomposition qr = new OldQRDecomposition(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);
+ }
+ }), 1.0e-5);
+ }
+
+ @Test
+ public void fullRankTall() {
+ Matrix x = matrix();
+ OldQRDecomposition qr = new OldQRDecomposition(x);
+ assertTrue(qr.hasFullRank());
+ Matrix rRef = reshape(new double[]{
+ -2.99129686445138, 0, 0, 0, 0,
+ -0.0282260628674372, -2.38850244769059, 0, 0, 0,
+ 0.733739310355871, 1.48042000631646, 2.29051263117895, 0, 0,
+ -0.0394082168269326, 0.282829484207801, -0.00438521041803086, -2.90823198084203, 0,
+ 0.923669647838536, 1.76679276072492, 0.637690104222683, -0.225890909498753, -1.35732293800944},
+ 5, 5);
+ Matrix r = qr.getR();
+ assertEquals(rRef, r, 1.0e-8);
+
+ Matrix qRef = reshape(new double[]{
+ -0.165178287646573, 0.0510035857637869, 0.13985915987379, -0.120173729496501,
+ -0.453198314345324, 0.644400679630493, -0.503117990820608, 0.24968739845381,
+ 0.323968339146224, -0.465266080134262, 0.276508948773268, -0.687909700644343,
+ 0.0544048888907195, -0.0166677718378263, 0.171309755790717, 0.310339001630029,
+ 0.674790532821663, 0.0058166082200493, -0.381707516461884, 0.300504956413142,
+ -0.105751091334003, 0.410450870871096, 0.31113446615821, 0.179338172684956,
+ 0.361951807617901, 0.763921725548796, 0.380327892605634, -0.287274944594054,
+ 0.0311604042556675, 0.0386096858143961, 0.0387156960650472, -0.232975755728917,
+ 0.0358178276684149, 0.173105775703199, 0.327321867815603, 0.328671945345279,
+ -0.36015879836344, -0.444261660176044, 0.09438499563253, 0.646216148583769
+ }, 8, 5);
+
+ printMatrix("qRef", qRef);
+
+ Matrix q = qr.getQ();
+ printMatrix("q", q);
+
+ assertEquals(qRef, q, 1.0e-8);
+
+ Matrix x1 = qr.solve(reshape(new double[]{
+ -0.0178247686747641, 0.68631714634098, -0.335464858468858, 1.50249941751569,
+ -0.669901640772149, -0.977025038942455, -1.18857546169856, -1.24792900492054
+ }, 8, 1));
+ Matrix xref = reshape(new double[]{
+ -0.0127440093664874, 0.655825940180799, -0.100755415991702, -0.0349559562697406,
+ -0.190744297762028
+ }, 5, 1);
+
+ printMatrix("x1", x1);
+ printMatrix("xref", xref);
+
+ assertEquals(xref, x1, 1.0e-8);
+ }
+
+ @Test
+ public void fullRankWide() {
+ Matrix x = matrix().transpose();
+ OldQRDecomposition qr = new OldQRDecomposition(x);
+ assertFalse(qr.hasFullRank());
+ Matrix rActual = qr.getR();
+
+ Matrix rRef = reshape(new double[]{
+ -2.42812464965842, 0, 0, 0, 0,
+ 0.303587286111356, -2.91663643494775, 0, 0, 0,
+ -0.201812474153156, -0.765485720168378, 1.09989373598954, 0, 0,
+ 1.47980701097885, -0.637545820524326, -1.55519859337935, 0.844655127991726, 0,
+ 0.0248883129453161, 0.00115010570270549, -0.236340588891252, -0.092924118200147, 1.42910099545547,
+ -1.1678472412429, 0.531245845248056, 0.351978196071514, -1.03241474816555, -2.20223861735426,
+ -0.887809959067632, 0.189731251982918, -0.504321849233586, 0.490484123999836, 1.21266692336743,
+ -0.633888169775463, 1.04738559065986, 0.284041239547031, 0.578183510077156, -0.942314870832456
+ }, 5, 8);
+ printMatrix("rRef", rRef);
+ printMatrix("rActual", rActual);
+ assertEquals(rRef, rActual, 1.0e-8);
+
+ Matrix qRef = reshape(new double[]{
+ -0.203489262374627, 0.316761677948356, -0.784155643293468, 0.394321494579, -0.29641971170211,
+ 0.0311283614803723, -0.34755265020736, 0.137138511478328, 0.848579887681972, 0.373287266507375,
+ -0.39603700561249, -0.787812566647329, -0.377864833067864, -0.275080943427399, 0.0636764674878229,
+ 0.0763976893309043, -0.318551137554327, 0.286407036668598, 0.206004127289883, -0.876482672226889,
+ 0.89159476695423, -0.238213616975551, -0.376141107880836, -0.0794701657055114, 0.0227025098210165
+ }, 5, 5);
+
+ Matrix q = qr.getQ();
+
+ printMatrix("qRef", qRef);
+ printMatrix("q", q);
+
+ assertEquals(qRef, q, 1.0e-8);
+
+ Matrix x1 = qr.solve(b());
+ Matrix xRef = reshape(new double[]{
+ -0.182580239668147, -0.437233627652114, 0.138787653097464, 0.672934739896228, -0.131420217069083, 0, 0, 0
+ }, 8, 1);
+
+ printMatrix("xRef", xRef);
+ printMatrix("x", x1);
+ assertEquals(xRef, x1, 1.0e-8);
+ }
+
+ private static void assertEquals(Matrix ref, Matrix actual, double epsilon) {
+ assertEquals(0, ref.minus(actual).aggregate(Functions.MAX, Functions.ABS), epsilon);
+ }
+
+ private static void printMatrix(String name, Matrix m) {
+ int rows = m.numRows();
+ int columns = m.numCols();
+ System.out.printf("%s - %d x %d\n", name, rows, columns);
+ for (int i = 0; i < rows; i++) {
+ for (int j = 0; j < columns; j++) {
+ System.out.printf("%10.5f", m.get(i, j));
+ }
+ System.out.printf("\n");
+ }
+ System.out.printf("\n");
+ System.out.printf("\n");
+ }
+
+ private static Matrix matrix() {
+ double[] values = {
+ 0.494097293912641, -0.152566866170993, -0.418360266395271, 0.359475300232312,
+ 1.35565069667582, -1.92759373242903, 1.50497526839076, -0.746889132087904,
+ -0.769136838293565, 1.10984954080986, -0.664389974392489, 1.6464660350229,
+ -0.11715420616969, 0.0216221197371269, -0.394972730980765, -0.748293157213142,
+ 1.90402764664962, -0.638042862848559, -0.362336344669668, -0.418261074380526,
+ -0.494211543128429, 1.38828971158414, 0.597110366867923, 1.05341387608687,
+ -0.957461740877418, -2.35528802598249, -1.03171458944128, 0.644319090271635,
+ -0.0569108993041965, -0.14419465550881, -0.0456801828174936,
+ 0.754694392571835, 0.719744008628535, -1.17873249802301, -0.155887528905918,
+ -1.5159868405466, 0.0918931582603128, 1.42179027361583, -0.100495054250176,
+ 0.0687986548485584
+ };
+ return reshape(values, 8, 5);
+ }
+
+ private static Matrix reshape(double[] values, int rows, int columns) {
+ Matrix m = new DenseMatrix(rows, columns);
+ int i = 0;
+ for (double v : values) {
+ m.set(i % rows, i / rows, v);
+ i++;
+ }
+ return m;
+ }
+
+ private static Matrix b() {
+ return reshape(new double[]
+ {-0.0178247686747641, 0.68631714634098, -0.335464858468858, 1.50249941751569, -0.669901640772149}, 5, 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/PermutedVectorViewTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/PermutedVectorViewTest.java b/core/src/test/java/org/apache/mahout/math/PermutedVectorViewTest.java
index b8cc4f6..79754ee 100644
--- a/core/src/test/java/org/apache/mahout/math/PermutedVectorViewTest.java
+++ b/core/src/test/java/org/apache/mahout/math/PermutedVectorViewTest.java
@@ -24,8 +24,6 @@ import org.junit.Test;
import java.util.Iterator;
import java.util.Random;
-import static org.junit.Assert.*;
-
public class PermutedVectorViewTest extends MahoutTestCase {
@Test
public void testViewBasics() {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/PivotedMatrixTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/PivotedMatrixTest.java b/core/src/test/java/org/apache/mahout/math/PivotedMatrixTest.java
index 9bbf09d..16cb3e7 100644
--- a/core/src/test/java/org/apache/mahout/math/PivotedMatrixTest.java
+++ b/core/src/test/java/org/apache/mahout/math/PivotedMatrixTest.java
@@ -18,7 +18,6 @@
package org.apache.mahout.math;
import org.junit.Test;
-import static org.junit.Assert.*;
public class PivotedMatrixTest extends MatrixTest {
@Override
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestDenseVector.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestDenseVector.java b/core/src/test/java/org/apache/mahout/math/TestDenseVector.java
index fbc053c..dfbfeab 100644
--- a/core/src/test/java/org/apache/mahout/math/TestDenseVector.java
+++ b/core/src/test/java/org/apache/mahout/math/TestDenseVector.java
@@ -19,7 +19,6 @@ package org.apache.mahout.math;
import org.apache.mahout.math.function.Functions;
import org.junit.Test;
-import static org.junit.Assert.*;
public final class TestDenseVector extends AbstractVectorTest<DenseVector> {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestMatrixView.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestMatrixView.java b/core/src/test/java/org/apache/mahout/math/TestMatrixView.java
index d401074..074df22 100644
--- a/core/src/test/java/org/apache/mahout/math/TestMatrixView.java
+++ b/core/src/test/java/org/apache/mahout/math/TestMatrixView.java
@@ -23,7 +23,6 @@ import org.junit.Before;
import org.junit.Test;
import java.util.Map;
-import static org.junit.Assert.*;
public final class TestMatrixView extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestOrderedIntDoubleMapping.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestOrderedIntDoubleMapping.java b/core/src/test/java/org/apache/mahout/math/TestOrderedIntDoubleMapping.java
index 26ceb1c..f78d604 100644
--- a/core/src/test/java/org/apache/mahout/math/TestOrderedIntDoubleMapping.java
+++ b/core/src/test/java/org/apache/mahout/math/TestOrderedIntDoubleMapping.java
@@ -18,7 +18,6 @@
package org.apache.mahout.math;
import org.junit.Test;
-import static org.junit.Assert.*;
public final class TestOrderedIntDoubleMapping extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestRandomAccessSparseVector.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestRandomAccessSparseVector.java b/core/src/test/java/org/apache/mahout/math/TestRandomAccessSparseVector.java
index e7f30c2..ecc005d 100644
--- a/core/src/test/java/org/apache/mahout/math/TestRandomAccessSparseVector.java
+++ b/core/src/test/java/org/apache/mahout/math/TestRandomAccessSparseVector.java
@@ -22,7 +22,6 @@ import org.apache.mahout.common.RandomUtils;
import org.junit.Test;
import java.util.Random;
-import static org.junit.Assert.*;
public final class TestRandomAccessSparseVector extends AbstractVectorTest<RandomAccessSparseVector> {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestSequentialAccessSparseVector.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestSequentialAccessSparseVector.java b/core/src/test/java/org/apache/mahout/math/TestSequentialAccessSparseVector.java
index e44f615..a36ed34 100644
--- a/core/src/test/java/org/apache/mahout/math/TestSequentialAccessSparseVector.java
+++ b/core/src/test/java/org/apache/mahout/math/TestSequentialAccessSparseVector.java
@@ -21,7 +21,6 @@ import org.apache.mahout.common.RandomUtils;
import org.junit.Test;
import java.util.Random;
-import static org.junit.Assert.*;
public final class TestSequentialAccessSparseVector extends AbstractVectorTest<SequentialAccessSparseVector> {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestSparseMatrix.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestSparseMatrix.java b/core/src/test/java/org/apache/mahout/math/TestSparseMatrix.java
index 34d76e9..2ebed3f 100644
--- a/core/src/test/java/org/apache/mahout/math/TestSparseMatrix.java
+++ b/core/src/test/java/org/apache/mahout/math/TestSparseMatrix.java
@@ -21,7 +21,6 @@ import java.util.Iterator;
import org.apache.mahout.math.function.Functions;
import org.junit.Test;
-import static org.junit.Assert.*;
public final class TestSparseMatrix extends MatrixTest {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java b/core/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java
index ac107d5..457af31 100644
--- a/core/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java
+++ b/core/src/test/java/org/apache/mahout/math/TestSparseRowMatrix.java
@@ -24,7 +24,6 @@ import org.junit.Assert;
import org.junit.Test;
import java.util.Random;
-import static org.junit.Assert.*;
public final class TestSparseRowMatrix extends MatrixTest {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/TestVectorView.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/TestVectorView.java b/core/src/test/java/org/apache/mahout/math/TestVectorView.java
index f1d58ff..31ca822 100644
--- a/core/src/test/java/org/apache/mahout/math/TestVectorView.java
+++ b/core/src/test/java/org/apache/mahout/math/TestVectorView.java
@@ -22,7 +22,6 @@ import java.util.Iterator;
import org.apache.mahout.math.function.Functions;
import org.apache.mahout.math.function.TimesFunction;
import org.junit.Test;
-import static org.junit.Assert.*;
public final class TestVectorView extends MahoutTestCase {
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/UpperTriangularTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/UpperTriangularTest.java b/core/src/test/java/org/apache/mahout/math/UpperTriangularTest.java
index 599a433..6cc4644 100644
--- a/core/src/test/java/org/apache/mahout/math/UpperTriangularTest.java
+++ b/core/src/test/java/org/apache/mahout/math/UpperTriangularTest.java
@@ -19,7 +19,6 @@ package org.apache.mahout.math;
import org.apache.mahout.math.function.Functions;
import org.junit.Test;
-import static org.junit.Assert.*;
public class UpperTriangularTest extends MahoutTestCase {
@Test
http://git-wip-us.apache.org/repos/asf/mahout/blob/49ad8cb4/core/src/test/java/org/apache/mahout/math/VectorBinaryAggregateCostTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/mahout/math/VectorBinaryAggregateCostTest.java b/core/src/test/java/org/apache/mahout/math/VectorBinaryAggregateCostTest.java
index d92ff10..623476d 100644
--- a/core/src/test/java/org/apache/mahout/math/VectorBinaryAggregateCostTest.java
+++ b/core/src/test/java/org/apache/mahout/math/VectorBinaryAggregateCostTest.java
@@ -1,330 +1,330 @@
-//
-///*
-// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
-// * agreements. See the NOTICE file distributed with this work for additional information regarding
-// * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
-// * "License"); you may not use this file except in compliance with the License. You may obtain a
-// * copy of the License at
-// *
-// * http://www.apache.org/licenses/LICENSE-2.0
-// *
-// * Unless required by applicable law or agreed to in writing, software distributed under the License
-// * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
-// * or implied. See the License for the specific language governing permissions and limitations under
-// * the License.
-// */
-//
-//package org.apache.mahout.math;
-//
-//import org.apache.mahout.math.function.Functions;
-//import org.easymock.EasyMock;
-//import org.junit.Before;
-//import org.junit.Test;
-//import org.junit.runner.RunWith;
-//import org.junit.runners.JUnit4;
-//
-//import static org.easymock.EasyMock.expect;
-//import static org.easymock.EasyMock.replay;
-//import static org.junit.Assert.assertEquals;
-//
-//@RunWith(JUnit4.class)
-//public final class VectorBinaryAggregateCostTest {
-// RandomAccessSparseVector realRasv = new RandomAccessSparseVector(1000000);
-// SequentialAccessSparseVector realSasv = new SequentialAccessSparseVector(1000000);
-// DenseVector realDense = new DenseVector(1000000);
-//
-// Vector rasv = EasyMock.createMock(Vector.class);
-// Vector sasv = EasyMock.createMock(Vector.class);
-// Vector dense = EasyMock.createMock(Vector.class);
-//
-// private static void createStubs(Vector v, Vector realV) {
-// expect(v.getLookupCost())
-// .andStubReturn(realV instanceof SequentialAccessSparseVector
-// ? Math.round(Math.log(1000)) : realV.getLookupCost());
-// expect(v.getIteratorAdvanceCost())
-// .andStubReturn(realV.getIteratorAdvanceCost());
-// expect(v.isAddConstantTime())
-// .andStubReturn(realV.isAddConstantTime());
-// expect(v.isSequentialAccess())
-// .andStubReturn(realV.isSequentialAccess());
-// expect(v.isDense())
-// .andStubReturn(realV.isDense());
-// expect(v.getNumNondefaultElements())
-// .andStubReturn(realV.isDense() ? realV.size() : 1000);
-// expect(v.size())
-// .andStubReturn(realV.size());
-// }
-//
-// @Before
-// public void setUpStubs() {
-// createStubs(dense, realDense);
-// createStubs(sasv, realSasv);
-// createStubs(rasv, realRasv);
-// }
-//
-// @Test
-// public void denseInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void sasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateIterateIntersection.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateIntersection.class,
-// VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void rasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void sasvDenseInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void denseSasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void denseRasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void rasvDenseInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void sasvRasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
-// VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-// @Test
-// public void rasvSasvInteractions() {
-// replayAll();
-//
-// // Dot product
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MULT).getClass());
-//
-// // Chebyshev distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
-//
-// // Euclidean distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
-//
-// // Manhattan distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
-//
-// // Minkowski distance
-// assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
-//
-// // Tanimoto distance
-// assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
-// VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
-// }
-//
-//
-// private void replayAll() {
-// replay(dense, sasv, rasv);
-// }
-//}
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.mahout.math;
+
+import org.apache.mahout.math.function.Functions;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.junit.Assert.assertEquals;
+
+@RunWith(JUnit4.class)
+public final class VectorBinaryAggregateCostTest {
+ RandomAccessSparseVector realRasv = new RandomAccessSparseVector(1000000);
+ SequentialAccessSparseVector realSasv = new SequentialAccessSparseVector(1000000);
+ DenseVector realDense = new DenseVector(1000000);
+
+ Vector rasv = EasyMock.createMock(Vector.class);
+ Vector sasv = EasyMock.createMock(Vector.class);
+ Vector dense = EasyMock.createMock(Vector.class);
+
+ private static void createStubs(Vector v, Vector realV) {
+ expect(v.getLookupCost())
+ .andStubReturn(realV instanceof SequentialAccessSparseVector
+ ? Math.round(Math.log(1000)) : realV.getLookupCost());
+ expect(v.getIteratorAdvanceCost())
+ .andStubReturn(realV.getIteratorAdvanceCost());
+ expect(v.isAddConstantTime())
+ .andStubReturn(realV.isAddConstantTime());
+ expect(v.isSequentialAccess())
+ .andStubReturn(realV.isSequentialAccess());
+ expect(v.isDense())
+ .andStubReturn(realV.isDense());
+ expect(v.getNumNondefaultElements())
+ .andStubReturn(realV.isDense() ? realV.size() : 1000);
+ expect(v.size())
+ .andStubReturn(realV.size());
+ }
+
+ @Before
+ public void setUpStubs() {
+ createStubs(dense, realDense);
+ createStubs(sasv, realSasv);
+ createStubs(rasv, realRasv);
+ }
+
+ @Test
+ public void denseInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(dense, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void sasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateIterateIntersection.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateIntersection.class,
+ VectorBinaryAggregate.getBestOperation(sasv, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void rasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(rasv, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void sasvDenseInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(sasv, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void denseSasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionSequential.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(dense, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void denseRasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(dense, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void rasvDenseInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(rasv, dense, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void sasvRasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThisLookupThat.class,
+ VectorBinaryAggregate.getBestOperation(sasv, rasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+ @Test
+ public void rasvSasvInteractions() {
+ replayAll();
+
+ // Dot product
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MULT).getClass());
+
+ // Chebyshev distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.MAX_ABS, Functions.MINUS).getClass());
+
+ // Euclidean distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MINUS_SQUARED).getClass());
+
+ // Manhattan distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MINUS_ABS).getClass());
+
+ // Minkowski distance
+ assertEquals(VectorBinaryAggregate.AggregateIterateUnionRandom.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.minusAbsPow(1.2)).getClass());
+
+ // Tanimoto distance
+ assertEquals(VectorBinaryAggregate.AggregateNonzerosIterateThatLookupThis.class,
+ VectorBinaryAggregate.getBestOperation(rasv, sasv, Functions.PLUS, Functions.MULT_SQUARE_LEFT).getClass());
+ }
+
+
+ private void replayAll() {
+ replay(dense, sasv, rasv);
+ }
+}