ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [7/9] ignite git commit: IGNITE-6328: Fixed compilation of ML examples.
Date Tue, 12 Sep 2017 11:27:16 GMT
IGNITE-6328: Fixed compilation of ML examples.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/25f8c573
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/25f8c573
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/25f8c573

Branch: refs/heads/ignite-6149
Commit: 25f8c573b291f92c9779ca9146fb5af3ab116987
Parents: d9481b5
Author: YuriBabak <y.chief@gmail.com>
Authored: Mon Sep 11 16:01:50 2017 +0300
Committer: Igor Sapego <isapego@gridgain.com>
Committed: Mon Sep 11 16:01:50 2017 +0300

----------------------------------------------------------------------
 .../ml/math/matrix/ExampleMatrixStorage.java         | 12 +++++++++++-
 .../regression/DistributedRegressionExample.java     |  2 +-
 .../org/apache/ignite/ml/math/util/MatrixUtil.java   | 15 +++++++++++++--
 3 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/25f8c573/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
index 1ccb2e2..542fbdc 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/matrix/ExampleMatrixStorage.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.util.Arrays;
-
 import org.apache.ignite.ml.math.MatrixStorage;
 import org.apache.ignite.ml.math.StorageConstants;
 import org.apache.ignite.ml.math.impls.storage.matrix.ArrayMatrixStorage;
@@ -114,6 +113,17 @@ class ExampleMatrixStorage implements MatrixStorage {
     }
 
     /** {@inheritDoc} */
+    @Override public int storageMode() {
+        // This value indicate that we store matrix data by rows.
+        return StorageConstants.ROW_STORAGE_MODE;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int accessMode() {
+        return StorageConstants.RANDOM_ACCESS_MODE;
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean isArrayBased() {
         return true;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f8c573/examples/src/main/ml/org/apache/ignite/examples/ml/math/regression/DistributedRegressionExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/ml/org/apache/ignite/examples/ml/math/regression/DistributedRegressionExample.java
b/examples/src/main/ml/org/apache/ignite/examples/ml/math/regression/DistributedRegressionExample.java
index 8e68522..de2c541 100644
--- a/examples/src/main/ml/org/apache/ignite/examples/ml/math/regression/DistributedRegressionExample.java
+++ b/examples/src/main/ml/org/apache/ignite/examples/ml/math/regression/DistributedRegressionExample.java
@@ -30,7 +30,7 @@ import org.apache.ignite.thread.IgniteThread;
 /**
  * Run linear regression over distributed matrix.
  *
- * TODO: Currently works only in local mode.
+ * TODO: IGNITE-6222, Currently works only in local mode.
  *
  * @see OLSMultipleLinearRegression
  */

http://git-wip-us.apache.org/repos/asf/ignite/blob/25f8c573/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java b/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
index 44c5868..c0a57d7 100644
--- a/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
+++ b/modules/ml/src/main/java/org/apache/ignite/ml/math/util/MatrixUtil.java
@@ -27,6 +27,8 @@ import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.matrix.MatrixView;
 import org.apache.ignite.ml.math.impls.matrix.PivotedMatrixView;
 import org.apache.ignite.ml.math.impls.matrix.RandomMatrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseBlockDistributedMatrix;
+import org.apache.ignite.ml.math.impls.matrix.SparseDistributedMatrix;
 import org.apache.ignite.ml.math.impls.matrix.SparseLocalOnHeapMatrix;
 import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
 
@@ -69,7 +71,7 @@ public class MatrixUtil {
      * @return Like matrix.
      */
     public static Matrix like(Matrix matrix, int rows, int cols) {
-        if (isCopyLikeSupport(matrix))
+        if (isCopyLikeSupport(matrix) || isDistributed(matrix))
             return new DenseLocalOnHeapMatrix(rows, cols);
         else
             return matrix.like(rows, cols);
@@ -83,13 +85,22 @@ public class MatrixUtil {
      * @return Like vector.
      */
     public static Vector likeVector(Matrix matrix, int crd) {
-        if (isCopyLikeSupport(matrix))
+        if (isCopyLikeSupport(matrix) || isDistributed(matrix))
             return new DenseLocalOnHeapVector(crd);
         else
             return matrix.likeVector(crd);
     }
 
     /**
+     * Check if a given matrix is distributed.
+     *
+     * @param matrix Matrix for like.
+     */
+    private static boolean isDistributed(Matrix matrix) {
+        return matrix instanceof SparseDistributedMatrix || matrix instanceof SparseBlockDistributedMatrix;
+    }
+
+    /**
      * Create the like vector with read-only matrices support.
      *
      * @param matrix Matrix for like.


Mime
View raw message