* F08VSF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER MMAX, NMAX, PMAX PARAMETER (MMAX=10,NMAX=10,PMAX=10) INTEGER LDA, LDB, LDQ, LDU, LDV PARAMETER (LDA=MMAX,LDB=PMAX,LDQ=NMAX,LDU=MMAX,LDV=PMAX) * .. Local Scalars .. DOUBLE PRECISION EPS, TOLA, TOLB INTEGER I, IFAIL, INFO, IRANK, J, K, L, M, N, P * .. Local Arrays .. COMPLEX *16 A(LDA,NMAX), B(LDB,NMAX), Q(LDQ,NMAX), TAU(NMAX), + U(LDU,MMAX), V(LDV,PMAX), WORK(MMAX+3*NMAX+PMAX) DOUBLE PRECISION RWORK(2*NMAX) INTEGER IWORK(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Functions .. DOUBLE PRECISION F06UAF, X02AJF EXTERNAL F06UAF, X02AJF * .. External Subroutines .. EXTERNAL X04DBF, ZGGSVP * .. Intrinsic Functions .. INTRINSIC MAX * .. Executable Statements .. WRITE (NOUT,*) 'F08VSF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) M, N, P IF (M.LE.MMAX .AND. N.LE.NMAX .AND. P.LE.PMAX) THEN * * Read the m by n matrix A and p by n matrix B from data file * READ (NIN,*) ((A(I,J),J=1,N),I=1,M) READ (NIN,*) ((B(I,J),J=1,N),I=1,P) * * Compute TOLA and TOLB as * TOLA = max(M,N)*norm(A)*macheps * TOLB = max(P,N)*norm(B)*macheps * EPS = X02AJF() TOLA = MAX(M,N)*F06UAF('One-norm',M,N,A,LDA,RWORK)*EPS TOLB = MAX(P,N)*F06UAF('One-norm',P,N,B,LDB,RWORK)*EPS * * Compute the factorization of (A, B) * (A = U*S*(Q**H), B = V*T*(Q**H)) * CALL ZGGSVP('U','V','Q',M,P,N,A,LDA,B,LDB,TOLA,TOLB,K,L,U,LDU, + V,LDV,Q,LDQ,IWORK,RWORK,TAU,WORK,INFO) * * Print solution * IRANK = K + L WRITE (NOUT,*) 'Numerical rank of (A**T B**T)**T (K+L)' WRITE (NOUT,99999) IRANK * WRITE (NOUT,*) IF (M.GE.IRANK) THEN IFAIL = 0 CALL X04DBF('Upper','Non-unit',IRANK,IRANK,A(1,N-IRANK+1), + LDA,'Bracketed','1P,E12.4', + 'Upper triangular matrix S','Integer',RLABS, + 'Integer',CLABS,80,0,IFAIL) ELSE IFAIL = 0 CALL X04DBF('Upper','Non-unit',M,IRANK,A(1,N-IRANK+1),LDA, + 'Bracketed','1P,E12.4', + 'Upper trapezoidal matrix S','Integer',RLABS, + 'Integer',CLABS,80,0,IFAIL) END IF WRITE (NOUT,*) IFAIL = 0 CALL X04DBF('Upper','Non-unit',L,L,B(1,N-L+1),LDB,'Bracketed', + '1P,E12.4','Upper triangular matrix T','Integer', + RLABS,'Integer',CLABS,80,0,IFAIL) WRITE (NOUT,*) IFAIL = 0 CALL X04DBF('General',' ',M,M,U,LDU,'Bracketed','1P,E12.4', + 'Orthogonal matrix U','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) WRITE (NOUT,*) IFAIL = 0 CALL X04DBF('General',' ',P,P,V,LDV,'Bracketed','1P,E12.4', + 'Orthogonal matrix V','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) WRITE (NOUT,*) IFAIL = 0 CALL X04DBF('General',' ',N,N,Q,LDQ,'Bracketed','1P,E12.4', + 'Orthogonal matrix Q','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) ELSE WRITE (NOUT,*) 'MMAX and/or NMAX too small' END IF * 99999 FORMAT (1X,I5) END