--- 
:name: zggrqf
:md5sum: 585d26f527a6d3aa55af7c50990d406c
:category: :subroutine
:arguments: 
- m: 
    :type: integer
    :intent: input
- p: 
    :type: integer
    :intent: input
- n: 
    :type: integer
    :intent: input
- a: 
    :type: doublecomplex
    :intent: input/output
    :dims: 
    - lda
    - n
- lda: 
    :type: integer
    :intent: input
- taua: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - MIN(m,n)
- b: 
    :type: doublecomplex
    :intent: input/output
    :dims: 
    - ldb
    - n
- ldb: 
    :type: integer
    :intent: input
- taub: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - MIN(p,n)
- work: 
    :type: doublecomplex
    :intent: output
    :dims: 
    - MAX(1,lwork)
- lwork: 
    :type: integer
    :intent: input
    :option: true
    :default: MAX(MAX(n,m),p)
- info: 
    :type: integer
    :intent: output
:substitutions: {}

:fortran_help: "      SUBROUTINE ZGGRQF( M, P, N, A, LDA, TAUA, B, LDB, TAUB, WORK, LWORK, INFO )\n\n\
  *  Purpose\n\
  *  =======\n\
  *\n\
  *  ZGGRQF computes a generalized RQ factorization of an M-by-N matrix A\n\
  *  and a P-by-N matrix B:\n\
  *\n\
  *              A = R*Q,        B = Z*T*Q,\n\
  *\n\
  *  where Q is an N-by-N unitary matrix, Z is a P-by-P unitary\n\
  *  matrix, and R and T assume one of the forms:\n\
  *\n\
  *  if M <= N,  R = ( 0  R12 ) M,   or if M > N,  R = ( R11 ) M-N,\n\
  *                   N-M  M                           ( R21 ) N\n\
  *                                                       N\n\
  *\n\
  *  where R12 or R21 is upper triangular, and\n\
  *\n\
  *  if P >= N,  T = ( T11 ) N  ,   or if P < N,  T = ( T11  T12 ) P,\n\
  *                  (  0  ) P-N                         P   N-P\n\
  *                     N\n\
  *\n\
  *  where T11 is upper triangular.\n\
  *\n\
  *  In particular, if B is square and nonsingular, the GRQ factorization\n\
  *  of A and B implicitly gives the RQ factorization of A*inv(B):\n\
  *\n\
  *               A*inv(B) = (R*inv(T))*Z'\n\
  *\n\
  *  where inv(B) denotes the inverse of the matrix B, and Z' denotes the\n\
  *  conjugate transpose of the matrix Z.\n\
  *\n\n\
  *  Arguments\n\
  *  =========\n\
  *\n\
  *  M       (input) INTEGER\n\
  *          The number of rows of the matrix A.  M >= 0.\n\
  *\n\
  *  P       (input) INTEGER\n\
  *          The number of rows of the matrix B.  P >= 0.\n\
  *\n\
  *  N       (input) INTEGER\n\
  *          The number of columns of the matrices A and B. N >= 0.\n\
  *\n\
  *  A       (input/output) COMPLEX*16 array, dimension (LDA,N)\n\
  *          On entry, the M-by-N matrix A.\n\
  *          On exit, if M <= N, the upper triangle of the subarray\n\
  *          A(1:M,N-M+1:N) contains the M-by-M upper triangular matrix R;\n\
  *          if M > N, the elements on and above the (M-N)-th subdiagonal\n\
  *          contain the M-by-N upper trapezoidal matrix R; the remaining\n\
  *          elements, with the array TAUA, represent the unitary\n\
  *          matrix Q as a product of elementary reflectors (see Further\n\
  *          Details).\n\
  *\n\
  *  LDA     (input) INTEGER\n\
  *          The leading dimension of the array A. LDA >= max(1,M).\n\
  *\n\
  *  TAUA    (output) COMPLEX*16 array, dimension (min(M,N))\n\
  *          The scalar factors of the elementary reflectors which\n\
  *          represent the unitary matrix Q (see Further Details).\n\
  *\n\
  *  B       (input/output) COMPLEX*16 array, dimension (LDB,N)\n\
  *          On entry, the P-by-N matrix B.\n\
  *          On exit, the elements on and above the diagonal of the array\n\
  *          contain the min(P,N)-by-N upper trapezoidal matrix T (T is\n\
  *          upper triangular if P >= N); the elements below the diagonal,\n\
  *          with the array TAUB, represent the unitary matrix Z as a\n\
  *          product of elementary reflectors (see Further Details).\n\
  *\n\
  *  LDB     (input) INTEGER\n\
  *          The leading dimension of the array B. LDB >= max(1,P).\n\
  *\n\
  *  TAUB    (output) COMPLEX*16 array, dimension (min(P,N))\n\
  *          The scalar factors of the elementary reflectors which\n\
  *          represent the unitary matrix Z (see Further Details).\n\
  *\n\
  *  WORK    (workspace/output) COMPLEX*16 array, dimension (MAX(1,LWORK))\n\
  *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.\n\
  *\n\
  *  LWORK   (input) INTEGER\n\
  *          The dimension of the array WORK. LWORK >= max(1,N,M,P).\n\
  *          For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3),\n\
  *          where NB1 is the optimal blocksize for the RQ factorization\n\
  *          of an M-by-N matrix, NB2 is the optimal blocksize for the\n\
  *          QR factorization of a P-by-N matrix, and NB3 is the optimal\n\
  *          blocksize for a call of ZUNMRQ.\n\
  *\n\
  *          If LWORK = -1, then a workspace query is assumed; the routine\n\
  *          only calculates the optimal size of the WORK array, returns\n\
  *          this value as the first entry of the WORK array, and no error\n\
  *          message related to LWORK is issued by XERBLA.\n\
  *\n\
  *  INFO    (output) INTEGER\n\
  *          = 0:  successful exit\n\
  *          < 0:  if INFO=-i, the i-th argument had an illegal value.\n\
  *\n\n\
  *  Further Details\n\
  *  ===============\n\
  *\n\
  *  The matrix Q is represented as a product of elementary reflectors\n\
  *\n\
  *     Q = H(1) H(2) . . . H(k), where k = min(m,n).\n\
  *\n\
  *  Each H(i) has the form\n\
  *\n\
  *     H(i) = I - taua * v * v'\n\
  *\n\
  *  where taua is a complex scalar, and v is a complex vector with\n\
  *  v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in\n\
  *  A(m-k+i,1:n-k+i-1), and taua in TAUA(i).\n\
  *  To form Q explicitly, use LAPACK subroutine ZUNGRQ.\n\
  *  To use Q to update another matrix, use LAPACK subroutine ZUNMRQ.\n\
  *\n\
  *  The matrix Z is represented as a product of elementary reflectors\n\
  *\n\
  *     Z = H(1) H(2) . . . H(k), where k = min(p,n).\n\
  *\n\
  *  Each H(i) has the form\n\
  *\n\
  *     H(i) = I - taub * v * v'\n\
  *\n\
  *  where taub is a complex scalar, and v is a complex vector with\n\
  *  v(1:i-1) = 0 and v(i) = 1; v(i+1:p) is stored on exit in B(i+1:p,i),\n\
  *  and taub in TAUB(i).\n\
  *  To form Z explicitly, use LAPACK subroutine ZUNGQR.\n\
  *  To use Z to update another matrix, use LAPACK subroutine ZUNMQR.\n\
  *\n\
  *  =====================================================================\n\
  *\n\
  *     .. Local Scalars ..\n      LOGICAL            LQUERY\n      INTEGER            LOPT, LWKOPT, NB, NB1, NB2, NB3\n\
  *     ..\n\
  *     .. External Subroutines ..\n      EXTERNAL           XERBLA, ZGEQRF, ZGERQF, ZUNMRQ\n\
  *     ..\n\
  *     .. External Functions ..\n      INTEGER            ILAENV\n      EXTERNAL           ILAENV\n\
  *     ..\n\
  *     .. Intrinsic Functions ..\n      INTRINSIC          INT, MAX, MIN\n\
  *     ..\n"
