1
c-----------------------------------------------------------------------
7
c Generate a random initial residual vector for the Arnoldi process.
8
c Force the residual vector to be in the range of the operator OP.
12
c ( IDO, BMAT, ITRY, INITV, N, J, V, LDV, RESID, RNORM,
13
c IPNTR, WORKD, IERR )
16
c IDO Integer. (INPUT/OUTPUT)
17
c Reverse communication flag. IDO must be zero on the first
19
c -------------------------------------------------------------
20
c IDO = 0: first call to the reverse communication interface
21
c IDO = -1: compute Y = OP * X where
22
c IPNTR(1) is the pointer into WORKD for X,
23
c IPNTR(2) is the pointer into WORKD for Y.
24
c This is for the initialization phase to force the
25
c starting vector into the range of OP.
26
c IDO = 2: compute Y = B * X where
27
c IPNTR(1) is the pointer into WORKD for X,
28
c IPNTR(2) is the pointer into WORKD for Y.
30
c -------------------------------------------------------------
32
c BMAT Character*1. (INPUT)
33
c BMAT specifies the type of the matrix B in the (generalized)
34
c eigenvalue problem A*x = lambda*B*x.
35
c B = 'I' -> standard eigenvalue problem A*x = lambda*x
36
c B = 'G' -> generalized eigenvalue problem A*x = lambda*B*x
38
c ITRY Integer. (INPUT)
39
c ITRY counts the number of times that dgetv0 is called.
40
c It should be set to 1 on the initial call to dgetv0.
42
c INITV Logical variable. (INPUT)
43
c .TRUE. => the initial residual vector is given in RESID.
44
c .FALSE. => generate a random initial residual vector.
47
c Dimension of the problem.
50
c Index of the residual vector to be generated, with respect to
51
c the Arnoldi process. J > 1 in case of a "restart".
53
c V Double precision N by J array. (INPUT)
54
c The first J-1 columns of V contain the current Arnoldi basis
55
c if this is a "restart".
57
c LDV Integer. (INPUT)
58
c Leading dimension of V exactly as declared in the calling
61
c RESID Double precision array of length N. (INPUT/OUTPUT)
62
c Initial residual vector to be generated. If RESID is
63
c provided, force RESID into the range of the operator OP.
65
c RNORM Double precision scalar. (OUTPUT)
66
c B-norm of the generated residual.
68
c IPNTR Integer array of length 3. (OUTPUT)
70
c WORKD Double precision work array of length 2*N. (REVERSE COMMUNICATION).
71
c On exit, WORK(1:N) = B*RESID to be used in SSAITR.
73
c IERR Integer. (OUTPUT)
75
c = -1: Cannot generate a nontrivial restarted residual vector
76
c in the range of the operator OP.
80
c-----------------------------------------------------------------------
88
c 1. D.C. Sorensen, "Implicit Application of Polynomial Filters in
89
c a k-Step Arnoldi Method", SIAM J. Matr. Anal. Apps., 13 (1992),
91
c 2. R.B. Lehoucq, "Analysis and Implementation of an Implicitly
92
c Restarted Arnoldi Iteration", Rice University Technical Report
93
c TR95-13, Department of Computational and Applied Mathematics.
96
c second ARPACK utility routine for timing.
97
c dvout ARPACK utility routine for vector output.
98
c dlarnv LAPACK routine for generating a random vector.
99
c dgemv Level 2 BLAS routine for matrix vector multiplication.
100
c dcopy Level 1 BLAS that copies one vector to another.
101
c ddot Level 1 BLAS that computes the scalar product of two vectors.
102
c dnrm2 Level 1 BLAS that computes the norm of a vector.
105
c Danny Sorensen Phuong Vu
106
c Richard Lehoucq CRPC / Rice University
107
c Dept. of Computational & Houston, Texas
108
c Applied Mathematics
112
c\SCCS Information: @(#)
113
c FILE: getv0.F SID: 2.7 DATE OF SID: 04/07/99 RELEASE: 2
117
c-----------------------------------------------------------------------
120
& ( ido, bmat, itry, initv, n, j, v, ldv, resid, rnorm,
121
& ipntr, workd, ierr )
123
c %----------------------------------------------------%
124
c | Include files for debugging and timing information |
125
c %----------------------------------------------------%
130
c %------------------%
131
c | Scalar Arguments |
132
c %------------------%
136
integer ido, ierr, itry, j, ldv, n
140
c %-----------------%
141
c | Array Arguments |
142
c %-----------------%
146
& resid(n), v(ldv,j), workd(2*n)
154
parameter (one = 1.0D+0, zero = 0.0D+0)
156
c %------------------------%
157
c | Local Scalars & Arrays |
158
c %------------------------%
160
logical first, inits, orth
161
integer idist, iseed(4), iter, msglvl, jj
164
save first, iseed, inits, iter, msglvl, orth, rnorm0
166
c %----------------------%
167
c | External Subroutines |
168
c %----------------------%
170
external dlarnv, dvout, dcopy, dgemv, second
172
c %--------------------%
173
c | External Functions |
174
c %--------------------%
180
c %---------------------%
181
c | Intrinsic Functions |
182
c %---------------------%
186
c %-----------------%
187
c | Data Statements |
188
c %-----------------%
192
c %-----------------------%
193
c | Executable Statements |
194
c %-----------------------%
197
c %-----------------------------------%
198
c | Initialize the seed of the LAPACK |
199
c | random number generator |
200
c %-----------------------------------%
212
c %-------------------------------%
213
c | Initialize timing statistics |
214
c | & message level for debugging |
215
c %-------------------------------%
225
c %-----------------------------------------------------%
226
c | Possibly generate a random starting vector in RESID |
227
c | Use a LAPACK random number generator used by the |
228
c | matrix generation routines. |
229
c | idist = 1: uniform (0,1) distribution; |
230
c | idist = 2: uniform (-1,1) distribution; |
231
c | idist = 3: normal (0,1) distribution; |
232
c %-----------------------------------------------------%
236
call dlarnv (idist, iseed, n, resid)
239
c %----------------------------------------------------------%
240
c | Force the starting vector into the range of OP to handle |
241
c | the generalized problem when B is possibly (singular). |
242
c %----------------------------------------------------------%
245
if (bmat .eq. 'G') then
249
call dcopy (n, resid, 1, workd, 1)
255
c %-----------------------------------------%
256
c | Back from computing OP*(initial-vector) |
257
c %-----------------------------------------%
261
c %-----------------------------------------------%
262
c | Back from computing B*(orthogonalized-vector) |
263
c %-----------------------------------------------%
267
if (bmat .eq. 'G') then
269
tmvopx = tmvopx + (t3 - t2)
272
c %------------------------------------------------------%
273
c | Starting vector is now in the range of OP; r = OP*r; |
274
c | Compute B-norm of starting vector. |
275
c %------------------------------------------------------%
279
if (bmat .eq. 'G') then
281
call dcopy (n, workd(n+1), 1, resid, 1)
286
else if (bmat .eq. 'I') then
287
call dcopy (n, resid, 1, workd, 1)
292
if (bmat .eq. 'G') then
294
tmvbx = tmvbx + (t3 - t2)
298
if (bmat .eq. 'G') then
299
rnorm0 = ddot (n, resid, 1, workd, 1)
300
rnorm0 = sqrt(abs(rnorm0))
301
else if (bmat .eq. 'I') then
302
rnorm0 = dnrm2(n, resid, 1)
306
c %---------------------------------------------%
307
c | Exit if this is the very first Arnoldi step |
308
c %---------------------------------------------%
310
if (j .eq. 1) go to 50
312
c %----------------------------------------------------------------
313
c | Otherwise need to B-orthogonalize the starting vector against |
314
c | the current Arnoldi basis using Gram-Schmidt with iter. ref. |
315
c | This is the case where an invariant subspace is encountered |
316
c | in the middle of the Arnoldi factorization. |
318
c | s = V^{T}*B*r; r = r - V*s; |
320
c | Stopping criteria used for iter. ref. is discussed in |
321
c | Parlett's book, page 107 and in Gragg & Reichel TOMS paper. |
322
c %---------------------------------------------------------------%
327
call dgemv ('T', n, j-1, one, v, ldv, workd, 1,
328
& zero, workd(n+1), 1)
329
call dgemv ('N', n, j-1, -one, v, ldv, workd(n+1), 1,
332
c %----------------------------------------------------------%
333
c | Compute the B-norm of the orthogonalized starting vector |
334
c %----------------------------------------------------------%
337
if (bmat .eq. 'G') then
339
call dcopy (n, resid, 1, workd(n+1), 1)
344
else if (bmat .eq. 'I') then
345
call dcopy (n, resid, 1, workd, 1)
350
if (bmat .eq. 'G') then
352
tmvbx = tmvbx + (t3 - t2)
355
if (bmat .eq. 'G') then
356
rnorm = ddot (n, resid, 1, workd, 1)
357
rnorm = sqrt(abs(rnorm))
358
else if (bmat .eq. 'I') then
359
rnorm = dnrm2(n, resid, 1)
362
c %--------------------------------------%
363
c | Check for further orthogonalization. |
364
c %--------------------------------------%
366
if (msglvl .gt. 2) then
367
call dvout (logfil, 1, rnorm0, ndigit,
368
& '_getv0: re-orthonalization ; rnorm0 is')
369
call dvout (logfil, 1, rnorm, ndigit,
370
& '_getv0: re-orthonalization ; rnorm is')
373
if (rnorm .gt. 0.717*rnorm0) go to 50
376
if (iter .le. 5) then
378
c %-----------------------------------%
379
c | Perform iterative refinement step |
380
c %-----------------------------------%
386
c %------------------------------------%
387
c | Iterative refinement step "failed" |
388
c %------------------------------------%
399
if (msglvl .gt. 0) then
400
call dvout (logfil, 1, rnorm, ndigit,
401
& '_getv0: B-norm of initial / restarted starting vector')
403
if (msglvl .gt. 3) then
404
call dvout (logfil, n, resid, ndigit,
405
& '_getv0: initial / restarted starting vector')
410
tgetv0 = tgetv0 + (t1 - t0)