weibozhao commented on a change in pull request #24:
URL: https://github.com/apache/flink-ml/pull/24#discussion_r766575765



##########
File path: flink-ml-core/src/main/java/org/apache/flink/ml/linalg/BLAS.java
##########
@@ -22,13 +22,84 @@
 
 /** A utility class that provides BLAS routines over matrices and vectors. */
 public class BLAS {
+
     /** For level-1 function dspmv, use javaBLAS for better performance. */
     private static final dev.ludovic.netlib.BLAS JAVA_BLAS =
             dev.ludovic.netlib.JavaBLAS.getInstance();
 
-    /** y += a * x . */
+    /**
+     * \sum_i |x_i| .
+     *
+     * @param x x
+     * @return \sum_i |x_i|
+     */
+    public static double asum(DenseVector x) {
+        return JAVA_BLAS.dasum(x.size(), x.values, 0, 1);
+    }
+
+    /**
+     * y += a * x .
+     *
+     * @param a a
+     * @param x x
+     * @param y y
+     */
     public static void axpy(double a, DenseVector x, DenseVector y) {
         Preconditions.checkArgument(x.size() == y.size(), "Vector size 
mismatched.");
         JAVA_BLAS.daxpy(x.size(), a, x.values, 1, y.values, 1);
     }
+
+    /**
+     * x \cdot y .
+     *
+     * @param x x
+     * @param y y
+     * @return x \cdot y
+     */
+    public static double dot(DenseVector x, DenseVector y) {
+        Preconditions.checkArgument(x.size() == y.size(), "Vector size 
mismatched.");
+        return JAVA_BLAS.ddot(x.size(), x.values, 1, y.values, 1);
+    }
+
+    /**
+     * \sqrt(\sum_i x_i * x_i) .
+     *
+     * @param x x
+     * @return \sqrt(\sum_i x_i * x_i)
+     */
+    public static double norm2(DenseVector x) {
+        return JAVA_BLAS.dnrm2(x.size(), x.values, 1);
+    }
+
+    /**
+     * x = x * a .
+     *
+     * @param a a
+     * @param x x
+     */
+    public static void scal(double a, DenseVector x) {
+        JAVA_BLAS.dscal(x.size(), a, x.values, 1);
+    }
+
+    /**
+     * y := alpha * A * x + beta * y.
+     *
+     * @param matA m x n matrix A.
+     * @param transA transform matrix or not.
+     * @param x dense vector with size n.
+     * @param y dense vector with size m.
+     */
+    public static void gemv(

Review comment:
       OK

##########
File path: flink-ml-core/src/main/java/org/apache/flink/ml/linalg/BLAS.java
##########
@@ -22,13 +22,84 @@
 
 /** A utility class that provides BLAS routines over matrices and vectors. */
 public class BLAS {
+
     /** For level-1 function dspmv, use javaBLAS for better performance. */
     private static final dev.ludovic.netlib.BLAS JAVA_BLAS =
             dev.ludovic.netlib.JavaBLAS.getInstance();
 
-    /** y += a * x . */
+    /**
+     * \sum_i |x_i| .
+     *
+     * @param x x
+     * @return \sum_i |x_i|
+     */
+    public static double asum(DenseVector x) {
+        return JAVA_BLAS.dasum(x.size(), x.values, 0, 1);
+    }
+
+    /**
+     * y += a * x .
+     *
+     * @param a a
+     * @param x x
+     * @param y y
+     */
     public static void axpy(double a, DenseVector x, DenseVector y) {
         Preconditions.checkArgument(x.size() == y.size(), "Vector size 
mismatched.");
         JAVA_BLAS.daxpy(x.size(), a, x.values, 1, y.values, 1);
     }
+
+    /**
+     * x \cdot y .
+     *
+     * @param x x
+     * @param y y
+     * @return x \cdot y
+     */
+    public static double dot(DenseVector x, DenseVector y) {
+        Preconditions.checkArgument(x.size() == y.size(), "Vector size 
mismatched.");
+        return JAVA_BLAS.ddot(x.size(), x.values, 1, y.values, 1);
+    }
+
+    /**
+     * \sqrt(\sum_i x_i * x_i) .
+     *
+     * @param x x
+     * @return \sqrt(\sum_i x_i * x_i)
+     */
+    public static double norm2(DenseVector x) {
+        return JAVA_BLAS.dnrm2(x.size(), x.values, 1);
+    }
+
+    /**
+     * x = x * a .
+     *
+     * @param a a
+     * @param x x
+     */
+    public static void scal(double a, DenseVector x) {
+        JAVA_BLAS.dscal(x.size(), a, x.values, 1);
+    }
+
+    /**
+     * y := alpha * A * x + beta * y.
+     *
+     * @param matA m x n matrix A.
+     * @param transA transform matrix or not.
+     * @param x dense vector with size n.
+     * @param y dense vector with size m.
+     */
+    public static void gemv(
+            double alpha,
+            DenseMatrix matA,
+            boolean transA,
+            DenseVector x,
+            double beta,
+            DenseVector y) {
+        final int m = matA.numRows();

Review comment:
       OK




-- 
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