convertToZTilde method Null safety

void convertToZTilde(
  1. Model15<ProgramOperation> m
)

Convert from ZP form to ZTilde, that is,

from:   X      to     X    -Y
        Y             Y     X

Implementation

void convertToZTilde(Model15 m) {
  final rows = this.rows;
  if (rows % 2 != 0) {
    throw CalculatorError(11);
  }
  final oldColumns = this.columns;
  final columns = oldColumns * 2;
  resize(m, rows, columns);
  isLU = false;
  // Copy Y:
  for (int r = rows ~/ 2; r < rows; r++) {
    for (int c = 0; c < oldColumns; c++) {
      final y = _values[r * oldColumns + c];
      set(r, c, y);
    }
  }
  // Copy X into both locations:
  for (int r = rows ~/ 2 - 1; r >= 0; r--) {
    for (int c = oldColumns - 1; c >= 0; c--) {
      final x = _values[r * oldColumns + c];
      set(r, c, x);
      set(r + rows ~/ 2, c + columns ~/ 2, x);
    }
  }
  // And finally, copy Y to -Y:
  for (int r = rows ~/ 2; r < rows; r++) {
    for (int c = 0; c < oldColumns; c++) {
      final y = get(r, c);
      set(r - rows ~/ 2, c + oldColumns, y.negateAsFloat());
    }
  }
}