Q method

Array2d Q()

Generate and return the (economy-sized) orthogonal factor Q

Implementation

Array2d Q() {
  var Q = Array2d.fixed(_m, _n);
  for (var k = _n - 1; k >= 0; k--) {
    for (var i = 0; i < _m; i++) {
      Q[i][k] = 0.0;
    }
    Q[k][k] = 1.0;
    for (var j = k; j < _n; j++) {
      if (_QR[k][k] != 0) {
        var s = 0.0;
        for (var i = k; i < _m; i++) {
          s += _QR[i][k] * Q[i][j];
        }
        s = -s / _QR[k][k];
        for (var i = k; i < _m; i++) {
          Q[i][j] += s * _QR[i][k];
        }
      }
    }
  }
  return Q;
}