dpofs.f 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. *DECK DPOFS
  2. SUBROUTINE DPOFS (A, LDA, N, V, ITASK, IND, WORK)
  3. C***BEGIN PROLOGUE DPOFS
  4. C***PURPOSE Solve a positive definite symmetric system of linear
  5. C equations.
  6. C***LIBRARY SLATEC
  7. C***CATEGORY D2B1B
  8. C***TYPE DOUBLE PRECISION (SPOFS-S, DPOFS-D, CPOFS-C)
  9. C***KEYWORDS HERMITIAN, LINEAR EQUATIONS, POSITIVE DEFINITE, SYMMETRIC
  10. C***AUTHOR Voorhees, E. A., (LANL)
  11. C***DESCRIPTION
  12. C
  13. C Subroutine DPOFS solves a positive definite symmetric
  14. C NxN system of double precision linear equations using
  15. C LINPACK subroutines DPOCO and DPOSL. That is, if A is an
  16. C NxN double precision positive definite symmetric matrix and if
  17. C X and B are double precision N-vectors, then DPOFS solves
  18. C the equation
  19. C
  20. C A*X=B.
  21. C
  22. C The matrix A is first factored into upper and lower tri-
  23. C angular matrices R and R-TRANPOSE. These factors are used to
  24. C find the solution vector X. An approximate condition number is
  25. C calculated to provide a rough estimate of the number of
  26. C digits of accuracy in the computed solution.
  27. C
  28. C If the equation A*X=B is to be solved for more than one vector
  29. C B, the factoring of A does not need to be performed again and
  30. C the option only to solve (ITASK .GT. 1) will be faster for
  31. C the succeeding solutions. In this case, the contents of A,
  32. C LDA, and N must not have been altered by the user following
  33. C factorization (ITASK=1). IND will not be changed by DPOFS
  34. C in this case.
  35. C
  36. C Argument Description ***
  37. C
  38. C A DOUBLE PRECISION(LDA,N)
  39. C on entry, the doubly subscripted array with dimension
  40. C (LDA,N) which contains the coefficient matrix. Only
  41. C the upper triangle, including the diagonal, of the
  42. C coefficient matrix need be entered and will subse-
  43. C quently be referenced and changed by the routine.
  44. C on return, A contains in its upper triangle an upper
  45. C triangular matrix R such that A = (R-TRANPOSE) * R .
  46. C LDA INTEGER
  47. C the leading dimension of the array A. LDA must be great-
  48. C er than or equal to N. (terminal error message IND=-1)
  49. C N INTEGER
  50. C the order of the matrix A. N must be greater
  51. C than or equal to 1. (terminal error message IND=-2)
  52. C V DOUBLE PRECISION(N)
  53. C on entry, the singly subscripted array(vector) of di-
  54. C mension N which contains the right hand side B of a
  55. C system of simultaneous linear equations A*X=B.
  56. C on return, V contains the solution vector, X .
  57. C ITASK INTEGER
  58. C If ITASK = 1, the matrix A is factored and then the
  59. C linear equation is solved.
  60. C If ITASK .GT. 1, the equation is solved using the existing
  61. C factored matrix A.
  62. C If ITASK .LT. 1, then terminal error message IND=-3 is
  63. C printed.
  64. C IND INTEGER
  65. C GT. 0 IND is a rough estimate of the number of digits
  66. C of accuracy in the solution, X.
  67. C LT. 0 See error message corresponding to IND below.
  68. C WORK DOUBLE PRECISION(N)
  69. C a singly subscripted array of dimension at least N.
  70. C
  71. C Error Messages Printed ***
  72. C
  73. C IND=-1 Terminal N is greater than LDA.
  74. C IND=-2 Terminal N is less than 1.
  75. C IND=-3 Terminal ITASK is less than 1.
  76. C IND=-4 Terminal The matrix A is computationally singular or
  77. C is not positive definite. A solution
  78. C has not been computed.
  79. C IND=-10 Warning The solution has no apparent significance.
  80. C The solution may be inaccurate or the
  81. C matrix A may be poorly scaled.
  82. C
  83. C Note- The above Terminal(*fatal*) Error Messages are
  84. C designed to be handled by XERMSG in which
  85. C LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0
  86. C for warning error messages from XERMSG. Unless
  87. C the user provides otherwise, an error message
  88. C will be printed followed by an abort.
  89. C
  90. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  91. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  92. C***ROUTINES CALLED D1MACH, DPOCO, DPOSL, XERMSG
  93. C***REVISION HISTORY (YYMMDD)
  94. C 800514 DATE WRITTEN
  95. C 890531 Changed all specific intrinsics to generic. (WRB)
  96. C 890831 Modified array declarations. (WRB)
  97. C 890831 REVISION DATE from Version 3.2
  98. C 891214 Prologue converted to Version 4.0 format. (BAB)
  99. C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
  100. C 900510 Convert XERRWV calls to XERMSG calls. (RWC)
  101. C 920501 Reformatted the REFERENCES section. (WRB)
  102. C***END PROLOGUE DPOFS
  103. C
  104. INTEGER LDA,N,ITASK,IND,INFO
  105. DOUBLE PRECISION A(LDA,*),V(*),WORK(*),D1MACH
  106. DOUBLE PRECISION RCOND
  107. CHARACTER*8 XERN1, XERN2
  108. C***FIRST EXECUTABLE STATEMENT DPOFS
  109. IF (LDA.LT.N) THEN
  110. IND = -1
  111. WRITE (XERN1, '(I8)') LDA
  112. WRITE (XERN2, '(I8)') N
  113. CALL XERMSG ('SLATEC', 'DPOFS', 'LDA = ' // XERN1 //
  114. * ' IS LESS THAN N = ' // XERN2, -1, 1)
  115. RETURN
  116. ENDIF
  117. C
  118. IF (N.LE.0) THEN
  119. IND = -2
  120. WRITE (XERN1, '(I8)') N
  121. CALL XERMSG ('SLATEC', 'DPOFS', 'N = ' // XERN1 //
  122. * ' IS LESS THAN 1', -2, 1)
  123. RETURN
  124. ENDIF
  125. C
  126. IF (ITASK.LT.1) THEN
  127. IND = -3
  128. WRITE (XERN1, '(I8)') ITASK
  129. CALL XERMSG ('SLATEC', 'DPOFS', 'ITASK = ' // XERN1 //
  130. * ' IS LESS THAN 1', -3, 1)
  131. RETURN
  132. ENDIF
  133. C
  134. IF (ITASK.EQ.1) THEN
  135. C
  136. C FACTOR MATRIX A INTO R
  137. C
  138. CALL DPOCO(A,LDA,N,RCOND,WORK,INFO)
  139. C
  140. C CHECK FOR POSITIVE DEFINITE MATRIX
  141. C
  142. IF (INFO.NE.0) THEN
  143. IND = -4
  144. CALL XERMSG ('SLATEC', 'DPOFS',
  145. * 'SINGULAR OR NOT POSITIVE DEFINITE - NO SOLUTION', -4, 1)
  146. RETURN
  147. ENDIF
  148. C
  149. C COMPUTE IND (ESTIMATE OF NO. OF SIGNIFICANT DIGITS)
  150. C AND CHECK FOR IND GREATER THAN ZERO
  151. C
  152. IND = -LOG10(D1MACH(4)/RCOND)
  153. IF (IND.EQ.0) THEN
  154. IND = -10
  155. CALL XERMSG ('SLATEC', 'DPOFS',
  156. * 'SOLUTION MAY HAVE NO SIGNIFICANCE', -10, 0)
  157. ENDIF
  158. ENDIF
  159. C
  160. C SOLVE AFTER FACTORING
  161. C
  162. CALL DPOSL(A,LDA,N,V)
  163. RETURN
  164. END