private void orthes(){
  int low=0;
  int high=n - 1;
  for (int m=low + 1; m <= high - 1; m++) {
    double scale=0.0;
    for (int i=m; i <= high; i++) {
      scale=scale + Math.abs(H[i][m - 1]);
    }
    if (scale != 0.0) {
      double h=0.0;
      for (int i=high; i >= m; i--) {
        ort[i]=H[i][m - 1] / scale;
        h+=ort[i] * ort[i];
      }
      double g=Math.sqrt(h);
      if (ort[m] > 0) {
        g=-g;
      }
      h=h - ort[m] * g;
      ort[m]=ort[m] - g;
      for (int j=m; j < n; j++) {
        double f=0.0;
        for (int i=high; i >= m; i--) {
          f+=ort[i] * H[i][j];
        }
        f=f / h;
        for (int i=m; i <= high; i++) {
          H[i][j]-=f * ort[i];
        }
      }
      for (int i=0; i <= high; i++) {
        double f=0.0;
        for (int j=high; j >= m; j--) {
          f+=ort[j] * H[i][j];
        }
        f=f / h;
        for (int j=m; j <= high; j++) {
          H[i][j]-=f * ort[j];
        }
      }
      ort[m]=scale * ort[m];
      H[m][m - 1]=scale * g;
    }
  }
  for (int i=0; i < n; i++) {
    for (int j=0; j < n; j++) {
      V[i][j]=(i == j ? 1.0 : 0.0);
    }
  }
  for (int m=high - 1; m >= low + 1; m--) {
    if (H[m][m - 1] != 0.0) {
      for (int i=m + 1; i <= high; i++) {
        ort[i]=H[i][m - 1];
      }
      for (int j=m; j <= high; j++) {
        double g=0.0;
        for (int i=m; i <= high; i++) {
          g+=ort[i] * V[i][j];
        }
        g=(g / ort[m]) / H[m][m - 1];
        for (int i=m; i <= high; i++) {
          V[i][j]+=g * ort[i];
        }
      }
    }
  }
}

private void orthes ( ) { int low = 0 ; int high = n - 1 ; for ( int m = low + 1 ; m <= high - 1 ; m ++ ) { double scale = 0.0 ; for ( int i = m ; i <= high ; i ++ ) { scale = scale + Math . abs ( H [ i ] [ m - 1 ] ) ; } if ( scale != 0.0 ) { double h = 0.0 ; for ( int i = high ; i >= m ; i -- ) { ort [ i ] = H [ i ] [ m - 1 ] / scale ; h += ort [ i ] * ort [ i ] ; } double g = Math . sqrt ( h ) ; if ( ort [ m ] > 0 ) { g = - g ; } h = h - ort [ m ] * g ; ort [ m ] = ort [ m ] - g ; for ( int j = m ; j < n ; j ++ ) { double f = 0.0 ; for ( int i = high ; i >= m ; i -- ) { f += ort [ i ] * H [ i ] [ j ] ; } f = f / h ; for ( int i = m ; i <= high ; i ++ ) { H [ i ] [ j ] -= f * ort [ i ] ; } } for ( int i = 0 ; i <= high ; i ++ ) { double f = 0.0 ; for ( int j = high ; j >= m ; j -- ) { f += ort [ j ] * H [ i ] [ j ] ; } f = f / h ; for ( int j = m ; j <= high ; j ++ ) { H [ i ] [ j ] -= f * ort [ j ] ; } } ort [ m ] = scale * ort [ m ] ; H [ m ] [ m - 1 ] = scale * g ; } } for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) { V [ i ] [ j ] = ( i == j ? 1.0 : 0.0 ) ; } } for ( int m = high - 1 ; m >= low + 1 ; m -- ) { if ( H [ m ] [ m - 1 ] != 0.0 ) { for ( int i = m + 1 ; i <= high ; i ++ ) { ort [ i ] = H [ i ] [ m - 1 ] ; } for ( int j = m ; j <= high ; j ++ ) { double g = 0.0 ; for ( int i = m ; i <= high ; i ++ ) { g += ort [ i ] * V [ i ] [ j ] ; } g = ( g / ort [ m ] ) / H [ m ] [ m - 1 ] ; for ( int i = m ; i <= high ; i ++ ) { V [ i ] [ j ] += g * ort [ i ] ; } } } } }
nonsymmetric reduction to hessenberg form .
