Transpiled version (13569L) is out of date.
sclass CompressToInterpolatedDoubleArray { // raw data to compress (integers) int[] data; // output InterpolatedDoubleArray result; // options settable double slopeTolerance = 0.01; // internal new IntBuffer indices; new DoubleBuffer values; *(int[] *data) {} InterpolatedDoubleArray get() { int iData = 0; while (iData < data.length) { int startValue = data[iData]; // possible range of actual floating point starting value DoubleRange startValueRange = doubleRange(startValue-0.5, startValue+0.5); // see how far the straight line goes from iData DoubleRange totalSlopeRange = null; int jData; // our straight line ends at jData-1 for (jData = iData+1; jData < data.length; jData++) { double x = data[jData], h = jData-iData; // possible range of actual floating point value DoubleRange xRange = doubleRange(x-0.5, x+0.5); // most generous range for possible slope depending // on possible floating point values at start and end DoubleRange slopeRange = doubleRange( (xRange.start-startValueRange.end)/h, (xRange.end-startValueRange.start)/h); // grow range a little to avoid size 0 ranges slopeRange = growRange(slopeTolerance, slopeRange); //printVars(+iData, +jData, +slopeRange, +totalSlopeRange); if (totalSlopeRange == null) totalSlopeRange = slopeRange; else { slopeRange = intersectRanges(slopeRange, totalSlopeRange); if (empty(slopeRange)) break; else totalSlopeRange = slopeRange; } } indices.add(iData); values.add(data[iData]); iData = max(iData+1, jData-1); } ret result = new InterpolatedDoubleArray(indices.toArrayNonNull(), values.toArrayNonNull()); } }
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
Snippet ID: | #1035702 |
Snippet name: | CompressToInterpolatedDoubleArray |
Eternal ID of this version: | #1035702/12 |
Text MD5: | f3d50df57f486f8da9f9d281831aa712 |
Author: | stefan |
Category: | javax / geometric compression |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-07-11 23:01:01 |
Source code size: | 1970 bytes / 59 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 151 / 243 |
Version history: | 11 change(s) |
Referenced in: | [show references] |