ds2lt.f 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. *DECK DS2LT
  2. SUBROUTINE DS2LT (N, NELT, IA, JA, A, ISYM, NEL, IEL, JEL, EL)
  3. C***BEGIN PROLOGUE DS2LT
  4. C***PURPOSE Lower Triangle Preconditioner SLAP Set Up.
  5. C Routine to store the lower triangle of a matrix stored
  6. C in the SLAP Column format.
  7. C***LIBRARY SLATEC (SLAP)
  8. C***CATEGORY D2E
  9. C***TYPE DOUBLE PRECISION (SS2LT-S, DS2LT-D)
  10. C***KEYWORDS LINEAR SYSTEM, LOWER TRIANGLE, SLAP SPARSE
  11. C***AUTHOR Greenbaum, Anne, (Courant Institute)
  12. C Seager, Mark K., (LLNL)
  13. C Lawrence Livermore National Laboratory
  14. C PO BOX 808, L-60
  15. C Livermore, CA 94550 (510) 423-3141
  16. C seager@llnl.gov
  17. C***DESCRIPTION
  18. C
  19. C *Usage:
  20. C INTEGER N, NELT, IA(NELT), JA(NELT), ISYM
  21. C INTEGER NEL, IEL(NEL), JEL(NEL)
  22. C DOUBLE PRECISION A(NELT), EL(NEL)
  23. C
  24. C CALL DS2LT( N, NELT, IA, JA, A, ISYM, NEL, IEL, JEL, EL )
  25. C
  26. C *Arguments:
  27. C N :IN Integer
  28. C Order of the Matrix.
  29. C NELT :IN Integer.
  30. C Number of non-zeros stored in A.
  31. C IA :IN Integer IA(NELT).
  32. C JA :IN Integer JA(NELT).
  33. C A :IN Double Precision A(NELT).
  34. C These arrays should hold the matrix A in the SLAP Column
  35. C format. See "Description", below.
  36. C ISYM :IN Integer.
  37. C Flag to indicate symmetric storage format.
  38. C If ISYM=0, all non-zero entries of the matrix are stored.
  39. C If ISYM=1, the matrix is symmetric, and only the lower
  40. C triangle of the matrix is stored.
  41. C NEL :OUT Integer.
  42. C Number of non-zeros in the lower triangle of A. Also
  43. C corresponds to the length of the IEL, JEL, EL arrays.
  44. C IEL :OUT Integer IEL(NEL).
  45. C JEL :OUT Integer JEL(NEL).
  46. C EL :OUT Double Precision EL(NEL).
  47. C IEL, JEL, EL contain the lower triangle of the A matrix
  48. C stored in SLAP Column format. See "Description", below,
  49. C for more details bout the SLAP Column format.
  50. C
  51. C *Description
  52. C =================== S L A P Column format ==================
  53. C This routine requires that the matrix A be stored in the
  54. C SLAP Column format. In this format the non-zeros are stored
  55. C counting down columns (except for the diagonal entry, which
  56. C must appear first in each "column") and are stored in the
  57. C double precision array A. In other words, for each column
  58. C in the matrix put the diagonal entry in A. Then put in the
  59. C other non-zero elements going down the column (except the
  60. C diagonal) in order. The IA array holds the row index for
  61. C each non-zero. The JA array holds the offsets into the IA,
  62. C A arrays for the beginning of each column. That is,
  63. C IA(JA(ICOL)), A(JA(ICOL)) points to the beginning of the
  64. C ICOL-th column in IA and A. IA(JA(ICOL+1)-1),
  65. C A(JA(ICOL+1)-1) points to the end of the ICOL-th column.
  66. C Note that we always have JA(N+1) = NELT+1, where N is the
  67. C number of columns in the matrix and NELT is the number of
  68. C non-zeros in the matrix.
  69. C
  70. C Here is an example of the SLAP Column storage format for a
  71. C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
  72. C column):
  73. C
  74. C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
  75. C 1 2 3 4 5 6 7 8 9 10 11
  76. C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
  77. C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
  78. C | 0 0 33 0 35| JA: 1 4 6 8 9 12
  79. C | 0 0 0 44 0|
  80. C |51 0 53 0 55|
  81. C
  82. C***REFERENCES (NONE)
  83. C***ROUTINES CALLED (NONE)
  84. C***REVISION HISTORY (YYMMDD)
  85. C 890404 DATE WRITTEN
  86. C 890404 Previous REVISION DATE
  87. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  88. C 890922 Numerous changes to prologue to make closer to SLATEC
  89. C standard. (FNF)
  90. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  91. C 910411 Prologue converted to Version 4.0 format. (BAB)
  92. C 920511 Added complete declaration section. (WRB)
  93. C 930701 Updated CATEGORY section. (FNF, WRB)
  94. C***END PROLOGUE DS2LT
  95. C .. Scalar Arguments ..
  96. INTEGER ISYM, N, NEL, NELT
  97. C .. Array Arguments ..
  98. DOUBLE PRECISION A(NELT), EL(NELT)
  99. INTEGER IA(NELT), IEL(NEL), JA(NELT), JEL(NEL)
  100. C .. Local Scalars ..
  101. INTEGER I, ICOL, J, JBGN, JEND
  102. C***FIRST EXECUTABLE STATEMENT DS2LT
  103. IF( ISYM.EQ.0 ) THEN
  104. C
  105. C The matrix is stored non-symmetricly. Pick out the lower
  106. C triangle.
  107. C
  108. NEL = 0
  109. DO 20 ICOL = 1, N
  110. JEL(ICOL) = NEL+1
  111. JBGN = JA(ICOL)
  112. JEND = JA(ICOL+1)-1
  113. CVD$ NOVECTOR
  114. DO 10 J = JBGN, JEND
  115. IF( IA(J).GE.ICOL ) THEN
  116. NEL = NEL + 1
  117. IEL(NEL) = IA(J)
  118. EL(NEL) = A(J)
  119. ENDIF
  120. 10 CONTINUE
  121. 20 CONTINUE
  122. JEL(N+1) = NEL+1
  123. ELSE
  124. C
  125. C The matrix is symmetric and only the lower triangle is
  126. C stored. Copy it to IEL, JEL, EL.
  127. C
  128. NEL = NELT
  129. DO 30 I = 1, NELT
  130. IEL(I) = IA(I)
  131. EL(I) = A(I)
  132. 30 CONTINUE
  133. DO 40 I = 1, N+1
  134. JEL(I) = JA(I)
  135. 40 CONTINUE
  136. ENDIF
  137. RETURN
  138. C------------- LAST LINE OF DS2LT FOLLOWS ----------------------------
  139. END