Repository: mahout Updated Branches: refs/heads/master 11046fb52 -> 907781bb8
MAHOUT-1571: Functional Views are not serialized as dense/sparse correctly This closes apache/mahout#9 Squashed commit of the following: commit 584e2e31e2ac23f75bec0a04e8a7168b8d74577b Author: Dmitriy Lyubimov <[email protected]> Date: Tue Jun 10 10:46:17 2014 -0700 Adding test commit ef271380e16192b55c31c7b219195d6982587206 Author: Dmitriy Lyubimov <[email protected]> Date: Wed Jun 4 14:43:24 2014 -0700 initial fix (?) Project: http://git-wip-us.apache.org/repos/asf/mahout/repo Commit: http://git-wip-us.apache.org/repos/asf/mahout/commit/907781bb Tree: http://git-wip-us.apache.org/repos/asf/mahout/tree/907781bb Diff: http://git-wip-us.apache.org/repos/asf/mahout/diff/907781bb Branch: refs/heads/master Commit: 907781bb856b47cb7b180484c6d4b9f55a6df038 Parents: 11046fb Author: Dmitriy Lyubimov <[email protected]> Authored: Tue Jun 10 10:48:55 2014 -0700 Committer: Dmitriy Lyubimov <[email protected]> Committed: Tue Jun 10 10:48:55 2014 -0700 ---------------------------------------------------------------------- CHANGELOG | 2 ++ .../apache/mahout/math/FunctionalMatrixView.java | 8 ++++++++ .../java/org/apache/mahout/math/MatricesTest.java | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mahout/blob/907781bb/CHANGELOG ---------------------------------------------------------------------- diff --git a/CHANGELOG b/CHANGELOG index 3b2e61b..2e174c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,8 @@ Mahout Change Log Release 1.0 - unreleased + MAHOUT-1571: Functional Views are not serialized as dense/sparse correctly (dlyubimov) + MAHOUT-1566: (Experimental) Regular ALS factorizer with conversion tests, optimizer enhancements and bug fixes (dlyubimov) MAHOUT-1537: Minor fixes to spark-shell (Anand Avati via dlyubimov) http://git-wip-us.apache.org/repos/asf/mahout/blob/907781bb/math/src/main/java/org/apache/mahout/math/FunctionalMatrixView.java ---------------------------------------------------------------------- diff --git a/math/src/main/java/org/apache/mahout/math/FunctionalMatrixView.java b/math/src/main/java/org/apache/mahout/math/FunctionalMatrixView.java index e2c8418..90ad937 100644 --- a/math/src/main/java/org/apache/mahout/math/FunctionalMatrixView.java +++ b/math/src/main/java/org/apache/mahout/math/FunctionalMatrixView.java @@ -77,5 +77,13 @@ class FunctionalMatrixView extends AbstractMatrix { throw new UnsupportedOperationException("Assignment to a matrix view not supported"); } + @Override + public Vector viewRow(int row) { + return new MatrixVectorView(this, row, 0, 0, 1, denseLike); + } + @Override + public Vector viewColumn(int column) { + return new MatrixVectorView(this, 0, column, 1, 0, denseLike); + } } http://git-wip-us.apache.org/repos/asf/mahout/blob/907781bb/math/src/test/java/org/apache/mahout/math/MatricesTest.java ---------------------------------------------------------------------- diff --git a/math/src/test/java/org/apache/mahout/math/MatricesTest.java b/math/src/test/java/org/apache/mahout/math/MatricesTest.java index 010f658..1b6169e 100644 --- a/math/src/test/java/org/apache/mahout/math/MatricesTest.java +++ b/math/src/test/java/org/apache/mahout/math/MatricesTest.java @@ -60,6 +60,23 @@ public class MatricesTest extends MahoutTestCase { } @Test + public void testViewDenseSparseReporting() { + Matrix m = new SparseMatrix(1000, 1000); + m.set(1, 1, 33.0); + Matrix mt = Matrices.transposedView(m); + + assertTrue(!mt.viewColumn(0).isDense()); + assertTrue(!mt.viewRow(0).isDense()); + + m = new DenseMatrix(10,10); + m.set(1, 1, 33.0); + mt = Matrices.transposedView(m); + + assertTrue(mt.viewColumn(0).isDense()); + assertTrue(mt.viewRow(0).isDense()); + } + + @Test public void testUniformView() { Matrix m1 = Matrices.uniformView(5, 6, 1234); Matrix m2 = Matrices.uniformView(5, 6, 1234);
