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/27 14:51:45 UTC
[17/51] [partial] mahout git commit: MAHOUT-2042 and MAHOUT-2045
Delete directories which were moved/no longer in use
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MathSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MathSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MathSuite.scala
deleted file mode 100644
index 9e93e63..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MathSuite.scala
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.scalabindings
-
-import org.apache.log4j.Level
-
-import org.apache.mahout.logging._
-import org.apache.mahout.math._
-import org.apache.mahout.math.scalabindings.RLikeOps._
-import org.apache.mahout.test.MahoutSuite
-import org.scalatest.FunSuite
-
-import scala.math._
-
-class MathSuite extends FunSuite with MahoutSuite {
-
- private final implicit val log = getLog(classOf[MathSuite])
-
- test("chol") {
-
- // try to solve Ax=b with cholesky:
- // this requires
- // (LL')x = B
- // L'x= (L^-1)B
- // x=(L'^-1)(L^-1)B
-
- val a = dense((1, 2, 3), (2, 3, 4), (3, 4, 5.5))
-
- // make sure it is symmetric for a valid solution
- a := a.t %*% a
-
- trace(s"A= \n$a")
-
- val b = dense((9, 8, 7)).t
-
- trace(s"b = \n$b")
-
- // Fails if chol(a, true)
- val ch = chol(a)
-
- trace(s"L = \n${ch.getL}")
-
- trace(s"(L^-1)b =\n${ch.solveLeft(b)}\n")
-
- val x = ch.solveRight(eye(3)) %*% ch.solveLeft(b)
-
- trace(s"x = \n$x")
-
- val axmb = (a %*% x) - b
-
- trace(s"AX - B = \n$axmb")
-
- axmb.norm should be < 1e-10
-
- }
-
- test("chol2") {
-
- val vtv = new DenseSymmetricMatrix(
- Array(
- 0.0021401286568947376, 0.001309251254596442, 0.0016003218703045058,
- 0.001545407014131058, 0.0012772546647977234,
- 0.001747768702674435
- ), true)
-
- printf("V'V=\n%s\n", vtv cloned)
-
- val vblock = dense(
- (0.0012356809018514347, 0.006141139195280868, 8.037742467936037E-4),
- (0.007910767859830255, 0.007989899899005457, 0.006877961936587515),
- (0.007011211118759952, 0.007458865101641882, 0.0048344749320346795),
- (0.006578789899685284, 0.0010812485516549452, 0.0062146270886981655)
- )
-
- val d = diag(15.0, 4)
-
-
- val b = dense(
- 0.36378319648203084,
- 0.3627384439613304,
- 0.2996934112658234)
-
- printf("B=\n%s\n", b)
-
-
- val cholArg = vtv + (vblock.t %*% d %*% vblock) + diag(4e-6, 3)
-
- printf("cholArg=\n%s\n", cholArg)
-
- printf("V'DV=\n%s\n", vblock.t %*% d %*% vblock)
-
- printf("V'V+V'DV=\n%s\n", vtv + (vblock.t %*% d %*% vblock))
-
- val ch = chol(cholArg)
-
- printf("L=\n%s\n", ch.getL)
-
- val x = ch.solveRight(eye(cholArg.nrow)) %*% ch.solveLeft(b)
-
- printf("X=\n%s\n", x)
-
- assert((cholArg %*% x - b).norm < 1e-10)
-
- }
-
- test("qr") {
- val a = dense((1, 2, 3), (2, 3, 6), (3, 4, 5), (4, 7, 8))
- val (q, r) = qr(a)
-
- printf("Q=\n%s\n", q)
- printf("R=\n%s\n", r)
-
- for (i <- 0 until q.ncol; j <- i + 1 until q.ncol)
- assert(abs(q(::, i) dot q(::, j)) < 1e-10)
- }
-
- test("solve matrix-vector") {
- val a = dense((1, 3), (4, 2))
- val b = dvec(11, 14)
- val x = solve(a, b)
-
- val control = dvec(2, 3)
-
- (control - x).norm(2) should be < 1e-10
- }
-
- test("solve matrix-matrix") {
- val a = dense((1, 3), (4, 2))
- val b = dense(11, 14)
- val x = solve(a, b)
-
- val control = dense(2, 3)
-
- (control - x).norm should be < 1e-10
- }
-
- test("solve to obtain inverse") {
- val a = dense((1, 3), (4, 2))
- val x = solve(a)
-
- val identity = a %*% x
-
- val control = eye(identity.ncol)
-
- (control - identity).norm should be < 1e-10
- }
-
- test("solve rejects non-square matrix") {
- intercept[IllegalArgumentException] {
- val a = dense((1, 2, 3), (4, 5, 6))
- val b = dvec(1, 2)
- solve(a, b)
- }
- }
-
- test("solve rejects singular matrix") {
- intercept[IllegalArgumentException] {
- val a = dense((1, 2), (2 , 4))
- val b = dvec(1, 2)
- solve(a, b)
- }
- }
-
- test("svd") {
-
- val a = dense((1, 2, 3), (3, 4, 5))
-
- val (u, v, s) = svd(a)
-
- printf("U:\n%s\n", u.toString)
- printf("V:\n%s\n", v.toString)
- printf("Sigma:\n%s\n", s.toString)
-
- val aBar = u %*% diagv(s) %*% v.t
-
- val amab = a - aBar
-
- printf("A-USV'=\n%s\n", amab.toString)
-
- assert(amab.norm < 1e-10)
-
- }
-
- test("random uniform") {
- val omega1 = Matrices.symmetricUniformView(2, 3, 1234)
- val omega2 = Matrices.symmetricUniformView(2, 3, 1234)
-
- val a = sparse(
- 0 -> 1 :: 1 -> 2 :: Nil,
- 0 -> 3 :: 1 -> 4 :: Nil,
- 0 -> 2 :: 1 -> 0.0 :: Nil
- )
-
- val block = a(0 to 0, ::).cloned
- val block2 = a(1 to 1, ::).cloned
-
- (block %*% omega1 - (a %*% omega2)(0 to 0, ::)).norm should be < 1e-7
- (block2 %*% omega1 - (a %*% omega2)(1 to 1, ::)).norm should be < 1e-7
-
- }
-
- test("sqDist(X,Y)") {
- val m = 100
- val n = 300
- val d = 7
- val mxX = Matrices.symmetricUniformView(m, d, 12345).cloned -= 5
- val mxY = Matrices.symmetricUniformView(n, d, 1234).cloned += 10
-
- val mxDsq = sqDist(mxX, mxY)
- val mxDsqControl = new DenseMatrix(m, n) := { (r, c, _) ⇒ (mxX(r, ::) - mxY(c, ::)) ^= 2 sum }
- (mxDsq - mxDsqControl).norm should be < 1e-7
- }
-
- test("sqDist(X)") {
- val m = 100
- val d = 7
- val mxX = Matrices.symmetricUniformView(m, d, 12345).cloned -= 5
-
- val mxDsq = sqDist(mxX)
- val mxDsqControl = sqDist(mxX, mxX)
- (mxDsq - mxDsqControl).norm should be < 1e-7
- }
-
- test("sparsity analysis") {
- setLogLevel(Level.DEBUG)
-
- val m = 500
- val n = 800
- val mxA = new DenseMatrix(m, n)
-
- densityAnalysis(mxA) shouldBe false
- densityAnalysis(mxA, .5) shouldBe false
- densityAnalysis(mxA + 1) shouldBe true
- densityAnalysis(mxA + 1, .95) shouldBe true
-
- for (i ← 0 until m by 5) mxA(i, ::) := 1
- info(s"20% detected as dense?:${densityAnalysis(mxA)}")
- mxA := 0
-
- for (i ← 0 until m by 3) mxA(i, ::) := 1
- info(s"33% detected as dense?:${densityAnalysis(mxA)}")
- mxA := 0
-
- for (i ← 0 until m by 4) mxA(i, ::) := 1
- info(s"25% detected as dense?:${densityAnalysis(mxA)}")
-
- for (i ← 0 until m by 2) mxA(i, ::) := 1
- info(s"50% detected as dense?:${densityAnalysis(mxA)}")
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatlabLikeMatrixOpsSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatlabLikeMatrixOpsSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatlabLikeMatrixOpsSuite.scala
deleted file mode 100644
index 547f710..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatlabLikeMatrixOpsSuite.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.scalabindings
-
-import org.scalatest.FunSuite
-import MatlabLikeOps._
-import scala.Predef._
-import org.apache.mahout.test.MahoutSuite
-
-class MatlabLikeMatrixOpsSuite extends FunSuite with MahoutSuite {
-
- test("multiplication") {
-
- val a = dense((1, 2, 3), (3, 4, 5))
- val b = dense(1, 4, 5)
- val m = a * b
-
- assert(m(0, 0) == 24)
- assert(m(1, 0) == 44)
- println(m.toString)
- }
-
- test("Hadamard") {
- val a = dense(
- (1, 2, 3),
- (3, 4, 5)
- )
- val b = dense(
- (1, 1, 2),
- (2, 1, 1)
- )
-
- val c = a *@ b
-
- printf("C=\n%s\n", c)
-
- assert(c(0, 0) == 1)
- assert(c(1, 2) == 5)
- println(c.toString)
-
- val d = a *@ 5.0
- assert(d(0, 0) == 5)
- assert(d(1, 1) == 20)
-
- a *@= b
- assert(a(0, 0) == 1)
- assert(a(1, 2) == 5)
- println(a.toString)
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatrixOpsSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatrixOpsSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatrixOpsSuite.scala
deleted file mode 100644
index 1296d9e..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/MatrixOpsSuite.scala
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * 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.scalabindings
-
-import org.scalatest.{Matchers, FunSuite}
-import RLikeOps._
-import scala._
-import org.apache.mahout.test.MahoutSuite
-import org.apache.mahout.math.{RandomAccessSparseVector, SequentialAccessSparseVector, Matrices}
-import org.apache.mahout.common.RandomUtils
-
-import scala.util.Random
-
-
-class MatrixOpsSuite extends FunSuite with MahoutSuite {
-
- test("equivalence") {
- val a = dense((1, 2, 3), (3, 4, 5))
- val b = dense((1, 2, 3), (3, 4, 5))
- val c = dense((1, 4, 3), (3, 4, 5))
- assert(a === b)
- assert(a !== c)
- }
-
- test("elementwise plus, minus") {
- val a = dense((1, 2, 3), (3, 4, 5))
- val b = dense((1, 1, 2), (2, 1, 1))
-
- val c = a + b
- assert(c(0, 0) == 2)
- assert(c(1, 2) == 6)
- println(c.toString)
- }
-
- test("matrix, vector slicing") {
-
- val a = dense((1, 2, 3), (3, 4, 5))
-
- assert(a(::, 0).sum == 4)
- assert(a(1, ::).sum == 12)
-
- assert(a(0 to 1, 1 to 2).sum == 14)
-
- // assign to slice-vector
- a(0, 0 to 1) :=(3, 5)
- // or
- a(0, 0 to 1) = (3, 5)
-
- assert(a(0, ::).sum == 11)
-
- println(a.toString)
-
- // assign to a slice-matrix
- a(0 to 1, 0 to 1) := dense((1, 1), (2, 2.5))
-
- // or
- a(0 to 1, 0 to 1) = dense((1, 1), (2, 2.5))
-
- println(a)
- println(a.sum)
-
- val b = dense((1, 2, 3), (3, 4, 5))
- b(0, ::) -= dvec(1, 2, 3)
- println(b)
- b(0, ::) should equal(dvec(0, 0, 0))
-
- }
-
- test("assignments") {
-
- val a = dense((1, 2, 3), (3, 4, 5))
-
- val b = a cloned
-
- b(0, 0) = 2.0
-
- printf("B=\n%s\n", b)
-
- assert((b - a).norm - 1 < 1e-10)
-
- val e = eye(5)
-
- println(s"I(5)=\n$e")
-
- a(0 to 1, 1 to 2) = dense((3, 2), (2, 3))
- a(0 to 1, 1 to 2) := dense((3, 2), (2, 3))
-
- println(s"a=$a")
-
- a(0 to 1, 1 to 2) := { _ => 45}
- println(s"a=$a")
-
-// a(0 to 1, 1 to 2) ::= { _ => 44}
- println(s"a=$a")
-
- // Sparse assignment to a sparse block
- val c = sparse(0 -> 1 :: Nil, 2 -> 2 :: Nil, 1 -> 5 :: Nil)
- val d = c.cloned
-
- println(s"d=$d")
- d.ncol shouldBe 3
-
- d(::, 1 to 2) ::= { _ => 4}
- println(s"d=$d")
- d(::, 1 to 2).sum shouldBe 8
-
- d ::= {_ => 5}
- d.sum shouldBe 15
-
- val f = c.cloned.t
- f ::= {_ => 6}
- f.sum shouldBe 18
-
- val g = c.cloned
- g(::, 1 until g.nrow) ::= { x => if (x <= 0) 0.0 else 1.0}
- g.sum shouldBe 3
- }
-
- test("functional apply()") {
- val mxA = sparse (
- (1 -> 3) :: (7 -> 7) :: Nil,
- (4 -> 5) :: (5 -> 8) :: Nil
- )
- val mxAControl = mxA cloned
-
- (mxA(x ⇒ x + 1) - (mxAControl + 1)).norm should be < 1e-7
- (mxA(x ⇒ x * 2) - (2 * mxAControl)).norm should be < 1e-7
-
- }
-
- test("sparse") {
-
- val a = sparse((1, 3) :: Nil,
- (0, 2) ::(1, 2.5) :: Nil
- )
- println(a.toString)
- }
-
- test("colSums, rowSums, colMeans, rowMeans, numNonZeroElementsPerColumn") {
- val a = dense(
- (2, 3, 4),
- (3, 4, 5)
- )
-
- a.colSums() should equal(dvec(5, 7, 9))
- a.rowSums() should equal(dvec(9, 12))
- a.colMeans() should equal(dvec(2.5, 3.5, 4.5))
- a.rowMeans() should equal(dvec(3, 4))
- a.numNonZeroElementsPerColumn() should equal(dvec(2,2,2))
- a.numNonZeroElementsPerRow() should equal(dvec(3,3))
-
- }
-
- test("numNonZeroElementsPerColumn and Row") {
- val a = dense(
- (2, 3, 4),
- (3, 4, 5),
- (-5, 0, -1),
- (0, 0, 1)
- )
-
- a.numNonZeroElementsPerColumn() should equal(dvec(3,2,4))
- a.numNonZeroElementsPerRow() should equal(dvec(3,3,2,1))
- }
-
- test("Vector Assignment performance") {
-
- val n = 1000
- val k = (n * 0.1).toInt
- val nIters = 10000
-
- val rnd = RandomUtils.getRandom
-
- val src = new SequentialAccessSparseVector(n)
- for (i <- 0 until k) src(rnd.nextInt(n)) = rnd.nextDouble()
-
- val times = (0 until 50).map { i =>
- val ms = System.currentTimeMillis()
- var j = 0
- while (j < nIters) {
- new SequentialAccessSparseVector(n) := src
- j += 1
- }
- System.currentTimeMillis() - ms
- }
-
- .tail
-
- val avgTime = times.sum.toDouble / times.size
-
- printf("Average assignment seqSparse2seqSparse time: %.3f ms\n", avgTime)
-
- val times2 = (0 until 50).map { i =>
- val ms = System.currentTimeMillis()
- var j = 0
- while (j < nIters) {
- new SequentialAccessSparseVector(n) := (new RandomAccessSparseVector(n) := src)
- j += 1
- }
- System.currentTimeMillis() - ms
- }
-
- .tail
-
- val avgTime2 = times2.sum.toDouble / times2.size
-
- printf("Average assignment seqSparse2seqSparse via Random Access Sparse time: %.3f ms\n", avgTime2)
-
- }
-
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeMatrixOpsSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeMatrixOpsSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeMatrixOpsSuite.scala
deleted file mode 100644
index 6dc8207..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeMatrixOpsSuite.scala
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * 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.scalabindings
-
-import java.util
-
-import org.apache.log4j.Level
-import org.apache.mahout.math._
-import org.scalatest.FunSuite
-import RLikeOps._
-import org.apache.mahout.test.MahoutSuite
-import org.apache.mahout.logging._
-import scala.collection.JavaConversions._
-import scala.util.Random
-
-class RLikeMatrixOpsSuite extends FunSuite with MahoutSuite {
-
- test("multiplication") {
-
- val a = dense((1, 2, 3), (3, 4, 5))
- val b = dense(1, 4, 5)
- val m = a %*% b
-
- assert(m(0, 0) == 24)
- assert(m(1, 0) == 44)
- println(m.toString)
- }
-
- test("Hadamard") {
- val a = dense(
- (1, 2, 3),
- (3, 4, 5)
- )
- val b = dense(
- (1, 1, 2),
- (2, 1, 1)
- )
-
- val c = a * b
-
- printf("C=\n%s\n", c)
-
- assert(c(0, 0) == 1)
- assert(c(1, 2) == 5)
- println(c.toString)
-
- val d = a * 5.0
- assert(d(0, 0) == 5)
- assert(d(1, 1) == 20)
-
- a *= b
- assert(a(0, 0) == 1)
- assert(a(1, 2) == 5)
- println(a.toString)
-
- }
-
- test("Uniform view") {
- val mxUnif = Matrices.symmetricUniformView(5000000, 5000000, 1234)
- }
-
- /** Test dsl overloads over scala operations over matrices */
- test ("scalarOps") {
- val a = dense(
- (1, 2, 3),
- (3, 4, 5)
- )
-
- (10 * a - (10 *: a)).norm shouldBe 0
- (10 + a - (10 +: a)).norm shouldBe 0
- (10 - a - (10 -: a)).norm shouldBe 0
- (10 / a - (10 /: a)).norm shouldBe 0
-
- }
-
- test("Multiplication experimental performance") {
-
- getLog(MMul.getClass).setLevel(Level.DEBUG)
-
- val d = 300
- val n = 3
-
- // Dense row-wise
- val mxAd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) + 1
- val mxBd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) - 1
-
- val rnd = new Random(1234)
-
- // Sparse rows
- val mxAsr = (new SparseRowMatrix(d,
- d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() + 1 else 0.0 }) cloned
- val mxBsr = (new SparseRowMatrix(d,
- d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() - 1 else 0.0 }) cloned
-
- // Hanging sparse rows
- val mxAs = (new SparseMatrix(d, d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() + 1 else 0.0 }) cloned
- val mxBs = (new SparseMatrix(d, d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() - 1 else 0.0 }) cloned
-
- // DIAGONAL
- val mxD = diagv(dvec(Array.tabulate(d)(_ => rnd.nextGaussian())))
-
- def time(op: => Unit): Long = {
- val ms = System.currentTimeMillis()
- op
- System.currentTimeMillis() - ms
- }
-
-
- // We're not using GPUMMul or OMPMMul in math-scala so dont need to worry about
- // changing it in this method
- def getMmulAvgs(mxA: Matrix, mxB: Matrix, n: Int) = {
-
- var control: Matrix = null
- var mmulVal: Matrix = null
-
- val current = Stream.range(0, n).map { _ => time {control = mxA.times(mxB)} }.sum.toDouble / n
- val experimental = Stream.range(0, n).map { _ => time {mmulVal = MMul(mxA, mxB, None)} }.sum.toDouble / n
- (control - mmulVal).norm should be < 1e-10
- current -> experimental
- }
-
- // Dense matrix tests.
- println(s"Ad %*% Bd: ${getMmulAvgs(mxAd, mxBd, n)}")
- println(s"Ad(::,::) %*% Bd: ${getMmulAvgs(mxAd(0 until mxAd.nrow,::), mxBd, n)}")
- println(s"Ad' %*% Bd: ${getMmulAvgs(mxAd.t, mxBd, n)}")
- println(s"Ad %*% Bd': ${getMmulAvgs(mxAd, mxBd.t, n)}")
- println(s"Ad' %*% Bd': ${getMmulAvgs(mxAd.t, mxBd.t, n)}")
- println(s"Ad'' %*% Bd'': ${getMmulAvgs(mxAd.t.t, mxBd.t.t, n)}")
- println
-
- // Sparse row matrix tests.
- println(s"Asr %*% Bsr: ${getMmulAvgs(mxAsr, mxBsr, n)}")
- println(s"Asr' %*% Bsr: ${getMmulAvgs(mxAsr.t, mxBsr, n)}")
- println(s"Asr %*% Bsr': ${getMmulAvgs(mxAsr, mxBsr.t, n)}")
- println(s"Asr' %*% Bsr': ${getMmulAvgs(mxAsr.t, mxBsr.t, n)}")
- println(s"Asr'' %*% Bsr'': ${getMmulAvgs(mxAsr.t.t, mxBsr.t.t, n)}")
- println
-
- // Sparse matrix tests.
- println(s"Asm %*% Bsm: ${getMmulAvgs(mxAs, mxBs, n)}")
- println(s"Asm' %*% Bsm: ${getMmulAvgs(mxAs.t, mxBs, n)}")
- println(s"Asm %*% Bsm': ${getMmulAvgs(mxAs, mxBs.t, n)}")
- println(s"Asm' %*% Bsm': ${getMmulAvgs(mxAs.t, mxBs.t, n)}")
- println(s"Asm'' %*% Bsm'': ${getMmulAvgs(mxAs.t.t, mxBs.t.t, n)}")
- println
-
- // Mixed sparse matrix tests.
- println(s"Asm %*% Bsr: ${getMmulAvgs(mxAs, mxBsr, n)}")
- println(s"Asm' %*% Bsr: ${getMmulAvgs(mxAs.t, mxBsr, n)}")
- println(s"Asm %*% Bsr': ${getMmulAvgs(mxAs, mxBsr.t, n)}")
- println(s"Asm' %*% Bsr': ${getMmulAvgs(mxAs.t, mxBsr.t, n)}")
- println(s"Asm'' %*% Bsr'': ${getMmulAvgs(mxAs.t.t, mxBsr.t.t, n)}")
- println
-
- println(s"Asr %*% Bsm: ${getMmulAvgs(mxAsr, mxBs, n)}")
- println(s"Asr' %*% Bsm: ${getMmulAvgs(mxAsr.t, mxBs, n)}")
- println(s"Asr %*% Bsm': ${getMmulAvgs(mxAsr, mxBs.t, n)}")
- println(s"Asr' %*% Bsm': ${getMmulAvgs(mxAsr.t, mxBs.t, n)}")
- println(s"Asr'' %*% Bsm'': ${getMmulAvgs(mxAsr.t.t, mxBs.t.t, n)}")
- println
-
- // Mixed dense/sparse
- println(s"Ad %*% Bsr: ${getMmulAvgs(mxAd, mxBsr, n)}")
- println(s"Ad' %*% Bsr: ${getMmulAvgs(mxAd.t, mxBsr, n)}")
- println(s"Ad %*% Bsr': ${getMmulAvgs(mxAd, mxBsr.t, n)}")
- println(s"Ad' %*% Bsr': ${getMmulAvgs(mxAd.t, mxBsr.t, n)}")
- println(s"Ad'' %*% Bsr'': ${getMmulAvgs(mxAd.t.t, mxBsr.t.t, n)}")
- println
-
- println(s"Asr %*% Bd: ${getMmulAvgs(mxAsr, mxBd, n)}")
- println(s"Asr' %*% Bd: ${getMmulAvgs(mxAsr.t, mxBd, n)}")
- println(s"Asr %*% Bd': ${getMmulAvgs(mxAsr, mxBd.t, n)}")
- println(s"Asr' %*% Bd': ${getMmulAvgs(mxAsr.t, mxBd.t, n)}")
- println(s"Asr'' %*% Bd'': ${getMmulAvgs(mxAsr.t.t, mxBd.t.t, n)}")
- println
-
- println(s"Ad %*% Bsm: ${getMmulAvgs(mxAd, mxBs, n)}")
- println(s"Ad' %*% Bsm: ${getMmulAvgs(mxAd.t, mxBs, n)}")
- println(s"Ad %*% Bsm': ${getMmulAvgs(mxAd, mxBs.t, n)}")
- println(s"Ad' %*% Bsm': ${getMmulAvgs(mxAd.t, mxBs.t, n)}")
- println(s"Ad'' %*% Bsm'': ${getMmulAvgs(mxAd.t.t, mxBs.t.t, n)}")
- println
-
- println(s"Asm %*% Bd: ${getMmulAvgs(mxAs, mxBd, n)}")
- println(s"Asm' %*% Bd: ${getMmulAvgs(mxAs.t, mxBd, n)}")
- println(s"Asm %*% Bd': ${getMmulAvgs(mxAs, mxBd.t, n)}")
- println(s"Asm' %*% Bd': ${getMmulAvgs(mxAs.t, mxBd.t, n)}")
- println(s"Asm'' %*% Bd'': ${getMmulAvgs(mxAs.t.t, mxBd.t.t, n)}")
- println
-
- // Diagonal cases
- println(s"Ad %*% D: ${getMmulAvgs(mxAd, mxD, n)}")
- println(s"Asr %*% D: ${getMmulAvgs(mxAsr, mxD, n)}")
- println(s"Asm %*% D: ${getMmulAvgs(mxAs, mxD, n)}")
- println(s"D %*% Ad: ${getMmulAvgs(mxD, mxAd, n)}")
- println(s"D %*% Asr: ${getMmulAvgs(mxD, mxAsr, n)}")
- println(s"D %*% Asm: ${getMmulAvgs(mxD, mxAs, n)}")
- println
-
- println(s"Ad' %*% D: ${getMmulAvgs(mxAd.t, mxD, n)}")
- println(s"Asr' %*% D: ${getMmulAvgs(mxAsr.t, mxD, n)}")
- println(s"Asm' %*% D: ${getMmulAvgs(mxAs.t, mxD, n)}")
- println(s"D %*% Ad': ${getMmulAvgs(mxD, mxAd.t, n)}")
- println(s"D %*% Asr': ${getMmulAvgs(mxD, mxAsr.t, n)}")
- println(s"D %*% Asm': ${getMmulAvgs(mxD, mxAs.t, n)}")
- println
-
- // Self-squared cases
- println(s"Ad %*% Ad': ${getMmulAvgs(mxAd, mxAd.t, n)}")
- println(s"Ad' %*% Ad: ${getMmulAvgs(mxAd.t, mxAd, n)}")
- println(s"Ad' %*% Ad'': ${getMmulAvgs(mxAd.t, mxAd.t.t, n)}")
- println(s"Ad'' %*% Ad': ${getMmulAvgs(mxAd.t.t, mxAd.t, n)}")
-
- }
-
-
- test("elementwise experimental performance") {
-
- val d = 500
- val n = 3
-
- // Dense row-wise
- val mxAd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) + 1
- val mxBd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) - 1
-
- val rnd = new Random(1234)
-
- // Sparse rows
- val mxAsr = (new SparseRowMatrix(d,
- d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() + 1 else 0.0 }) cloned
- val mxBsr = (new SparseRowMatrix(d,
- d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() - 1 else 0.0 }) cloned
-
- // Hanging sparse rows
- val mxAs = (new SparseMatrix(d, d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() + 1 else 0.0 }) cloned
- val mxBs = (new SparseMatrix(d, d) := { _ => if (rnd.nextDouble() < 0.1) rnd.nextGaussian() - 1 else 0.0 }) cloned
-
- // DIAGONAL
- val mxD = diagv(dvec(Array.tabulate(d)(_ => rnd.nextGaussian())))
-
- def time(op: => Unit): Long = {
- val ms = System.currentTimeMillis()
- op
- System.currentTimeMillis() - ms
- }
-
- def getEWAvgs(mxA: Matrix, mxB: Matrix, n: Int) = {
-
- var control: Matrix = null
- var mmulVal: Matrix = null
-
- val current = Stream.range(0, n).map { _ => time {control = mxA + mxB} }.sum.toDouble / n
- val experimental = Stream.range(0, n).map { _ => time {mmulVal = mxA + mxB} }.sum.toDouble / n
- (control - mmulVal).norm should be < 1e-10
- current -> experimental
- }
-
- // Dense matrix tests.
- println(s"Ad + Bd: ${getEWAvgs(mxAd, mxBd, n)}")
- println(s"Ad' + Bd: ${getEWAvgs(mxAd.t, mxBd, n)}")
- println(s"Ad + Bd': ${getEWAvgs(mxAd, mxBd.t, n)}")
- println(s"Ad' + Bd': ${getEWAvgs(mxAd.t, mxBd.t, n)}")
- println(s"Ad'' + Bd'': ${getEWAvgs(mxAd.t.t, mxBd.t.t, n)}")
- println
-
- // Sparse row matrix tests.
- println(s"Asr + Bsr: ${getEWAvgs(mxAsr, mxBsr, n)}")
- println(s"Asr' + Bsr: ${getEWAvgs(mxAsr.t, mxBsr, n)}")
- println(s"Asr + Bsr': ${getEWAvgs(mxAsr, mxBsr.t, n)}")
- println(s"Asr' + Bsr': ${getEWAvgs(mxAsr.t, mxBsr.t, n)}")
- println(s"Asr'' + Bsr'': ${getEWAvgs(mxAsr.t.t, mxBsr.t.t, n)}")
- println
-
- // Sparse matrix tests.
- println(s"Asm + Bsm: ${getEWAvgs(mxAs, mxBs, n)}")
- println(s"Asm' + Bsm: ${getEWAvgs(mxAs.t, mxBs, n)}")
- println(s"Asm + Bsm': ${getEWAvgs(mxAs, mxBs.t, n)}")
- println(s"Asm' + Bsm': ${getEWAvgs(mxAs.t, mxBs.t, n)}")
- println(s"Asm'' + Bsm'': ${getEWAvgs(mxAs.t.t, mxBs.t.t, n)}")
- println
-
- // Mixed sparse matrix tests.
- println(s"Asm + Bsr: ${getEWAvgs(mxAs, mxBsr, n)}")
- println(s"Asm' + Bsr: ${getEWAvgs(mxAs.t, mxBsr, n)}")
- println(s"Asm + Bsr': ${getEWAvgs(mxAs, mxBsr.t, n)}")
- println(s"Asm' + Bsr': ${getEWAvgs(mxAs.t, mxBsr.t, n)}")
- println(s"Asm'' + Bsr'': ${getEWAvgs(mxAs.t.t, mxBsr.t.t, n)}")
- println
-
- println(s"Asr + Bsm: ${getEWAvgs(mxAsr, mxBs, n)}")
- println(s"Asr' + Bsm: ${getEWAvgs(mxAsr.t, mxBs, n)}")
- println(s"Asr + Bsm': ${getEWAvgs(mxAsr, mxBs.t, n)}")
- println(s"Asr' + Bsm': ${getEWAvgs(mxAsr.t, mxBs.t, n)}")
- println(s"Asr'' + Bsm'': ${getEWAvgs(mxAsr.t.t, mxBs.t.t, n)}")
- println
-
- // Mixed dense/sparse
- println(s"Ad + Bsr: ${getEWAvgs(mxAd, mxBsr, n)}")
- println(s"Ad' + Bsr: ${getEWAvgs(mxAd.t, mxBsr, n)}")
- println(s"Ad + Bsr': ${getEWAvgs(mxAd, mxBsr.t, n)}")
- println(s"Ad' + Bsr': ${getEWAvgs(mxAd.t, mxBsr.t, n)}")
- println(s"Ad'' + Bsr'': ${getEWAvgs(mxAd.t.t, mxBsr.t.t, n)}")
- println
-
- println(s"Asr + Bd: ${getEWAvgs(mxAsr, mxBd, n)}")
- println(s"Asr' + Bd: ${getEWAvgs(mxAsr.t, mxBd, n)}")
- println(s"Asr + Bd': ${getEWAvgs(mxAsr, mxBd.t, n)}")
- println(s"Asr' + Bd': ${getEWAvgs(mxAsr.t, mxBd.t, n)}")
- println(s"Asr'' + Bd'': ${getEWAvgs(mxAsr.t.t, mxBd.t.t, n)}")
- println
-
- println(s"Ad + Bsm: ${getEWAvgs(mxAd, mxBs, n)}")
- println(s"Ad' + Bsm: ${getEWAvgs(mxAd.t, mxBs, n)}")
- println(s"Ad + Bsm': ${getEWAvgs(mxAd, mxBs.t, n)}")
- println(s"Ad' + Bsm': ${getEWAvgs(mxAd.t, mxBs.t, n)}")
- println(s"Ad'' + Bsm'': ${getEWAvgs(mxAd.t.t, mxBs.t.t, n)}")
- println
-
- println(s"Asm + Bd: ${getEWAvgs(mxAs, mxBd, n)}")
- println(s"Asm' + Bd: ${getEWAvgs(mxAs.t, mxBd, n)}")
- println(s"Asm + Bd': ${getEWAvgs(mxAs, mxBd.t, n)}")
- println(s"Asm' + Bd': ${getEWAvgs(mxAs.t, mxBd.t, n)}")
- println(s"Asm'' + Bd'': ${getEWAvgs(mxAs.t.t, mxBd.t.t, n)}")
- println
-
- // Diagonal cases
- println(s"Ad + D: ${getEWAvgs(mxAd, mxD, n)}")
- println(s"Asr + D: ${getEWAvgs(mxAsr, mxD, n)}")
- println(s"Asm + D: ${getEWAvgs(mxAs, mxD, n)}")
- println(s"D + Ad: ${getEWAvgs(mxD, mxAd, n)}")
- println(s"D + Asr: ${getEWAvgs(mxD, mxAsr, n)}")
- println(s"D + Asm: ${getEWAvgs(mxD, mxAs, n)}")
- println
-
- println(s"Ad' + D: ${getEWAvgs(mxAd.t, mxD, n)}")
- println(s"Asr' + D: ${getEWAvgs(mxAsr.t, mxD, n)}")
- println(s"Asm' + D: ${getEWAvgs(mxAs.t, mxD, n)}")
- println(s"D + Ad': ${getEWAvgs(mxD, mxAd.t, n)}")
- println(s"D + Asr': ${getEWAvgs(mxD, mxAsr.t, n)}")
- println(s"D + Asm': ${getEWAvgs(mxD, mxAs.t, n)}")
- println
-
- }
-
- test("dense-view-debug") {
- val d = 500
- // Dense row-wise
- val mxAd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) + 1
- val mxBd = new DenseMatrix(d, d) := Matrices.gaussianView(d, d, 134) - 1
-
- mxAd(0 until mxAd.nrow, ::) %*% mxBd
-
- }
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeVectorOpsSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeVectorOpsSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeVectorOpsSuite.scala
deleted file mode 100644
index f17f08a..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/RLikeVectorOpsSuite.scala
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.scalabindings
-
-import org.apache.log4j.{BasicConfigurator, Level}
-import org.apache.mahout.logging._
-import org.apache.mahout.math._
-import org.apache.mahout.math.scalabindings.RLikeOps._
-import org.apache.mahout.test.MahoutSuite
-import org.scalatest.FunSuite
-
-class RLikeVectorOpsSuite extends FunSuite with MahoutSuite {
-
- BasicConfigurator.configure()
- private[scalabindings] final implicit val log = getLog(classOf[RLikeVectorOpsSuite])
- setLogLevel(Level.DEBUG)
-
- test("Hadamard") {
- val a: Vector = (1, 2, 3)
- val b = (3, 4, 5)
-
- val c = a * b
- println(c)
- assert(c ===(3, 8, 15))
- }
-
- test("dot-view performance") {
-
- val dv1 = new DenseVector(500) := Matrices.uniformView(1, 500, 1234)(0, ::)
- val dv2 = new DenseVector(500) := Matrices.uniformView(1, 500, 1244)(0, ::)
-
- val nit = 300000
-
- // warm up
- dv1 dot dv2
-
- val dmsStart = System.currentTimeMillis()
- for (i ← 0 until nit)
- dv1 dot dv2
- val dmsMs = System.currentTimeMillis() - dmsStart
-
- val (dvv1, dvv2) = dv1(0 until dv1.length) → dv2(0 until dv2.length)
-
- // Warm up.
- dvv1 dot dvv2
-
- val dvmsStart = System.currentTimeMillis()
- for (i ← 0 until nit)
- dvv1 dot dvv2
- val dvmsMs = System.currentTimeMillis() - dvmsStart
-
- debug(f"dense vector dots:${dmsMs}%.2f ms.")
- debug(f"dense view dots:${dvmsMs}%.2f ms.")
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/VectorOpsSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/VectorOpsSuite.scala b/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/VectorOpsSuite.scala
deleted file mode 100644
index fe272df..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/math/scalabindings/VectorOpsSuite.scala
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.scalabindings
-
-import org.scalatest.FunSuite
-import org.apache.mahout.math.{SequentialAccessSparseVector, RandomAccessSparseVector, Vector}
-import RLikeOps._
-import org.apache.mahout.test.MahoutSuite
-
-import scala.util.Random
-
-/** VectorOps Suite */
-class VectorOpsSuite extends FunSuite with MahoutSuite {
-
- test("inline create") {
-
- val sparseVec = svec((5 -> 1) :: (10 -> 2.0) :: Nil)
- println(sparseVec)
-
- assert(sparseVec.size() == 11)
-
- val sparseVec2: Vector = (5 -> 1.0) :: (10 -> 2.0) :: Nil
- println(sparseVec2)
-
- val sparseVec3: Vector = new RandomAccessSparseVector(100) := (5 -> 1.0) :: Nil
- println(sparseVec3)
-
- val sparseVec4 = svec((5 -> 1) :: (10 -> 2.0) :: Nil, 100)
- println(sparseVec4)
-
- assert(sparseVec4.size() == 100)
-
- intercept[IllegalArgumentException] {
- val sparseVec5 = svec((5 -> 1) :: (10 -> 2.0) :: Nil, 10)
- }
-
- val denseVec1: Vector = (1.0, 1.1, 1.2)
- println(denseVec1)
-
- val denseVec2 = dvec(1, 0, 1.1, 1.2)
- println(denseVec2)
- }
-
- test("plus minus") {
-
- val a: Vector = (1, 2, 3)
- val b: Vector = (0 -> 3) :: (1 -> 4) :: (2 -> 5) :: Nil
-
- val c = a + b
- val d = b - a
- val e = -b - a
-
- assert(c ===(4, 6, 8))
- assert(d ===(2, 2, 2))
- assert(e ===(-4, -6, -8))
-
- }
-
- test("dot") {
-
- val a: Vector = (1, 2, 3)
- val b = (3, 4, 5)
-
- val c = a dot b
- println(c)
- assert(c == 26)
-
- }
-
- test ("scalarOps") {
- val a = dvec(1 to 5):Vector
-
- 10 * a shouldBe 10 *: a
- 10 + a shouldBe 10 +: a
- 10 - a shouldBe 10 -: a
- 10 / a shouldBe 10 /: a
-
- }
-
- test("sparse assignment") {
-
- val svec = new SequentialAccessSparseVector(30)
- svec(1) = -0.5
- svec(3) = 0.5
- println(svec)
-
- svec(1 until svec.length) ::= ( _ => 0)
- println(svec)
-
- svec.sum shouldBe 0
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/nlp/tfidf/TFIDFtestBase.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/nlp/tfidf/TFIDFtestBase.scala b/math-scala/src/test/scala/org/apache/mahout/nlp/tfidf/TFIDFtestBase.scala
deleted file mode 100644
index 4635e95..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/nlp/tfidf/TFIDFtestBase.scala
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * 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.nlp.tfidf
-
-import org.apache.mahout.math._
-import org.apache.mahout.math.scalabindings._
-import org.apache.mahout.test.DistributedMahoutSuite
-import org.scalatest.{FunSuite, Matchers}
-import scala.collection._
-import RLikeOps._
-import scala.math._
-
-
-trait TFIDFtestBase extends DistributedMahoutSuite with Matchers {
- this: FunSuite =>
-
- val epsilon = 1E-6
-
- val documents: List[(Int, String)] = List(
- (1, "the first document contains 5 terms"),
- (2, "document two document contains 4 terms"),
- (3, "document three three terms"),
- (4, "each document including this document contain the term document"))
-
- def createDictionaryAndDfMaps(documents: List[(Int, String)]): (Map[String, Int], Map[Int, Int]) = {
-
- // get a tf count for the entire dictionary
- val dictMap = documents.unzip._2.mkString(" ").toLowerCase.split(" ").groupBy(identity).mapValues(_.length)
-
- // create a dictionary with an index for each term
- val dictIndex = dictMap.zipWithIndex.map(x => x._1._1 -> x._2)
-
- val docFrequencyCount = new Array[Int](dictMap.size)
-
- for (token <- dictMap) {
- for (doc <- documents) {
- // parse the string and get a word then increment the df count for that word
- if (doc._2.toLowerCase.split(" ").contains(token._1)) {
- docFrequencyCount(dictIndex(token._1)) += 1
- }
- }
- }
-
- val docFrequencyMap = docFrequencyCount.zipWithIndex.map(x => x._2 -> x._1).toMap
-
- (dictIndex, docFrequencyMap)
- }
-
- def vectorizeDocument(document: String,
- dictionaryMap: Map[String, Int],
- dfMap: Map[Int, Int], weight: TermWeight = new TFIDF): Vector = {
-
- val wordCounts = document.toLowerCase.split(" ").groupBy(identity).mapValues(_.length)
-
- val vec = new RandomAccessSparseVector(dictionaryMap.size)
-
- val totalDFSize = dictionaryMap.size
- val docSize = wordCounts.size
-
- for (word <- wordCounts) {
- val term = word._1
- if (dictionaryMap.contains(term)) {
- val termFreq = word._2
- val dictIndex = dictionaryMap(term)
- val docFreq = dfMap(dictIndex)
- val currentWeight = weight.calculate(termFreq, docFreq.toInt, docSize, totalDFSize.toInt)
- vec(dictIndex)= currentWeight
- }
- }
- vec
- }
-
- test("TF test") {
-
- val (dictionary, dfMap) = createDictionaryAndDfMaps(documents)
-
- val tf: TermWeight = new TF()
-
- val vectorizedDocuments: Matrix = new SparseMatrix(documents.size, dictionary.size)
-
- for (doc <- documents) {
- vectorizedDocuments(doc._1 - 1, ::) := vectorizeDocument(doc._2, dictionary, dfMap, tf)
- }
-
- // corpus:
- // (1, "the first document contains 5 terms"),
- // (2, "document two document contains 4 terms"),
- // (3, "document three three terms"),
- // (4, "each document including this document contain the term document")
-
- // dictonary:
- // (this -> 0, 4 -> 1, three -> 2, document -> 3, two -> 4, term -> 5, 5 -> 6, contain -> 7,
- // each -> 8, first -> 9, terms -> 10, contains -> 11, including -> 12, the -> 13)
-
- // dfMap:
- // (0 -> 1, 5 -> 1, 10 -> 3, 1 -> 1, 6 -> 1, 9 -> 1, 13 -> 2, 2 -> 1, 12 -> 1, 7 -> 1, 3 -> 4,
- // 11 -> 2, 8 -> 1, 4 -> 1)
-
- vectorizedDocuments(0, 0).toInt should be (0)
- vectorizedDocuments(0, 13).toInt should be (1)
- vectorizedDocuments(1, 3).toInt should be (2)
- vectorizedDocuments(3, 3).toInt should be (3)
-
- }
-
-
- test("TFIDF test") {
- val (dictionary, dfMap) = createDictionaryAndDfMaps(documents)
-
- val tfidf: TermWeight = new TFIDF()
-
- val vectorizedDocuments: Matrix = new SparseMatrix(documents.size, dictionary.size)
-
- for (doc <- documents) {
- vectorizedDocuments(doc._1 - 1, ::) := vectorizeDocument(doc._2, dictionary, dfMap, tfidf)
- }
-
- // corpus:
- // (1, "the first document contains 5 terms"),
- // (2, "document two document contains 4 terms"),
- // (3, "document three three terms"),
- // (4, "each document including this document contain the term document")
-
- // dictonary:
- // (this -> 0, 4 -> 1, three -> 2, document -> 3, two -> 4, term -> 5, 5 -> 6, contain -> 7,
- // each -> 8, first -> 9, terms -> 10, contains -> 11, including -> 12, the -> 13)
-
- // dfMap:
- // (0 -> 1, 5 -> 1, 10 -> 3, 1 -> 1, 6 -> 1, 9 -> 1, 13 -> 2, 2 -> 1, 12 -> 1, 7 -> 1, 3 -> 4,
- // 11 -> 2, 8 -> 1, 4 -> 1)
-
- abs(vectorizedDocuments(0, 0) - 0.0) should be < epsilon
- abs(vectorizedDocuments(0, 13) - 2.540445) should be < epsilon
- abs(vectorizedDocuments(1, 3) - 2.870315) should be < epsilon
- abs(vectorizedDocuments(3, 3) - 3.515403) should be < epsilon
- }
-
- test("MLlib TFIDF test") {
- val (dictionary, dfMap) = createDictionaryAndDfMaps(documents)
-
- val tfidf: TermWeight = new MLlibTFIDF()
-
- val vectorizedDocuments: Matrix = new SparseMatrix(documents.size, dictionary.size)
-
- for (doc <- documents) {
- vectorizedDocuments(doc._1 - 1, ::) := vectorizeDocument(doc._2, dictionary, dfMap, tfidf)
- }
-
- // corpus:
- // (1, "the first document contains 5 terms"),
- // (2, "document two document contains 4 terms"),
- // (3, "document three three terms"),
- // (4, "each document including this document contain the term document")
-
- // dictonary:
- // (this -> 0, 4 -> 1, three -> 2, document -> 3, two -> 4, term -> 5, 5 -> 6, contain -> 7,
- // each -> 8, first -> 9, terms -> 10, contains -> 11, including -> 12, the -> 13)
-
- // dfMap:
- // (0 -> 1, 5 -> 1, 10 -> 3, 1 -> 1, 6 -> 1, 9 -> 1, 13 -> 2, 2 -> 1, 12 -> 1, 7 -> 1, 3 -> 4,
- // 11 -> 2, 8 -> 1, 4 -> 1)
-
- abs(vectorizedDocuments(0, 0) - 0.0) should be < epsilon
- abs(vectorizedDocuments(0, 13) - 1.609437) should be < epsilon
- abs(vectorizedDocuments(1, 3) - 2.197224) should be < epsilon
- abs(vectorizedDocuments(3, 3) - 3.295836) should be < epsilon
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/test/DistributedMahoutSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/test/DistributedMahoutSuite.scala b/math-scala/src/test/scala/org/apache/mahout/test/DistributedMahoutSuite.scala
deleted file mode 100644
index 3538991..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/test/DistributedMahoutSuite.scala
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.test
-
-import org.apache.mahout.math.drm.DistributedContext
-import org.scalatest.{Suite, FunSuite, Matchers}
-
-/**
- * Unit tests that use a distributed context to run
- */
-trait DistributedMahoutSuite extends MahoutSuite { this: Suite =>
- protected implicit var mahoutCtx: DistributedContext
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/test/LoggerConfiguration.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/test/LoggerConfiguration.scala b/math-scala/src/test/scala/org/apache/mahout/test/LoggerConfiguration.scala
deleted file mode 100644
index 7a34aa2..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/test/LoggerConfiguration.scala
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.apache.mahout.test
-
-import org.scalatest._
-import org.apache.log4j.{Level, Logger, BasicConfigurator}
-
-trait LoggerConfiguration extends BeforeAndAfterAllConfigMap {
- this: Suite =>
-
- override protected def beforeAll(configMap: ConfigMap): Unit = {
- super.beforeAll(configMap)
- BasicConfigurator.resetConfiguration()
- BasicConfigurator.configure()
- Logger.getRootLogger.setLevel(Level.ERROR)
- Logger.getLogger("org.apache.mahout.math.scalabindings").setLevel(Level.DEBUG)
- }
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala b/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
deleted file mode 100644
index d3b8a38..0000000
--- a/math-scala/src/test/scala/org/apache/mahout/test/MahoutSuite.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.test
-
-import java.io.File
-import org.scalatest._
-import org.apache.mahout.common.RandomUtils
-
-trait MahoutSuite extends BeforeAndAfterEach with LoggerConfiguration with Matchers {
- this: Suite =>
-
- final val TmpDir = "tmp/"
-
- override protected def beforeEach() {
- super.beforeEach()
- RandomUtils.useTestSeed()
- }
-
- override protected def beforeAll(configMap: ConfigMap) {
- super.beforeAll(configMap)
-
- // just in case there is an existing tmp dir clean it before every suite
- deleteDirectory(new File(TmpDir))
- }
-
- override protected def afterEach() {
-
- // clean the tmp dir after every test
- deleteDirectory(new File(TmpDir))
-
- super.afterEach()
- }
-
- /** Delete directory no symlink checking and exceptions are not caught */
- private def deleteDirectory(path: File): Unit = {
- if (path.isDirectory)
- for (files <- path.listFiles) deleteDirectory(files)
- path.delete
- }
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/pom.xml
----------------------------------------------------------------------
diff --git a/math/pom.xml b/math/pom.xml
deleted file mode 100644
index 9855b9d..0000000
--- a/math/pom.xml
+++ /dev/null
@@ -1,256 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- 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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.mahout</groupId>
- <artifactId>mahout</artifactId>
- <version>0.13.1-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>mahout-math</artifactId>
- <name>Mahout Math</name>
- <description>High performance scientific and technical computing data structures and methods,
- mostly based on CERN's
- Colt Java API
- </description>
-
- <packaging>jar</packaging>
-
- <!--<build>-->
- <!--<plugins>-->
- <!--<!– copy jars to top directory, which is MAHOUT_HOME –>-->
- <!--<plugin>-->
- <!--<artifactId>maven-antrun-plugin</artifactId>-->
- <!--<version>1.4</version>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>copy</id>-->
- <!--<phase>package</phase>-->
- <!--<configuration>-->
- <!--<tasks>-->
- <!--<copy file="target/mahout-math-${version}.jar" tofile="../mahout-math-${version}.jar" />-->
- <!--</tasks>-->
- <!--</configuration>-->
- <!--<goals>-->
- <!--<goal>run</goal>-->
- <!--</goals>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
- <!--<plugin>-->
- <!--<groupId>org.apache.mahout</groupId>-->
- <!--<artifactId>mahout-collection-codegen-plugin</artifactId>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<phase>generate-sources</phase>-->
- <!--<goals>-->
- <!--<goal>generate</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<!–<mainExcludes>–>-->
- <!--<!–<mainExclude>**/AbstractBooleanList.java</mainExclude>–>-->
- <!--<!–<mainExclude>**/BooleanArrayList.java</mainExclude>–>-->
- <!--<!–<mainExclude>**/BooleanBufferConsumer.java</mainExclude>–>-->
- <!--<!–</mainExcludes>–>-->
- <!--<!–<testExcludes>–>-->
- <!--<!–<testExclude>**/BooleanArrayListTest.java</testExclude>–>-->
- <!--<!–</testExcludes>–>-->
- <!--<outputDirectory>${project.build.directory}/generated-sources/mahout</outputDirectory>-->
- <!--<testOutputDirectory>${project.build.directory}/generated-test-sources/mahout</testOutputDirectory>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.codehaus.mojo</groupId>-->
- <!--<artifactId>build-helper-maven-plugin</artifactId>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<id>add-source</id>-->
- <!--<phase>generate-sources</phase>-->
- <!--<goals>-->
- <!--<goal>add-source</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<sources>-->
- <!--<source>${project.build.directory}/generated-sources/mahout</source>-->
- <!--</sources>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--<execution>-->
- <!--<id>add-test-source</id>-->
- <!--<phase>generate-sources</phase>-->
- <!--<goals>-->
- <!--<goal>add-test-source</goal>-->
- <!--</goals>-->
- <!--<configuration>-->
- <!--<sources>-->
- <!--<source>${project.build.directory}/generated-test-sources/mahout</source>-->
- <!--</sources>-->
- <!--</configuration>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
-
- <!--<!– create test jar so other modules can reuse the math test utility classes. –>-->
- <!--<plugin>-->
- <!--<groupId>org.apache.maven.plugins</groupId>-->
- <!--<artifactId>maven-jar-plugin</artifactId>-->
- <!--<executions>-->
- <!--<execution>-->
- <!--<goals>-->
- <!--<goal>test-jar</goal>-->
- <!--</goals>-->
- <!--<phase>package</phase>-->
- <!--</execution>-->
- <!--</executions>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<artifactId>maven-javadoc-plugin</artifactId>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<artifactId>maven-source-plugin</artifactId>-->
- <!--</plugin>-->
-
- <!--<plugin>-->
- <!--<groupId>org.apache.maven.plugins</groupId>-->
- <!--<artifactId>maven-remote-resources-plugin</artifactId>-->
- <!--<configuration>-->
- <!--<appendedResourcesDirectory>../src/main/appended-resources</appendedResourcesDirectory>-->
- <!--<resourceBundles>-->
- <!--<resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>-->
- <!--</resourceBundles>-->
- <!--<supplementalModels>-->
- <!--<supplementalModel>supplemental-models.xml</supplementalModel>-->
- <!--</supplementalModels>-->
- <!--</configuration>-->
- <!--</plugin>-->
-
- <!--<!–<plugin>–>-->
- <!--<!–<groupId>org.apache.maven.plugins</groupId>–>-->
- <!--<!–<artifactId>maven-shade-plugin</artifactId>–>-->
- <!--<!–<version>3.0.0</version>–>-->
- <!--<!–<executions>–>-->
- <!--<!–<execution>–>-->
- <!--<!–<phase>package</phase>–>-->
- <!--<!–<goals>–>-->
- <!--<!–<goal>shade</goal>–>-->
- <!--<!–</goals>–>-->
- <!--<!–<configuration>–>-->
- <!--<!–<artifactSet>–>-->
- <!--<!–<includes>–>-->
- <!--<!–<include>it.unimi.dsi:fastutil</include>–>-->
- <!--<!–</includes>–>-->
- <!--<!–</artifactSet>–>-->
- <!--<!–<relocations>–>-->
- <!--<!–<relocation>–>-->
- <!--<!–<pattern>it.unimi.dsi.fastutil</pattern>–>-->
- <!--<!–<shadedPattern>shaded.it.unimi.dsi.fastutil</shadedPattern>–>-->
- <!--<!–</relocation>–>-->
- <!--<!–</relocations>–>-->
- <!--<!–</configuration>–>-->
- <!--<!–</execution>–>-->
- <!--<!–</executions>–>-->
- <!--<!–</plugin>–>-->
- <!--<!– remove jars from top directory on clean –>-->
- <!--<plugin>-->
- <!--<artifactId>maven-clean-plugin</artifactId>-->
- <!--<version>3.0.0</version>-->
- <!--<configuration>-->
- <!--<filesets>-->
- <!--<fileset>-->
- <!--<directory>../</directory>-->
- <!--<includes>-->
- <!--<include>mahout-math*.jar</include>-->
- <!--</includes>-->
- <!--<followSymlinks>false</followSymlinks>-->
- <!--</fileset>-->
- <!--</filesets>-->
- <!--</configuration>-->
- <!--</plugin>-->
- <!--</plugins>-->
- <!--</build>-->
-
- <dependencies>
-
- <!-- 3rd-party -->
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-math3</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
-
- <dependency>
- <groupId>it.unimi.dsi</groupId>
- <artifactId>fastutil</artifactId>
- <version>7.0.12</version>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jcl</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-test-framework</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.carrotsearch.randomizedtesting</groupId>
- <artifactId>randomizedtesting-runner</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.tdunning</groupId>
- <artifactId>t-digest</artifactId>
- <version>3.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/buffer/ValueTypeBufferConsumer.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/buffer/ValueTypeBufferConsumer.java.t b/math/src/main/java-templates/org/apache/mahout/math/buffer/ValueTypeBufferConsumer.java.t
deleted file mode 100644
index 3077dfd..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/buffer/ValueTypeBufferConsumer.java.t
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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.
- */
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-package org.apache.mahout.math.buffer;
-
-import org.apache.mahout.math.list.${valueTypeCap}ArrayList;
-/**
- * Object that can accept a primitive array list of
- * ${valueType} items.
- **/
-public interface ${valueTypeCap}BufferConsumer {
-
- /**
- * Adds all elements of the specified list to the receiver.
- *
- * @param list the list of which all elements shall be added.
- */
- void addAllOf(${valueTypeCap}ArrayList list);
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeObjectProcedure.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeObjectProcedure.java.t b/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeObjectProcedure.java.t
deleted file mode 100644
index 4ecf714..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeObjectProcedure.java.t
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.function;
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-/**
- * Interface that represents a procedure object: a procedure that takes two arguments and does not return a value.
- *
-*/
-public interface ${keyTypeCap}ObjectProcedure<T> {
-
- /**
- * Applies a procedure to two arguments. Optionally can return a boolean flag to inform the object calling the
- * procedure.
- *
- * <p>Example: forEach() methods often use procedure objects. To signal to a forEach() method whether iteration should
- * continue normally or terminate (because for example a matching element has been found), a procedure can return
- * <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
- *
- * @param first first argument passed to the procedure.
- * @param second second argument passed to the procedure.
- * @return a flag to inform the object calling the procedure.
- */
- boolean apply(${keyType} first, T second);
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t b/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t
deleted file mode 100644
index c198353..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeProcedure.java.t
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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.function;
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-/**
- * Interface that represents a procedure object: a procedure that takes a single argument and does not return a value.
- *
- */
-public interface ${keyTypeCap}Procedure {
-
- /**
- * Applies a procedure to an argument. Optionally can return a boolean flag to inform the object calling the
- * procedure.
- *
- * <p>Example: forEach() methods often use procedure objects. To signal to a forEach() method whether iteration should
- * continue normally or terminate (because for example a matching element has been found), a procedure can return
- * <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
- *
- * @param element element passed to the procedure.
- * @return a flag to inform the object calling the procedure.
- */
- boolean apply(${keyType} element);
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeValueTypeProcedure.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeValueTypeProcedure.java.t b/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeValueTypeProcedure.java.t
deleted file mode 100644
index cf7ac22..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/function/KeyTypeValueTypeProcedure.java.t
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.function;
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-/**
- * Interface that represents a procedure object: a procedure that takes two arguments and does not return a value.
- *
- */
-public interface ${keyTypeCap}${valueTypeCap}Procedure {
-
- /**
- * Applies a procedure to two arguments. Optionally can return a boolean flag to inform the object calling the
- * procedure.
- *
- * <p>Example: forEach() methods often use procedure objects. To signal to a forEach() method whether iteration should
- * continue normally or terminate (because for example a matching element has been found), a procedure can return
- * <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
- *
- * @param first first argument passed to the procedure.
- * @param second second argument passed to the procedure.
- * @return a flag to inform the object calling the procedure.
- */
- boolean apply(${keyType} first, ${valueType} second);
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t b/math/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t
deleted file mode 100644
index e3576a8..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/function/ObjectValueTypeProcedure.java.t
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * 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.function;
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-/**
- * Interface that represents a procedure object: a procedure that takes two arguments and does not return a value.
- *
- */
-public interface Object${valueTypeCap}Procedure<T> {
-
- /**
- * Applies a procedure to two arguments. Optionally can return a boolean flag to inform the object calling the
- * procedure.
- *
- * <p>Example: forEach() methods often use procedure objects. To signal to a forEach() method whether iteration should
- * continue normally or terminate (because for example a matching element has been found), a procedure can return
- * <tt>false</tt> to indicate termination and <tt>true</tt> to indicate continuation.
- *
- * @param first first argument passed to the procedure.
- * @param second second argument passed to the procedure.
- * @return a flag to inform the object calling the procedure.
- */
- boolean apply(T first, ${valueType} second);
-}
http://git-wip-us.apache.org/repos/asf/mahout/blob/e0573de3/math/src/main/java-templates/org/apache/mahout/math/function/ValueTypeComparator.java.t
----------------------------------------------------------------------
diff --git a/math/src/main/java-templates/org/apache/mahout/math/function/ValueTypeComparator.java.t b/math/src/main/java-templates/org/apache/mahout/math/function/ValueTypeComparator.java.t
deleted file mode 100644
index 9f27905..0000000
--- a/math/src/main/java-templates/org/apache/mahout/math/function/ValueTypeComparator.java.t
+++ /dev/null
@@ -1,81 +0,0 @@
-/**
- * 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.function;
-
-/*
-Copyright 1999 CERN - European Organization for Nuclear Research.
-Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose
-is hereby granted without fee, provided that the above copyright notice appear in all copies and
-that both that copyright notice and this permission notice appear in supporting documentation.
-CERN makes no representations about the suitability of this software for any purpose.
-It is provided "as is" without expressed or implied warranty.
-*/
-
-/**
- * A comparison function which imposes a <i>total ordering</i> on some collection of elements. Comparators can be
- * passed to a sort method (such as <tt>org.apache.mahout.math.Sorting.quickSort</tt>) to allow precise control over
- * the sort order.<p>
- *
- * Note: It is generally a good idea for comparators to implement <tt>java.io.Serializable</tt>, as they may be used as
- * ordering methods in serializable data structures. In order for the data structure to serialize successfully, the
- * comparator (if provided) must implement <tt>Serializable</tt>.<p>
- *
- * @see java.util.Comparator
- * @see org.apache.mahout.math.Sorting
- */
-public interface ${valueTypeCap}Comparator {
-
- /**
- * Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.<p>
- *
- * The implementor must ensure that <tt>sgn(compare(x, y)) == -sgn(compare(y, x))</tt> for all <tt>x</tt> and
- * <tt>y</tt>. (This implies that <tt>compare(x, y)</tt> must throw an exception if and only if <tt>compare(y,
- * x)</tt> throws an exception.)<p>
- *
- * The implementor must also ensure that the relation is transitive: <tt>((compare(x, y)>0) && (compare(y,
- * z)>0))</tt> implies <tt>compare(x, z)>0</tt>.<p>
- *
- * Finally, the implementer must ensure that <tt>compare(x, y)==0</tt> implies that <tt>sgn(compare(x,
- * z))==sgn(compare(y, z))</tt> for all <tt>z</tt>.<p>
- *
- * @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater
- * than the second.
- */
- int compare(${valueType} o1, ${valueType} o2);
-
- /**
- * Indicates whether some other object is "equal to" this Comparator. This method must obey the general
- * contract of <tt>Object.equals(Object)</tt>. Additionally, this method can return <tt>true</tt> <i>only</i> if the
- * specified Object is also a comparator and it imposes the same ordering as this comparator. Thus,
- * <code>comp1.equals(comp2)</code> implies that <tt>sgn(comp1.compare(o1, o2))==sgn(comp2.compare(o1, o2))</tt> for
- * every element <tt>o1</tt> and <tt>o2</tt>.<p>
- *
- * Note that it is <i>always</i> safe <i>not</i> to override <tt>Object.equals(Object)</tt>. However, overriding this
- * method may, in some cases, improve performance by allowing programs to determine that two distinct Comparators
- * impose the same order.
- *
- * @param obj the reference object with which to compare.
- * @return <code>true</code> only if the specified object is also a comparator and it imposes the same ordering as
- * this comparator.
- * @see Object#hashCode()
- */
- boolean equals(Object obj);
-}