Debian Codegraph @

Modules/ThirdParty/VNL/src/vxl/v3p/netlib/arpack/dsgets.f

raw
1 c-----------------------------------------------------------------------
2 c\BeginDoc
3 c
4 c\Name: dsgets
5 c
6 c\Description:
7 c Given the eigenvalues of the symmetric tridiagonal matrix H,
8 c computes the NP shifts AMU that are zeros of the polynomial of
9 c degree NP which filters out components of the unwanted eigenvectors
10 c corresponding to the AMU's based on some given criteria.
11 c
12 c NOTE: This is called even in the case of user specified shifts in
13 c order to sort the eigenvalues, and error bounds of H for later use.
14 c
15 c\Usage:
16 c call dsgets
17 c ( ISHIFT, WHICH, KEV, NP, RITZ, BOUNDS, SHIFTS )
18 c
19 c\Arguments
20 c ISHIFT Integer. (INPUT)
21 c Method for selecting the implicit shifts at each iteration.
22 c ISHIFT = 0: user specified shifts
23 c ISHIFT = 1: exact shift with respect to the matrix H.
24 c
25 c WHICH Character*2. (INPUT)
26 c Shift selection criteria.
27 c 'LM' -> KEV eigenvalues of largest magnitude are retained.
28 c 'SM' -> KEV eigenvalues of smallest magnitude are retained.
29 c 'LA' -> KEV eigenvalues of largest value are retained.
30 c 'SA' -> KEV eigenvalues of smallest value are retained.
31 c 'BE' -> KEV eigenvalues, half from each end of the spectrum.
32 c If KEV is odd, compute one more from the high end.
33 c
34 c KEV Integer. (INPUT)
35 c KEV+NP is the size of the matrix H.
36 c
37 c NP Integer. (INPUT)
38 c Number of implicit shifts to be computed.
39 c
40 c RITZ Double precision array of length KEV+NP. (INPUT/OUTPUT)
41 c On INPUT, RITZ contains the eigenvalues of H.
42 c On OUTPUT, RITZ are sorted so that the unwanted eigenvalues
43 c are in the first NP locations and the wanted part is in
44 c the last KEV locations. When exact shifts are selected, the
45 c unwanted part corresponds to the shifts to be applied.
46 c
47 c BOUNDS Double precision array of length KEV+NP. (INPUT/OUTPUT)
48 c Error bounds corresponding to the ordering in RITZ.
49 c
50 c SHIFTS Double precision array of length NP. (INPUT/OUTPUT)
51 c On INPUT: contains the user specified shifts if ISHIFT = 0.
52 c On OUTPUT: contains the shifts sorted into decreasing order
53 c of magnitude with respect to the Ritz estimates contained in
54 c BOUNDS. If ISHIFT = 0, SHIFTS is not modified on exit.
55 c
56 c\EndDoc
57 c
58 c-----------------------------------------------------------------------
59 c
60 c\BeginLib
61 c
62 c\Local variables:
63 c xxxxxx real
64 c
65 c\Routines called:
66 c dsortr ARPACK utility sorting routine.
67 c second ARPACK utility routine for timing.
68 c dcopy Level 1 BLAS that copies one vector to another.
69 c dswap Level 1 BLAS that swaps the contents of two vectors.
70 c
71 c\Author
72 c Danny Sorensen Phuong Vu
73 c Richard Lehoucq CRPC / Rice University
74 c Dept. of Computational & Houston, Texas
75 c Applied Mathematics
76 c Rice University
77 c Houston, Texas
78 c
79 c\Revision history:
80 c xx/xx/93: Version ' 2.1'
81 c
82 c\SCCS Information: @(#)
83 c FILE: sgets.F SID: 2.4 DATE OF SID: 4/19/96 RELEASE: 2
84 c
85 c\Remarks
86 c
87 c\EndLib
88 c
89 c-----------------------------------------------------------------------
90 c
91 subroutine dsgets ( ishift, which, kev, np, ritz, bounds, shifts )
92 c
93 c %----------------------------------------------------%
94 c | Include files for debugging and timing information |
95 c %----------------------------------------------------%
96 c
97 include 'debug.h'
98 include 'stat.h'
99 c
100 c %------------------%
101 c | Scalar Arguments |
102 c %------------------%
103 c
104 character*2 which
105 integer ishift, kev, np
106 c
107 c %-----------------%
108 c | Array Arguments |
109 c %-----------------%
110 c
111 Double precision
112 & bounds(kev+np), ritz(kev+np), shifts(np)
113 c
114 c %------------%
115 c | Parameters |
116 c %------------%
117 c
118 Double precision
119 & one, zero
120 parameter (one = 1.0D+0, zero = 0.0D+0)
121 c
122 c %---------------%
123 c | Local Scalars |
124 c %---------------%
125 c
126 integer kevd2, msglvl
127 c
128 c %----------------------%
129 c | External Subroutines |
130 c %----------------------%
131 c
132 external dswap, dcopy, dsortr, second
133 c
134 c %---------------------%
135 c | Intrinsic Functions |
136 c %---------------------%
137 c
138 intrinsic max, min
139 c
140 c %-----------------------%
141 c | Executable Statements |
142 c %-----------------------%
143 c
144 c %-------------------------------%
145 c | Initialize timing statistics |
146 c | & message level for debugging |
147 c %-------------------------------%
148 c
149 call second (t0)
150 msglvl = msgets
151 c
152 if (which .eq. 'BE') then
153 c
154 c %-----------------------------------------------------%
155 c | Both ends of the spectrum are requested. |
156 c | Sort the eigenvalues into algebraically increasing |
157 c | order first then swap high end of the spectrum next |
158 c | to low end in appropriate locations. |
159 c | NOTE: when np < floor(kev/2) be careful not to swap |
160 c | overlapping locations. |
161 c %-----------------------------------------------------%
162 c
163 call dsortr ('LA', .true., kev+np, ritz, bounds)
164 kevd2 = kev / 2
165 if ( kev .gt. 1 ) then
166 call dswap ( min(kevd2,np), ritz, 1,
167 & ritz( max(kevd2,np)+1 ), 1)
168 call dswap ( min(kevd2,np), bounds, 1,
169 & bounds( max(kevd2,np)+1 ), 1)
170 end if
171 c
172 else
173 c
174 c %----------------------------------------------------%
175 c | LM, SM, LA, SA case. |
176 c | Sort the eigenvalues of H into the desired order |
177 c | and apply the resulting order to BOUNDS. |
178 c | The eigenvalues are sorted so that the wanted part |
179 c | are always in the last KEV locations. |
180 c %----------------------------------------------------%
181 c
182 call dsortr (which, .true., kev+np, ritz, bounds)
183 end if
184 c
185 if (ishift .eq. 1 .and. np .gt. 0) then
186 c
187 c %-------------------------------------------------------%
188 c | Sort the unwanted Ritz values used as shifts so that |
189 c | the ones with largest Ritz estimates are first. |
190 c | This will tend to minimize the effects of the |
191 c | forward instability of the iteration when the shifts |
192 c | are applied in subroutine dsapps. |
193 c %-------------------------------------------------------%
194 c
195 call dsortr ('SM', .true., np, bounds, ritz)
196 call dcopy (np, ritz, 1, shifts, 1)
197 end if
198 c
199 call second (t1)
200 tsgets = tsgets + (t1 - t0)
201 c
202 c if (msglvl .gt. 0) then
203 c call ivout (logfil, 1, kev, ndigit, '_sgets: KEV is')
204 c call ivout (logfil, 1, np, ndigit, '_sgets: NP is')
205 c call dvout (logfil, kev+np, ritz, ndigit,
206 c & '_sgets: Eigenvalues of current H matrix')
207 c call dvout (logfil, kev+np, bounds, ndigit,
208 c & '_sgets: Associated Ritz estimates')
209 c end if
210 c
211 return
212 c
213 c %---------------%
214 c | End of dsgets |
215 c %---------------%
216 c
217 end