code: def schur(ctx, A, overwrite_a=False):
      """
      This routine computes the Schur decomposition of a square matrix A.
      Given A, an unitary matrix Q is determined such that
  
            Q' A Q = R                and               Q' Q = Q Q' = 1
  
      where R is an upper right triangular 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
        R : an upper right triangular matrix
  
      return value:   (Q, R)
  
      example:
        >>> from mpmath import mp
        >>> A = mp.matrix([[3, -1, 2], [2, 5, -5], [-2, -3, 7]])
        >>> Q, R = mp.schur(A)
        >>> mp.nprint(R, 3) # doctest:+SKIP
        [2.0  0.417  -2.53]
        [0.0    4.0  -4.74]
        [0.0    0.0    9.0]
        >>> print(mp.chop(A - Q * R * Q.transpose_conj()))
        [0.0  0.0  0.0]
        [0.0  0.0  0.0]
        [0.0  0.0  0.0]
  
      warning: The Schur decomposition is not unique.
      """
  
      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
  
      hessenberg_qr(ctx, A, Q)
  
      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 7 for calling a global function with example usage: schur(ctx, A, overwrite_a) and returns: Q,  A, ctx,  A