getRow method

Float64List getRow (Float64List array, int row, int nrows)

Considers array as a two-dimensional array with nrows rows. The rows, when appended to each other in sequence, are building up array. Returns a new array consisting of the row row whose length will be (array.length / nrows). Returns null if row outside range. Conditions: row >= 0. If array.length cannot be divided by nrows without a remainder, the repective part of array can't be obtained. array will remain unmodified.

Implementation

static Float64List getRow(Float64List array, int row, int nrows) {
  if (row < 0 || row >= nrows) return null;
  int rowLength = array.length ~/ nrows;
  Float64List result = new Float64List(rowLength);
  for (int i = 0; i < rowLength; i++) {
    result[i] = array[row * rowLength + i];
  }
  return result;
}