lindong28 commented on a change in pull request #24:
URL: https://github.com/apache/flink-ml/pull/24#discussion_r768414729
##########
File path: flink-ml-core/src/main/java/org/apache/flink/ml/linalg/BLAS.java
##########
@@ -26,9 +26,91 @@
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 or y = alpha * (A^T) * x + beta * y.
+ *
+ * @param alpha alpha.
+ * @param A m x n matrix A.
+ * @param transA Whether transposes matrix y before multiply.
+ * @param x dense vector with size n.
+ * @param beta beta.
+ * @param y dense vector with size m.
+ */
+ public static void gemv(
+ double alpha,
+ DenseMatrix A,
Review comment:
It looks like the latest PR has been updated to use `matA`, which sounds
good to me.
Could you update the Java doc to make sure it is consistent with the actual
function signature?
And it might be useful to keep the comment open (unresolved) if it is
unclear how we plan to solve it.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]