mahout-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlyubi...@apache.org
Subject git commit: (NOJIRA) small tweaks:
Date Thu, 21 Aug 2014 22:30:47 GMT
Repository: mahout
Updated Branches:
  refs/heads/master 85a098a36 -> 656225c67


(NOJIRA) small tweaks:

(1) enabling A.diagv = syntax.
(2) removing redundant implicit from MatrixOps.
(3) renaming pom module name for math scala bindings.


Project: http://git-wip-us.apache.org/repos/asf/mahout/repo
Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/656225c6
Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/656225c6
Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/656225c6

Branch: refs/heads/master
Commit: 656225c67fb5cc5d232ac77a4201ecd2f1136805
Parents: 85a098a
Author: Dmitriy Lyubimov <dlyubimov@apache.org>
Authored: Thu Aug 21 15:28:52 2014 -0700
Committer: Dmitriy Lyubimov <dlyubimov@apache.org>
Committed: Thu Aug 21 15:28:52 2014 -0700

----------------------------------------------------------------------
 math-scala/pom.xml                              |  2 +-
 .../mahout/math/scalabindings/MatrixOps.scala   | 20 ++++++++++++++------
 .../mahout/math/scalabindings/package.scala     |  4 ++--
 .../math/scalabindings/MatrixOpsSuite.scala     |  2 +-
 .../math/scalabindings/VectorOpsSuite.scala     |  2 +-
 5 files changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mahout/blob/656225c6/math-scala/pom.xml
----------------------------------------------------------------------
diff --git a/math-scala/pom.xml b/math-scala/pom.xml
index 2a348eb..b2fea6b 100644
--- a/math-scala/pom.xml
+++ b/math-scala/pom.xml
@@ -28,7 +28,7 @@
   </parent>
 
   <artifactId>mahout-math-scala_2.10</artifactId>
-  <name>Mahout Math/Scala wrappers</name>
+  <name>Mahout Math Scala bindings</name>
   <description>High performance scientific and technical computing data structures
and methods,
     mostly based on CERN's
     Colt Java API

http://git-wip-us.apache.org/repos/asf/mahout/blob/656225c6/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/MatrixOps.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/MatrixOps.scala
b/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/MatrixOps.scala
index a94d2a8..732a98a 100644
--- a/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/MatrixOps.scala
+++ b/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/MatrixOps.scala
@@ -26,6 +26,9 @@ class MatrixOps(val m: Matrix) {
 
   import MatrixOps._
 
+  // We need this for some functions below (but it would screw some functions above)
+  import RLikeOps.v2vOps
+
   def nrow = m.rowSize()
 
   def ncol = m.columnSize()
@@ -166,9 +169,6 @@ class MatrixOps(val m: Matrix) {
   def isFullRank: Boolean =
     new QRDecomposition(if (nrow < ncol) m t else m cloned).hasFullRank
 
-  // We need this for some functions below (but it would screw some functions above)
-  import RLikeOps.v2vOps
-
   def colSums() = m.aggregateColumns(vectorSumFunc)
 
   def rowSums() = m.aggregateRows(vectorSumFunc)
@@ -177,15 +177,23 @@ class MatrixOps(val m: Matrix) {
 
   def rowMeans() = if (m.ncol == 0) rowSums() else rowSums() /= m.ncol
 
-  def diagv = m.viewDiagonal()
+  /* Diagonal */
+  def diagv: Vector = m.viewDiagonal()
+
+  /* Diagonal assignment */
+  def diagv_=(that: Vector) = diagv := that
+
+  /* Diagonal assignment */
+  def diagv_=(that: Double) = diagv := that
 
   def numNonZeroElementsPerColumn() = m.aggregateColumns(vectorCountNonZeroElementsFunc)
 }
 
 object MatrixOps {
-  implicit def m2ops(m: Matrix): MatrixOps = new MatrixOps(m)
 
-  implicit def v2ops(v: Vector): VectorOps = new VectorOps(v)
+  import RLikeOps.v2vOps
+
+  implicit def m2ops(m: Matrix): MatrixOps = new MatrixOps(m)
 
   private def vectorSumFunc = new VectorFunction {
     def apply(f: Vector): Double = f.sum

http://git-wip-us.apache.org/repos/asf/mahout/blob/656225c6/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/package.scala
----------------------------------------------------------------------
diff --git a/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/package.scala
b/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/package.scala
index 43db95e..36f5103 100644
--- a/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/package.scala
+++ b/math-scala/src/main/scala/org/apache/mahout/math/scalabindings/package.scala
@@ -121,7 +121,7 @@ package object scalabindings {
    * @return
    */
   def dense[R](rows: R*): DenseMatrix = {
-    import MatrixOps._
+    import RLikeOps._
     val data = for (r <- rows) yield {
       r match {
         case n: Number => Array(n.doubleValue())
@@ -288,7 +288,7 @@ package object scalabindings {
    * @return (x)
    */
   def solve(a: Matrix, b: Vector): Vector = {
-    import MatrixOps._
+    import RLikeOps._
     val x = solve(a, b.toColMatrix)
     x(::, 0)
   }

http://git-wip-us.apache.org/repos/asf/mahout/blob/656225c6/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
index c6fccbc..5be6ca8 100644
--- 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
@@ -18,7 +18,7 @@
 package org.apache.mahout.math.scalabindings
 
 import org.scalatest.{Matchers, FunSuite}
-import MatrixOps._
+import RLikeOps._
 import scala._
 import org.apache.mahout.test.MahoutSuite
 import org.apache.mahout.math.{RandomAccessSparseVector, SequentialAccessSparseVector, Matrices}

http://git-wip-us.apache.org/repos/asf/mahout/blob/656225c6/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
index ae2d3a5..fda2038 100644
--- 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
@@ -19,7 +19,7 @@ package org.apache.mahout.math.scalabindings
 
 import org.scalatest.FunSuite
 import org.apache.mahout.math.{RandomAccessSparseVector, Vector}
-import MatrixOps._
+import RLikeOps._
 import org.apache.mahout.test.MahoutSuite
 
 /** VectorOps Suite */


Mime
View raw message