zhipeng93 commented on a change in pull request #73:
URL: https://github.com/apache/flink-ml/pull/73#discussion_r840204804



##########
File path: flink-ml-core/src/main/java/org/apache/flink/ml/linalg/BLAS.java
##########
@@ -89,4 +111,56 @@ public static void gemv(
                 y.values,
                 1);
     }
+
+    private static void axpy(double a, DenseVector x, DenseVector y) {
+        JAVA_BLAS.daxpy(x.size(), a, x.values, 1, y.values, 1);
+    }
+
+    private static void axpy(double a, SparseVector x, DenseVector y) {
+        for (int i = 0; i < x.indices.length; i++) {
+            int index = x.indices[i];
+            y.values[index] += a * x.values[i];
+        }
+    }
+
+    private static void hDot(SparseVector x, SparseVector y) {
+        int idx = 0;
+        int idy = 0;
+        while (idx < x.indices.length && idy < y.indices.length) {
+            int indexX = x.indices[idx];
+            while (idy < y.indices.length && y.indices[idy] < indexX) {
+                y.values[idy] = 0;
+                idy++;
+            }
+            if (idy < y.indices.length && y.indices[idy] == indexX) {
+                y.values[idy] *= x.values[idx];
+                idy++;
+            }
+            idx++;
+        }
+    }
+
+    private static void hDot(SparseVector x, DenseVector y) {
+        int idx = 0;
+        for (int i = 0; i < y.size(); i++) {
+            if (x.indices[idx] == i) {

Review comment:
       Thanks for pointing this out. It is fixed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to