src/math-helpers.js
function hessenbergQRStep (M) {
  const n = M.dimension;
  const me = M.elements;
  const csr = [0, 0, 0];
  const cs = [];
  for (let k = 0; k < n - 1; ++k) {
    const row1 = k;
    const row2 = k + 1;
    const colK = k * n;
    const a = me[row1 + colK];
    const b = me[row2 + colK];
    rotg(a, b, csr);
    const c = csr[0];
    const s = csr[1];
    const r = csr[2];
    cs[k] = [c, s];
    for (let x = k; x < n; ++x) {
      const colX = x * n;
      const tmp1 = me[row1 + colX];
      const tmp2 = me[row2 + colX];
      me[row1 + colX] = c * tmp1 + s * tmp2;
      me[row2 + colX] = -s * tmp1 + c * tmp2;
    }
    me[row1 + colK] = r;
    me[row2 + colK] = 0;
  }
  for (let k = 0; k < n - 1; ++k) {
    const col1 = k * n;
    const col2 = (k + 1) * n;
    const [c, s] = cs[k];
    for (let x = 0; x <= k + 1; ++x) {
      const rowX = x;
      const tmp1 = me[rowX + col1];
      const tmp2 = me[rowX + col2];
      me[rowX + col1] = tmp1 * c + tmp2 * s;
      me[rowX + col2] = -tmp1 * s + tmp2 * c;
    }
  }
  return M;
}
function hessenbergQRStep (M) {
  const n = M.dimension;
  const me = M.elements;
  const csr = [0, 0, 0];
  const cs = [];
  for (let k = 0; k < n - 1; ++k) {
    const row1 = k;
    const row2 = k + 1;
    const colK = k * n;
    const a = me[row1 + colK];
    const b = me[row2 + colK];
    rotg(a, b, csr);
    const c = csr[0];
    const s = csr[1];
    const r = csr[2];
    cs[k] = [c, s];
    for (let x = k; x < n; ++x) {
      const colX = x * n;
      const tmp1 = me[row1 + colX];
      const tmp2 = me[row2 + colX];
      me[row1 + colX] = c * tmp1 + s * tmp2;
      me[row2 + colX] = -s * tmp1 + c * tmp2;
    }
    me[row1 + colK] = r;
    me[row2 + colK] = 0;
  }
  for (let k = 0; k < n - 1; ++k) {
    const col1 = k * n;
    const col2 = (k + 1) * n;
    const [c, s] = cs[k];
    for (let x = 0; x <= k + 1; ++x) {
      const rowX = x;
      const tmp1 = me[rowX + col1];
      const tmp2 = me[rowX + col2];
      me[rowX + col1] = tmp1 * c + tmp2 * s;
      me[rowX + col2] = -tmp1 * s + tmp2 * c;
    }
  }
  return M;
}
function hessenbergQRStep ( M ) { const n = M . dimension ; const me = M . elements ; const csr = [ 0 , 0 , 0 ] ; const cs = [ ] ; for ( let k = 0 ; k < n - 1 ; ++ k ) { const row1 = k ; const row2 = k + 1 ; const colK = k * n ; const a = me [ row1 + colK ] ; const b = me [ row2 + colK ] ; rotg ( a , b , csr ) ; const c = csr [ 0 ] ; const s = csr [ 1 ] ; const r = csr [ 2 ] ; cs [ k ] = [ c , s ] ; for ( let x = k ; x < n ; ++ x ) { const colX = x * n ; const tmp1 = me [ row1 + colX ] ; const tmp2 = me [ row2 + colX ] ; me [ row1 + colX ] = c * tmp1 + s * tmp2 ; me [ row2 + colX ] = - s * tmp1 + c * tmp2 ; } me [ row1 + colK ] = r ; me [ row2 + colK ] = 0 ; } for ( let k = 0 ; k < n - 1 ; ++ k ) { const col1 = k * n ; const col2 = ( k + 1 ) * n ; const [ c , s ] = cs [ k ] ; for ( let x = 0 ; x <= k + 1 ; ++ x ) { const rowX = x ; const tmp1 = me [ rowX + col1 ] ; const tmp2 = me [ rowX + col2 ] ; me [ rowX + col1 ] = tmp1 * c + tmp2 * s ; me [ rowX + col2 ] = - tmp1 * s + tmp2 * c ; } } return M ; }
Computes a Hessenberg step of the QR algorithm.
@memberof Helpers
@param {Matrix2|Matrix3|Matrix4} M The matrix to step.
Computes a Hessenberg step of the QR algorithm .