code: def hessenberg(ctx, A, overwrite_a=False):
      """
      This routine computes the Hessenberg decomposition of a square matrix A.
      Given A, an unitary matrix Q is determined such that
  
            Q' A Q = H                and               Q' Q = Q Q' = 1
  
      where H is an upper right Hessenberg matrix. Here ' denotes the hermitian
      transpose (i.e. transposition and conjugation).
  
      input:
        A            : a real or complex square matrix
        overwrite_a  : if true, allows modification of A which may improve
                       performance. if false, A is not modified.
  
      output:
        Q : an unitary matrix
        H : an upper right Hessenberg matrix
  
      example:
        >>> from mpmath import mp
        >>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
        >>> Q, H = mp.hessenberg(A)
        >>> mp.nprint(H, 3) # doctest:+SKIP
        [  3.15  2.23  4.44]
        [-0.769  4.85  3.05]
        [   0.0  3.61   7.0]
        >>> print(mp.chop(A - Q * H * Q.transpose_conj()))
        [0.0  0.0  0.0]
        [0.0  0.0  0.0]
        [0.0  0.0  0.0]
  
      return value:   (Q, H)
      """
  
      n = A.rows
  
      if n == 1:
          return (ctx.matrix([[1]]), A)
  
      if not overwrite_a:
          A = A.copy()
  
      T = ctx.matrix(n, 1)
  
      hessenberg_reduce_0(ctx, A, T)
      Q = A.copy()
      hessenberg_reduce_1(ctx, Q, T)
  
      for x in xrange(n):
          for y in xrange(x + 2, n):
              A[y, x] = 0
  
      return Q, A
  
file_path: catboost/contrib/python/mpmath/py3/mpmath/matrices/eigen.py
imports: from ..libmp.backend import xrange
label_desc: Use image node_id 4 for calling a global function with example usage: hessenberg(ctx, A, overwrite_a) and returns: Q,  A, ctx,  A