cpofs.f 6.4 KB

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