zhipeng93 commented on code in PR #110:
URL: https://github.com/apache/flink-ml/pull/110#discussion_r902112959
##########
flink-ml-core/src/main/java/org/apache/flink/ml/linalg/BLAS.java:
##########
@@ -113,11 +113,22 @@ private static double dot(SparseVector x, SparseVector y)
{
return dotValue;
}
+ public static double norm2(Vector x) {
+ if (x instanceof DenseVector) {
+ return norm2((DenseVector) x);
+ }
+ return norm2((SparseVector) x);
+ }
+
/** \sqrt(\sum_i x_i * x_i) . */
public static double norm2(DenseVector x) {
return JAVA_BLAS.dnrm2(x.size(), x.values, 1);
}
+ public static double norm2(SparseVector x) {
Review Comment:
nits: norm2(SparseVector) and norm2(DenseVector) could be private.
##########
flink-ml-core/src/main/java/org/apache/flink/ml/linalg/typeinfo/DenseVectorSerializer.java:
##########
@@ -84,7 +84,7 @@ public void serialize(DenseVector vector, DataOutputView
target) throws IOExcept
target.writeInt(len);
for (int i = 0; i < len; i++) {
- Bits.putDouble(buf, i << 3, vector.values[i]);
+ Bits.putDouble(buf, (i & 127) << 3, vector.values[i]);
Review Comment:
nit: could you update also the source.read() -> source.readFully() in
Line#107?
--
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]