* F08QHF Example Program Text * Mark 16 Release. NAG Copyright 1992. * .. Parameters .. INTEGER NIN, NOUT PARAMETER (NIN=5,NOUT=6) INTEGER MMAX, NMAX, LDA, LDB, LDC PARAMETER (MMAX=8,NMAX=8,LDA=MMAX,LDB=NMAX,LDC=MMAX) * .. Local Scalars .. DOUBLE PRECISION SCALE INTEGER I, IFAIL, INFO, J, M, N * .. Local Arrays .. DOUBLE PRECISION A(LDA,MMAX), B(LDB,NMAX), C(LDC,NMAX) * .. External Subroutines .. EXTERNAL DTRSYL, X04CAF * .. Executable Statements .. WRITE (NOUT,*) 'F08QHF Example Program Results' WRITE (NOUT,*) * Skip heading in data file READ (NIN,*) READ (NIN,*) M, N IF (M.LE.MMAX .AND. N.LE.NMAX) THEN * * Read A, B and C from data file * READ (NIN,*) ((A(I,J),J=1,M),I=1,M) READ (NIN,*) ((B(I,J),J=1,N),I=1,N) READ (NIN,*) ((C(I,J),J=1,N),I=1,M) * * Solve the Sylvester equation A*X + X*B = C for X * CALL DTRSYL('No transpose','No transpose',1,M,N,A,LDA,B,LDB,C, + LDC,SCALE,INFO) IF (INFO.EQ.1) THEN WRITE (NOUT,99999) WRITE (NOUT,*) END IF * * Print the solution matrix X * IFAIL = 0 CALL X04CAF('General',' ',M,N,C,LDC,'Solution matrix X',IFAIL) * WRITE (NOUT,*) WRITE (NOUT,99998) 'SCALE = ', SCALE ELSE WRITE (NOUT,*) 'MMAX and/or NMAX too small' END IF STOP * 99999 FORMAT (/' A and B have common or very close eigenvalues.',/' Pe', + 'rturbed values were used to solve the equations') 99998 FORMAT (1X,A,1P,E10.2) END