convertFromZTilde method Null safety

void convertFromZTilde(
  1. Model15<ProgramOperation> m
)

Convert from ZTilde to ZP

from: X -YC to X Y XC Y

where XC and YC are ignored and discarded.

Implementation

void convertFromZTilde(Model15 m) {
  final rows = this.rows;
  final columns = this.columns;
  if (rows % 2 != 0 || columns % 2 != 0) {
    throw CalculatorError(11);
  }
  final newColumns = columns ~/ 2;
  isLU = false;

  // Copy X:
  for (int r = 0; r < rows ~/ 2; r++) {
    for (int c = 0; c < newColumns; c++) {
      final x = get(r, c);
      _values[r * newColumns + c] = x;
    }
  }
  // Copy Y:
  for (int r = rows ~/ 2; r < rows; r++) {
    for (int c = 0; c < newColumns; c++) {
      final y = get(r, c);
      _values[r * newColumns + c] = y;
    }
  }

  resize(m, rows, newColumns);
}