* F04JLF Example Program Text. * Mark 20 Revised. NAG Copyright 2001. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER NMAX, MMAX, PMAX, LDA, LDB, LWORK PARAMETER (NMAX=10,MMAX=10,PMAX=10,LDA=MMAX,LDB=MMAX, + LWORK=NMAX+MMAX+64*(MMAX+PMAX)) * .. Local Scalars .. INTEGER I, IFAIL, J, M, N, P * .. Local Arrays .. DOUBLE PRECISION A(LDA,NMAX), B(LDB,PMAX), D(MMAX), WORK(LWORK), + X(NMAX), Y(PMAX) * .. External Subroutines .. EXTERNAL F04JLF * .. Executable Statements .. WRITE (NOUT,*) 'F04JLF Example Program Results' * 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 A, B and D from data file * READ (NIN,*) ((A(I,J),J=1,N),I=1,M) READ (NIN,*) ((B(I,J),J=1,P),I=1,M) READ (NIN,*) (D(I),I=1,M) * * Solve the weighted least-squares problem * * minimize ||inv(B)*(D-A*X)|| (in the 2-norm) * IFAIL = 0 * CALL F04JLF(M,N,P,A,LDA,B,LDB,D,X,Y,WORK,LWORK,IFAIL) * * Print least-squares solution * WRITE (NOUT,*) WRITE (NOUT,*) 'Least-squares solution' WRITE (NOUT,99999) (X(I),I=1,N) END IF STOP * 99999 FORMAT (1X,8F9.4) END