* F08MDF Example Program Text * Mark 21 Release. NAG Copyright 2004. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX PARAMETER (NMAX=10) INTEGER LDU, LDVT PARAMETER (LDU=NMAX,LDVT=NMAX) * .. Local Scalars .. INTEGER I, IFAIL, INFO, N * .. Local Arrays .. DOUBLE PRECISION D(NMAX), E(NMAX-1), Q(1), U(LDU,NMAX), + VT(LDVT,NMAX), WORK(NMAX*(3*NMAX+2)) INTEGER IQ(1), IWORK(7*NMAX) * .. External Subroutines .. EXTERNAL DBDSDC, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08MDF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) N IF (N.LE.NMAX) THEN * * Read the bidiagonal matrix B from data file, first * the diagonal elements, and then the off diagonal elements * READ (NIN,*) (D(I),I=1,N) READ (NIN,*) (E(I),I=1,N-1) * * Calculate the singular values and left and right singular * vectors of B. * CALL DBDSDC('Upper','I',N,D,E,U,LDU,VT,LDVT,Q,IQ,WORK,IWORK, + INFO) * IF (INFO.EQ.0) THEN * * Print singular values and vectors * IFAIL = 0 CALL X04CAF('General',' ',N,N,U,LDU, + 'Left singular vectors, by column',IFAIL) * WRITE (NOUT,*) WRITE (NOUT,*) 'Singular values' WRITE (NOUT,99999) (D(I),I=1,N) * WRITE (NOUT,*) IFAIL = 0 CALL X04CAF('General',' ',N,N,VT,LDVT, + 'Right singular vectors, by row',IFAIL) * ELSE WRITE (NOUT,99998) + 'Failure to compute a singular value, INFO = ', INFO END IF ELSE WRITE (NOUT,*) 'NMAX too small' END IF STOP * 99999 FORMAT ((3X,8F8.4)) 99998 FORMAT (1X,A,I10) END