Mancer1 commented on code in PR #2560:
URL: https://github.com/apache/systemds/pull/2560#discussion_r3770590536


##########
src/main/java/org/apache/sysds/runtime/compress/colgroup/ColGroupFactory.java:
##########
@@ -1078,6 +1083,46 @@ private static AColGroup 
compressLinearFunctional(IColIndex colIndexes, MatrixBl
                return ColGroupLinearFunctional.create(colIndexes, 
coefficients, numRows);
        }
 
+       /**
+        * This method is the entry point to compress a matrix with piecewise 
linear compression The first method uses a
+        * segmented least squares with dynamic programming to compress the 
columns The second method uses a successive
+        * compression method, which compares each values in linear time and 
checks if the targetloss exceeded
+        *
+        * @param colIndexes the column indices to compress
+        * @param in         the input Matrixblock containing the data
+        * @param cs         compression settings to define the target loss, 
which should be considered
+        * @return a piecewise linear compressed column group
+        */
+
+       public static AColGroup compressPiecewiseLinearFunctional(IColIndex 
colIndexes, MatrixBlock in,
+               CompressionSettings cs) {
+
+               final int numRows = in.getNumRows();
+               final int numCols = colIndexes.size();
+               int[][] breakpointsPerCol = new int[numCols][];
+               double[][] slopesPerCol = new double[numCols][];
+               double[][] interceptsPerCol = new double[numCols][];
+
+               for(int col = 0; col < numCols; col++) {
+                       final int colIdx = colIndexes.get(col);
+                       double[] column = PiecewiseLinearUtils.getColumn(in, 
colIdx);
+                       PiecewiseLinearUtils.SegmentedRegression fit = 
PiecewiseLinearUtils
+                               .compressSuccessivePiecewiseLinear(column, cs);
+                       breakpointsPerCol[col] = fit.getBreakpoints();
+                       interceptsPerCol[col] = fit.getIntercepts();
+                       slopesPerCol[col] = fit.getSlopes();
+
+               }
+               return ColGroupPiecewiseLinearCompressed.create(colIndexes, 
breakpointsPerCol, slopesPerCol, interceptsPerCol,
+                       numRows);
+
+       }

Review Comment:
   Done. Just need Tests for coverage



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

Reply via email to