getCompressionIntervals method
array
= array (e.g. to be compressed)
nIntervals
= size of compressed array
ixFirst
= first index in array to be considered
Returns the computed interval indices with respect to array
.
The size of the result is nIntervals
.
Implementation
static List<int> getCompressionIntervals(
Float64List array, int nIntervals, int ixFirst) {
List<int> newxValuesIndices = [];
double deltaIx = array.length / nIntervals;
int curix;
for (int i = 0; i < nIntervals; i++) {
curix = (i * deltaIx).round();
newxValuesIndices.add(curix + ixFirst);
if (curix >= array.length) break;
}
if (newxValuesIndices.length < nIntervals) {
newxValuesIndices.add(array.length - 1 + ixFirst);
} else {
newxValuesIndices[newxValuesIndices.length - 1] =
array.length - 1 + ixFirst;
}
// print("===>$nIntervals = $ixFirst = $newxValuesIndices");
return newxValuesIndices;
}