* F08YEF 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, NCYCLE, P * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), ALPHA(NMAX), B(LDB,NMAX), + BETA(NMAX), Q(LDQ,NMAX), TAU(NMAX), U(LDU,MMAX), + V(LDV,PMAX), WORK(MMAX+3*NMAX+PMAX) INTEGER IWORK(NMAX) CHARACTER CLABS(1), RLABS(1) * .. External Functions .. DOUBLE PRECISION F06RAF, X02AJF EXTERNAL F06RAF, X02AJF * .. External Subroutines .. EXTERNAL DGGSVP, DTGSJA, X04CBF * .. Intrinsic Functions .. INTRINSIC MAX * .. Executable Statements .. WRITE (NOUT,*) 'F08YEF 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)*F06RAF('One-norm',M,N,A,LDA,WORK)*EPS TOLB = MAX(P,N)*F06RAF('One-norm',P,N,B,LDB,WORK)*EPS * * Compute the factorization of (A, B) * (A = U1*S*(Q1**T), B = V1*T*(Q1**T)) * CALL DGGSVP('U','V','Q',M,P,N,A,LDA,B,LDB,TOLA,TOLB,K,L,U,LDU, + V,LDV,Q,LDQ,IWORK,TAU,WORK,INFO) * * Compute the generalized singular value decomposition of (A, B) * (A = U*D1*(0 R)*(Q**T), B = V*D2*(0 R)*(Q**T)) * CALL DTGSJA('U','V','Q',M,P,N,K,L,A,LDA,B,LDB,TOLA,TOLB,ALPHA, + BETA,U,LDU,V,LDV,Q,LDQ,WORK,NCYCLE,INFO) * IF (INFO.EQ.0) THEN * * Print solution * IRANK = K + L WRITE (NOUT,*) + 'Number of infinite generalized singular values (K)' WRITE (NOUT,99999) K WRITE (NOUT,*) + 'Number of finite generalized singular values (L)' WRITE (NOUT,99999) L WRITE (NOUT,*) + ' Effective Numerical rank of (A**T B**T)**T (K+L)' WRITE (NOUT,99999) IRANK WRITE (NOUT,*) WRITE (NOUT,*) 'Finite generalized singular values' WRITE (NOUT,99998) (ALPHA(J)/BETA(J),J=K+1,IRANK) * IFAIL = 0 WRITE (NOUT,*) CALL X04CBF('General',' ',M,M,U,LDU,'1P,E12.4', + 'Orthogonal matrix U','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) WRITE (NOUT,*) CALL X04CBF('General',' ',P,P,V,LDV,'1P,E12.4', + 'Orthogonal matrix V','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) WRITE (NOUT,*) CALL X04CBF('General',' ',N,N,Q,LDQ,'1P,E12.4', + 'Orthogonal matrix Q','Integer',RLABS,'Integer', + CLABS,80,0,IFAIL) WRITE (NOUT,*) CALL X04CBF('Upper triangular','Non-unit',IRANK,IRANK, + A(1,N-IRANK+1),LDA,'1P,E12.4', + 'Non singular upper triangular matrix R', + 'Integer',RLABS,'Integer',CLABS,80,0,IFAIL) WRITE (NOUT,*) WRITE (NOUT,*) 'Number of cycles of the Kogbetliantz method' WRITE (NOUT,99999) NCYCLE ELSE WRITE (NOUT,99997) 'Failure in DTGSJA. INFO =', INFO END IF ELSE WRITE (NOUT,*) 'MMAX and/or NMAX too small' END IF STOP * 99999 FORMAT (1X,I5) 99998 FORMAT (3X,8(1P,E12.4)) 99997 FORMAT (1X,A,I4) END