ss2lt.f 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. *DECK SS2LT
  2. SUBROUTINE SS2LT (N, NELT, IA, JA, A, ISYM, NEL, IEL, JEL, EL)
  3. C***BEGIN PROLOGUE SS2LT
  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 SINGLE 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 REAL A(NELT), EL(NEL)
  23. C
  24. C CALL SS2LT( 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 Real 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 Real 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 real array A. In other words, for each column in the matrix
  58. C put the diagonal entry in A. Then put in the other non-zero
  59. C elements going down the column (except the diagonal) in
  60. C order. The IA array holds the row index for each non-zero.
  61. C The JA array holds the offsets into the IA, A arrays for the
  62. C beginning of each column. That is, IA(JA(ICOL)),
  63. C A(JA(ICOL)) points to the beginning of the ICOL-th column in
  64. C IA and A. IA(JA(ICOL+1)-1), A(JA(ICOL+1)-1) points to the
  65. C end of the ICOL-th column. Note that we always have
  66. C JA(N+1) = NELT+1, where N is the number of columns in the
  67. C matrix and NELT is the number of non-zeros in the matrix.
  68. C
  69. C Here is an example of the SLAP Column storage format for a
  70. C 5x5 Matrix (in the A and IA arrays '|' denotes the end of a
  71. C column):
  72. C
  73. C 5x5 Matrix SLAP Column format for 5x5 matrix on left.
  74. C 1 2 3 4 5 6 7 8 9 10 11
  75. C |11 12 0 0 15| A: 11 21 51 | 22 12 | 33 53 | 44 | 55 15 35
  76. C |21 22 0 0 0| IA: 1 2 5 | 2 1 | 3 5 | 4 | 5 1 3
  77. C | 0 0 33 0 35| JA: 1 4 6 8 9 12
  78. C | 0 0 0 44 0|
  79. C |51 0 53 0 55|
  80. C
  81. C***REFERENCES (NONE)
  82. C***ROUTINES CALLED (NONE)
  83. C***REVISION HISTORY (YYMMDD)
  84. C 871119 DATE WRITTEN
  85. C 881213 Previous REVISION DATE
  86. C 890915 Made changes requested at July 1989 CML Meeting. (MKS)
  87. C 890922 Numerous changes to prologue to make closer to SLATEC
  88. C standard. (FNF)
  89. C 890929 Numerous changes to reduce SP/DP differences. (FNF)
  90. C 910411 Prologue converted to Version 4.0 format. (BAB)
  91. C 920511 Added complete declaration section. (WRB)
  92. C 930701 Updated CATEGORY section. (FNF, WRB)
  93. C***END PROLOGUE SS2LT
  94. C .. Scalar Arguments ..
  95. INTEGER ISYM, N, NEL, NELT
  96. C .. Array Arguments ..
  97. REAL A(NELT), EL(NELT)
  98. INTEGER IA(NELT), IEL(NEL), JA(NELT), JEL(NEL)
  99. C .. Local Scalars ..
  100. INTEGER I, ICOL, J, JBGN, JEND
  101. C***FIRST EXECUTABLE STATEMENT SS2LT
  102. IF( ISYM.EQ.0 ) THEN
  103. C
  104. C The matrix is stored non-symmetricly. Pick out the lower
  105. C triangle.
  106. C
  107. NEL = 0
  108. DO 20 ICOL = 1, N
  109. JEL(ICOL) = NEL+1
  110. JBGN = JA(ICOL)
  111. JEND = JA(ICOL+1)-1
  112. CVD$ NOVECTOR
  113. DO 10 J = JBGN, JEND
  114. IF( IA(J).GE.ICOL ) THEN
  115. NEL = NEL + 1
  116. IEL(NEL) = IA(J)
  117. EL(NEL) = A(J)
  118. ENDIF
  119. 10 CONTINUE
  120. 20 CONTINUE
  121. JEL(N+1) = NEL+1
  122. ELSE
  123. C
  124. C The matrix is symmetric and only the lower triangle is
  125. C stored. Copy it to IEL, JEL, EL.
  126. C
  127. NEL = NELT
  128. DO 30 I = 1, NELT
  129. IEL(I) = IA(I)
  130. EL(I) = A(I)
  131. 30 CONTINUE
  132. DO 40 I = 1, N+1
  133. JEL(I) = JA(I)
  134. 40 CONTINUE
  135. ENDIF
  136. RETURN
  137. C------------- LAST LINE OF SS2LT FOLLOWS ----------------------------
  138. END