int rowStartRegion = getMatrixRegion(row, 0);
int rowEndRegion = getMatrixRegion(row + 1, 0);
double[] rowVal = new double[cols];
if (rowStartRegion == rowEndRegion) {
int rowStartIndex = getRegionOffset(row, 0);
DoubleBuffer region = matrixRegions[rowStartRegion];
for (int col = 0; col < cols; ++col)
rowVal[col] = region.get(col + rowStartIndex);
}
else {
DoubleBuffer firstRegion = matrixRegions[rowStartRegion];
DoubleBuffer secondRegion = matrixRegions[rowEndRegion];
int rowStartIndex = getRegionOffset(row, 0);
int rowOffset = 0;
for (; rowStartIndex + rowOffset < MAX_ELEMENTS_PER_REGION;
++rowOffset) {
rowVal[rowOffset] = firstRegion.get(rowOffset + rowStartIndex);
}
// Fill from the second region
for (int i = 0; rowOffset < rowVal.length; ++i, ++rowOffset)
rowVal[rowOffset] = secondRegion.get(i);
}
return rowVal;
}