NAG Library Routine Document F04BEF.1

Similar documents
NAG Fortran Library Routine Document F04BJF.1

NAG Fortran Library Routine Document F04CJF.1

NAG Fortran Library Routine Document F04BGF.1

NAG Fortran Library Routine Document F04CAF.1

NAG Fortran Library Routine Document F04DHF.1

NAG Library Routine Document F07MAF (DSYSV).1

NAG Fortran Library Routine Document F07AAF (DGESV).1

NAG Fortran Library Routine Document F08BHF (DTZRZF).1

NAG Library Function Document nag_real_sym_posdef_tridiag_lin_solve (f04bgc)

NAG Library Routine Document F08FAF (DSYEV)

NAG Library Function Document nag_complex_gen_lin_solve (f04cac)

NAG Fortran Library Routine Document F08KAF (DGELSS).1

NAG Library Function Document nag_herm_posdef_tridiag_lin_solve (f04cgc)

NAG Library Function Document nag_complex_tridiag_lin_solve (f04ccc)

F04EBFP.1. NAG Parallel Library Routine Document

NAG Library Routine Document F08BVF (ZTZRZF)

NAG Library Function Document nag_dspsv (f07pac)

NAG Library Routine Document F04MCF.1

NAG Fortran Library Routine Document F01CTF.1

NAG Library Routine Document F07KDF (DPSTRF)

NAG Library Routine Document F08FDF (DSYEVR)

NAG Fortran Library Routine Document F01CWF.1

NAG Library Routine Document F08ZNF (ZGGLSE)

NAG Library Function Document nag_dgttrs (f07cec)

NAG Library Routine Document F08ASF (ZGEQRF).1

NAG Library Routine Document F04JAF.1

NAG Fortran Library Routine Document F08FQF (CHEEVD=ZHEEVD).1

NAG Library Routine Document G02BUF.1

NAG Fortran Library Routine Document F04JAF.1

NAG Fortran Library Routine Document G02HKF.1

NAG Library Function Document nag_zhpev (f08gnc)

Module 5.5: nag sym bnd lin sys Symmetric Banded Systems of Linear Equations. Contents

NAG Fortran Library Routine Document F04JGF.1

NAG Library Routine Document H03ADF.1

NAG Fortran Library Routine Document G01ADF.1

NAG Library Routine Document G05REF.1

NAG Fortran Library Routine Document F11ZPF.1

NAG Library Routine Document G05RGF.1

NAG Fortran Library Routine Document G05LZF.1

NAG Library Function Document nag_zheevx (f08fpc)

NAG Library Function Document nag_zgelsy (f08bnc)

NAG Library Routine Document G02CFF.1

NAG Library Routine Document G02DDF.1

F02WUF NAG Fortran Library Routine Document

NAG Fortran Library Routine Document G08AJF.1

NAG Library Routine Document G02BGF.1

NAG Fortran Library Routine Document X04CBF.1

NAG Library Function Document nag_dsygv (f08sac)

NAG Library Routine Document F08LEF (DGBBRD)

NAG Library Function Document nag_dgelsd (f08kcc)

NAG Fortran Library Routine Document E02BCF.1

NAG Library Routine Document E02BCF.1

NAG Library Function Document nag_dstev (f08jac)

NAG Library Function Document nag_dsbev (f08hac)

NAG Library Function Document nag_zgelss (f08knc)

NAG Library Function Document nag_dgglse (f08zac)

NAG Library Routine Document F08NGF (DORMHR).1

NAG Fortran Library Routine Document G01AJF.1

NAG Library Function Document nag_ztzrzf (f08bvc)

NAG Fortran Library Routine Document G08AKF.1

NAG Fortran Library Routine Document G01NBF.1

NAG Library Routine Document D02UCF.1

F01BSF NAG Fortran Library Routine Document

NAG Fortran Library Routine Document G01ARF.1

NAG Library Routine Document G02BXF.1

NAG Library Routine Document G01ABF.1

NAG Library Routine Document G02DAF.1

NAG Fortran Library Routine Document G05RAF.1

NAG Library Routine Document G01AJF.1

F07HDFP (PDPBTRF).1. NAG Parallel Library Routine Document

NAG Library Routine Document D02UAF.1

NAG Library Routine Document G05PZF.1

NAG Library Routine Document C05RBF.1

NAG Library Routine Document C05QBF.1

NAG Library Routine Document D02HBF.1

NAG Fortran Library Routine Document C05PBF.1

NAG Library Routine Document C05PBF/C05PBA

NAG Library Routine Document G13DMF.1

NAG Fortran Library Routine Document E01AEF.1

NAG Library Routine Document G12ABF.1

NAG Library Routine Document G13CDF.1

NAG Library Routine Document D02MWF.1

NAG Library Routine Document G13DPF.1

NAG Fortran Library Routine Document F11DSF.1

NAG Library Function Document nag_zhbevx (f08hpc)

NAG Library Routine Document G02GPF.1

NAG Library Routine Document E04GYF.1

NAG Library Routine Document D04AAF.1

NAG Library Routine Document D01BAF.1

NAG Library Routine Document E02DFF.1

NAG C Library Function Document nag_zspcon (f07quc)

NAG Library Function Document nag_dsytrf (f07mdc)

NAG Library Function Document nag_dpbtrf (f07hdc)

NAG Library Routine Document G05PZF.1

NAG Library Routine Document G05PGF.1

NAG Fortran Library Routine Document D02PZF.1

NAG Library Function Document nag_ztgsen (f08yuc)

NAG C Library Function Document nag_dspcon (f07pgc)

NAG Library Function Document nag_ztbcon (f07vuc)

NAG Fortran Library Routine Document D02MVF.1

Transcription:

F04 Simultaneous Linear Equations NAG Library Routine Document Note: before using this routine, please read the Users Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details. Purpose computes the solution to a real system of linear equations AX ¼ B, where A is an n by n symmetric positive-definite matrix, stored in packed format, and X and B are n by r matrices. An estimate of the condition number of A and an error bound for the computed solution are also returned. 2 Specification SUBROUTINE (UPLO, N, NRHS, AP, B, LDB, RCOND, ERRBND, IFAIL) INTEGER N, NRHS, LDB, IFAIL double precision AP(), B(LDB,), RCOND, ERRBND CHARACTER UPLO 3 Description The Cholesky factorization is used to factor A as A ¼ U T U, if UPLO ¼ U, or A ¼ LL T, if UPLO ¼ L, where U is an upper triangular matrix and L is a lower triangular matrix. The factored form of A is then used to solve the system of equations AX ¼ B. 4 References Anderson E, Bai Z, Bischof C, Blackford S, Demmel J, Dongarra J J, Du Croz J J, Greenbaum A, Hammarling S, McKenney A and Sorensen D (999) LAPACK Users Guide (3rd Edition) SIAM, Philadelphiahttp://www.netlib.org/lapack/lug Higham N J (2002) Accuracy and Stability of Numerical Algorithms (2nd Edition) SIAM, Philadelphia 5 Parameters : UPLO CHARACTER Input On entry: if UPLO ¼ U, the upper triangle of the matrix A is stored. If UPLO ¼ L, the lower triangle of the matrix A is stored. Constraint: UPLO ¼ U or L. 2: N INTEGER Input On entry: the number of linear equations n, i.e., the order of the matrix A. Constraint: N 0. 3: NRHS INTEGER Input On entry: the number of right-hand sides r, i.e., the number of columns of the matrix B. Constraint: NRHS 0..

NAG Library Manual 4: APðÞ double precision array Input/Output Note: the dimension of the array AP must be at least maxð; N ðn þ Þ=2Þ. On entry: the n by n symmetric matrix A. The upper or lower triangular part of the symmetric matrix is packed column-wise in a linear array. The jth column of A is stored in the array AP as follows: if UPLO ¼ U, APði þ ðj Þj=2Þ ¼a ij for i j; if UPLO ¼ L, APði þ ðj Þð2n jþ=2þ ¼a ij for j i n. See Section 8 below for further details. On exit: if IFAIL ¼ 0orNþ, the factor U or L from the Cholesky factorization A ¼ U T U or A ¼ LL T, in the same storage format as A. 5: BðLDB,Þ double precision array Input/Output Note: the second dimension of the array B must be at least maxð; NRHSÞ. To solve the equations Ax ¼ b, where b is a single right-hand side, B may be supplied as a one-dimensional array with length LDB ¼ maxð; NÞ. On entry: the n by r matrix of right-hand sides B. On exit: if IFAIL ¼ 0orNþ, the n by r solution matrix X. 6: LDB INTEGER Input On entry: the first dimension of the array B as declared in the (sub)program from which is called. Constraint: LDB maxð; NÞ. 7: RCOND double precision Output On exit: if IFAIL ¼ 0orNþ, an estimate of the reciprocal of the condition number of the matrix A, computed as RCOND ¼ = kak A. 8: ERRBND double precision Output On exit: if IFAIL ¼ 0orNþ, an estimate of the forward error bound for a computed solution ^x, such that k^x xk = kxk ERRBND, where ^x is a column of the computed solution returned in the array B and x is the corresponding column of the exact solution X. If RCOND is less than machine precision, then ERRBND is returned as unity. 9: IFAIL INTEGER Input/Output On entry: IFAIL must be set to 0, or. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details. On exit: IFAIL ¼ 0 unless the routine detects an error (see Section 6). For environments where it might be inappropriate to halt program execution when an error is detected, the value or is recommended. If the output of error messages is undesirable, then the value is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value or is used it is essential to test the value of IFAIL on exit..2

F04 Simultaneous Linear Equations 6 Error Indicators and Warnings If on entry IFAIL ¼ 0or, explanatory error messages are output on the current error message unit (as defined by X04AAF). Errors or warnings detected by the routine: IFAIL < 0 and IFAIL 6¼ 999 If IFAIL ¼ i, the ith argument had an illegal value. IFAIL ¼ 999 Allocation of memory failed. The INTEGER allocatable memory required is N, and the double precision allocatable memory required is 3 N. Allocation failed before the solution could be computed. IFAIL > 0 and IFAIL N If IFAIL ¼ i, the leading minor of order i of A is not positive-definite. The factorization could not be completed, and the solution has not been computed. IFAIL ¼ N þ RCOND is less than machine precision, so that the matrix A is numerically singular. A solution to the equations AX ¼ B has nevertheless been computed. 7 Accuracy The computed solution for a single right-hand side, ^x, satisfies an equation of the form ða þ EÞ^x ¼ b, where kek ¼ OðÞA k k and is the machine precision. An approximate error bound for the computed solution is given by k^x xk A ð Þ kek, kxk kak where A ð Þ ¼ A kak, the condition number of A with respect to the solution of the linear equations. uses the approximation kek ¼ A k k to estimate ERRBND. See Section 4.4 of Anderson et al. (999) for further details. 8 Further Comments Two- The packed storage scheme is illustrated by the following example when n ¼ 4 and UPLO ¼ U. dimensional storage of the symmetric matrix A: a a 2 a 3 a 4 a 22 a 23 a 24 a 33 a 34 a 44 a ij ¼ a ji Packed storage of the upper triangle of A: AP ¼ ½a, a 2, a 22, a 3, a 23, a 33, a 4, a 24, a 34, a 44 Š The total number of floating-point operations required to solve the equations AX ¼ B is proportional to 3 n3 þ n 2 r. The condition number estimation typically requires between four and five solves and never more than eleven solves, following the factorization..3

NAG Library Manual In practice the condition number estimator is very reliable, but it can underestimate the true condition number; see Section 5.3 of Higham (2002) for further details. The complex analogue of is F04CEF. 9 Example This example solves the equations AX ¼ B, where A is the symmetric positive-definite matrix 0 0 4:6 3:2 0:56 0:0 8:70 8:30 3:2 5:03 0:83 :8 A ¼ B C 3:35 2:3 @ 0:56 0:83 0:76 0:34 A and B ¼ B C @ :89 :6 A. 0:0 :8 0:34 :8 4:4 5:00 An estimate of the condition number of A and an approximate error bound for the computed solutions are also printed. 9. Program Text Example Program Text Mark 2 Release. NAG Copyright 2004... Parameters.. INTEGER NIN, NOUT (NIN=5,NOUT=6) INTEGER NMAX, NRHSMX (NMAX=8,NRHSMX=2) INTEGER LDB (LDB=NMAX) CHARACTER UPLO (UPLO= U ).. Local Scalars.. DOUBLE PRECISION ERRBND, RCOND INTEGER I, IERR, IFAIL, J, N, NRHS.. Local Arrays.. DOUBLE PRECISION AP((NMAX(NMAX+))/2), B(LDB,NRHSMX).. External Subroutines.. EXTERNAL, X04CAF.. Executable Statements.. WRITE (NOUT,) Example Program Results WRITE (NOUT,) Skip heading in data file READ (NIN,) READ (NIN,) N, NRHS IF (N.LE.NMAX.AND. NRHS.LE.NRHSMX) THEN Read the upper or lower triangular part of the matrix A from data file IF (UPLO.EQ. U ) THEN READ (NIN,) ((AP(I+(J(J-))/2),J=I,N),I=,N) ELSE IF (UPLO.EQ. L ) THEN READ (NIN,) ((AP(I+((2N-J)(J-))/2),J=,I),I=,N) END IF Read B from data file READ (NIN,) ((B(I,J),J=,NRHS),I=,N) Solve the equations AX = B for X IFAIL = CALL (UPLO,N,NRHS,AP,B,LDB,RCOND,ERRBND,IFAIL) IF (IFAIL.EQ.0) THEN.4

F04 Simultaneous Linear Equations Print solution, estimate of condition number and approximate error bound IERR = 0 CALL X04CAF( General,,N,NRHS,B,LDB, Solution,IERR) WRITE (NOUT,) WRITE (NOUT,) Estimate of condition number WRITE (NOUT,99999).0D0/RCOND WRITE (NOUT,) WRITE (NOUT,) + Estimate of error bound for computed solutions WRITE (NOUT,99999) ERRBND ELSE IF (IFAIL.EQ.N+) THEN Matrix A is numerically singular. Print estimate of reciprocal of condition number and solution WRITE (NOUT,) WRITE (NOUT,) Estimate of reciprocal of condition number WRITE (NOUT,99999) RCOND WRITE (NOUT,) IERR = 0 CALL X04CAF( General,,N,NRHS,B,LDB, Solution,IERR) ELSE IF (IFAIL.GT.0.AND. IFAIL.LE.N) THEN The matrix A is not positive definite to working precision WRITE (NOUT,99998) The leading minor of order, IFAIL, + is not positive definite ELSE WRITE (NOUT,99997) IFAIL END IF ELSE WRITE (NOUT,) NMAX and/or NRHSMX too small END IF 99999 FORMAT (6X,P,E9.) 99998 FORMAT (X,A,I3,A) 99997 FORMAT (X, returned with IFAIL =,I5) END 9.2 Program Data Example Program Data 4 2 :Values of N and NRHS 4.6-3.2 0.56-0.0 5.03-0.83.8 0.76 0.34.8 :End of matrix A 8.70 8.30-3.35 2.3.89.6-4.4 5.00 :End of matrix B 9.3 Program Results Example Program Results Solution 2.0000 4.0000 2 -.0000 3.0000 3 2.0000 2.0000.5

NAG Library Manual 4-3.0000.0000 Estimate of condition number 9.7E+0 Estimate of error bound for computed solutions.e-4.6 (last)