dppfa.f 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. *DECK DPPFA
  2. SUBROUTINE DPPFA (AP, N, INFO)
  3. C***BEGIN PROLOGUE DPPFA
  4. C***PURPOSE Factor a real symmetric positive definite matrix stored in
  5. C packed form.
  6. C***LIBRARY SLATEC (LINPACK)
  7. C***CATEGORY D2B1B
  8. C***TYPE DOUBLE PRECISION (SPPFA-S, DPPFA-D, CPPFA-C)
  9. C***KEYWORDS LINEAR ALGEBRA, LINPACK, MATRIX FACTORIZATION, PACKED,
  10. C POSITIVE DEFINITE
  11. C***AUTHOR Moler, C. B., (U. of New Mexico)
  12. C***DESCRIPTION
  13. C
  14. C DPPFA factors a double precision symmetric positive definite
  15. C matrix stored in packed form.
  16. C
  17. C DPPFA is usually called by DPPCO, but it can be called
  18. C directly with a saving in time if RCOND is not needed.
  19. C (time for DPPCO) = (1 + 18/N)*(time for DPPFA) .
  20. C
  21. C On Entry
  22. C
  23. C AP DOUBLE PRECISION (N*(N+1)/2)
  24. C the packed form of a symmetric matrix A . The
  25. C columns of the upper triangle are stored sequentially
  26. C in a one-dimensional array of length N*(N+1)/2 .
  27. C See comments below for details.
  28. C
  29. C N INTEGER
  30. C the order of the matrix A .
  31. C
  32. C On Return
  33. C
  34. C AP an upper triangular matrix R , stored in packed
  35. C form, so that A = TRANS(R)*R .
  36. C
  37. C INFO INTEGER
  38. C = 0 for normal return.
  39. C = K if the leading minor of order K is not
  40. C positive definite.
  41. C
  42. C
  43. C Packed Storage
  44. C
  45. C The following program segment will pack the upper
  46. C triangle of a symmetric matrix.
  47. C
  48. C K = 0
  49. C DO 20 J = 1, N
  50. C DO 10 I = 1, J
  51. C K = K + 1
  52. C AP(K) = A(I,J)
  53. C 10 CONTINUE
  54. C 20 CONTINUE
  55. C
  56. C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
  57. C Stewart, LINPACK Users' Guide, SIAM, 1979.
  58. C***ROUTINES CALLED DDOT
  59. C***REVISION HISTORY (YYMMDD)
  60. C 780814 DATE WRITTEN
  61. C 890531 Changed all specific intrinsics to generic. (WRB)
  62. C 890831 Modified array declarations. (WRB)
  63. C 890831 REVISION DATE from Version 3.2
  64. C 891214 Prologue converted to Version 4.0 format. (BAB)
  65. C 900326 Removed duplicate information from DESCRIPTION section.
  66. C (WRB)
  67. C 920501 Reformatted the REFERENCES section. (WRB)
  68. C***END PROLOGUE DPPFA
  69. INTEGER N,INFO
  70. DOUBLE PRECISION AP(*)
  71. C
  72. DOUBLE PRECISION DDOT,T
  73. DOUBLE PRECISION S
  74. INTEGER J,JJ,JM1,K,KJ,KK
  75. C***FIRST EXECUTABLE STATEMENT DPPFA
  76. JJ = 0
  77. DO 30 J = 1, N
  78. INFO = J
  79. S = 0.0D0
  80. JM1 = J - 1
  81. KJ = JJ
  82. KK = 0
  83. IF (JM1 .LT. 1) GO TO 20
  84. DO 10 K = 1, JM1
  85. KJ = KJ + 1
  86. T = AP(KJ) - DDOT(K-1,AP(KK+1),1,AP(JJ+1),1)
  87. KK = KK + K
  88. T = T/AP(KK)
  89. AP(KJ) = T
  90. S = S + T*T
  91. 10 CONTINUE
  92. 20 CONTINUE
  93. JJ = JJ + J
  94. S = AP(JJ) - S
  95. IF (S .LE. 0.0D0) GO TO 40
  96. AP(JJ) = SQRT(S)
  97. 30 CONTINUE
  98. INFO = 0
  99. 40 CONTINUE
  100. RETURN
  101. END