cpofa.f 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. *DECK CPOFA
  2. SUBROUTINE CPOFA (A, LDA, N, INFO)
  3. C***BEGIN PROLOGUE CPOFA
  4. C***PURPOSE Factor a complex Hermitian positive definite matrix.
  5. C***LIBRARY SLATEC (LINPACK)
  6. C***CATEGORY D2D1B
  7. C***TYPE COMPLEX (SPOFA-S, DPOFA-D, CPOFA-C)
  8. C***KEYWORDS LINEAR ALGEBRA, LINPACK, MATRIX FACTORIZATION,
  9. C POSITIVE DEFINITE
  10. C***AUTHOR Moler, C. B., (U. of New Mexico)
  11. C***DESCRIPTION
  12. C
  13. C CPOFA factors a complex Hermitian positive definite matrix.
  14. C
  15. C CPOFA is usually called by CPOCO, but it can be called
  16. C directly with a saving in time if RCOND is not needed.
  17. C (Time for CPOCO) = (1 + 18/N)*(Time for CPOFA) .
  18. C
  19. C On Entry
  20. C
  21. C A COMPLEX(LDA, N)
  22. C the Hermitian matrix to be factored. Only the
  23. C diagonal and upper triangle are used.
  24. C
  25. C LDA INTEGER
  26. C the leading dimension of the array A .
  27. C
  28. C N INTEGER
  29. C the order of the matrix A .
  30. C
  31. C On Return
  32. C
  33. C A an upper triangular matrix R so that A =
  34. C CTRANS(R)*R where CTRANS(R) is the conjugate
  35. C transpose. The strict lower triangle is unaltered.
  36. C If INFO .NE. 0 , the factorization is not complete.
  37. C
  38. C INFO INTEGER
  39. C = 0 for normal return.
  40. C = K signals an error condition. The leading minor
  41. C of order K is not positive definite.
  42. C
  43. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  44. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  45. C***ROUTINES CALLED CDOTC
  46. C***REVISION HISTORY (YYMMDD)
  47. C 780814 DATE WRITTEN
  48. C 890831 Modified array declarations. (WRB)
  49. C 890831 REVISION DATE from Version 3.2
  50. C 891214 Prologue converted to Version 4.0 format. (BAB)
  51. C 900326 Removed duplicate information from DESCRIPTION section.
  52. C (WRB)
  53. C 920501 Reformatted the REFERENCES section. (WRB)
  54. C***END PROLOGUE CPOFA
  55. INTEGER LDA,N,INFO
  56. COMPLEX A(LDA,*)
  57. C
  58. COMPLEX CDOTC,T
  59. REAL S
  60. INTEGER J,JM1,K
  61. C***FIRST EXECUTABLE STATEMENT CPOFA
  62. DO 30 J = 1, N
  63. INFO = J
  64. S = 0.0E0
  65. JM1 = J - 1
  66. IF (JM1 .LT. 1) GO TO 20
  67. DO 10 K = 1, JM1
  68. T = A(K,J) - CDOTC(K-1,A(1,K),1,A(1,J),1)
  69. T = T/A(K,K)
  70. A(K,J) = T
  71. S = S + REAL(T*CONJG(T))
  72. 10 CONTINUE
  73. 20 CONTINUE
  74. S = REAL(A(J,J)) - S
  75. IF (S .LE. 0.0E0 .OR. AIMAG(A(J,J)) .NE. 0.0E0) GO TO 40
  76. A(J,J) = CMPLX(SQRT(S),0.0E0)
  77. 30 CONTINUE
  78. INFO = 0
  79. 40 CONTINUE
  80. RETURN
  81. END