KTH framework for Nek5000 toolboxes; testing version  0.0.1
zlacon.f
Go to the documentation of this file.
1  SUBROUTINE zlacon( N, V, X, EST, KASE )
2 *
3 * -- LAPACK auxiliary routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * June 30, 1999
7 *
8 * .. Scalar Arguments ..
9  INTEGER KASE, N
10  DOUBLE PRECISION EST
11 * ..
12 * .. Array Arguments ..
13  COMPLEX*16 V( N ), X( N )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * ZLACON estimates the 1-norm of a square, complex matrix A.
20 * Reverse communication is used for evaluating matrix-vector products.
21 *
22 * Arguments
23 * =========
24 *
25 * N (input) INTEGER
26 * The order of the matrix. N >= 1.
27 *
28 * V (workspace) COMPLEX*16 array, dimension (N)
29 * On the final return, V = A*W, where EST = norm(V)/norm(W)
30 * (W is not returned).
31 *
32 * X (input/output) COMPLEX*16 array, dimension (N)
33 * On an intermediate return, X should be overwritten by
34 * A * X, if KASE=1,
35 * A' * X, if KASE=2,
36 * where A' is the conjugate transpose of A, and ZLACON must be
37 * re-called with all the other parameters unchanged.
38 *
39 * EST (output) DOUBLE PRECISION
40 * An estimate (a lower bound) for norm(A).
41 *
42 * KASE (input/output) INTEGER
43 * On the initial call to ZLACON, KASE should be 0.
44 * On an intermediate return, KASE will be 1 or 2, indicating
45 * whether X should be overwritten by A * X or A' * X.
46 * On the final return from ZLACON, KASE will again be 0.
47 *
48 * Further Details
49 * ======= =======
50 *
51 * Contributed by Nick Higham, University of Manchester.
52 * Originally named CONEST, dated March 16, 1988.
53 *
54 * Reference: N.J. Higham, "FORTRAN codes for estimating the one-norm of
55 * a real or complex matrix, with applications to condition estimation",
56 * ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.
57 *
58 * Last modified: April, 1999
59 *
60 * =====================================================================
61 *
62 * .. Parameters ..
63  INTEGER ITMAX
64  parameter( itmax = 5 )
65  DOUBLE PRECISION ONE, TWO
66  parameter( one = 1.0d0, two = 2.0d0 )
67  COMPLEX*16 CZERO, CONE
68  parameter( czero = ( 0.0d0, 0.0d0 ),
69  $ cone = ( 1.0d0, 0.0d0 ) )
70 * ..
71 * .. Local Scalars ..
72  INTEGER I, ITER, J, JLAST, JUMP
73  DOUBLE PRECISION ABSXI, ALTSGN, ESTOLD, SAFMIN, TEMP
74 * ..
75 * .. External Functions ..
76  INTEGER IZMAX1
77  DOUBLE PRECISION DLAMCH, DZSUM1
78  EXTERNAL izmax1, dlamch, dzsum1
79 * ..
80 * .. External Subroutines ..
81  EXTERNAL zcopy
82 * ..
83 * .. Intrinsic Functions ..
84  INTRINSIC abs, dble, dcmplx, dimag
85 * ..
86 * .. Save statement ..
87  SAVE
88 * ..
89 * .. Executable Statements ..
90 *
91  safmin = dlamch( 'Safe minimum' )
92  IF( kase.EQ.0 ) THEN
93  DO 10 i = 1, n
94  x( i ) = dcmplx( one / dble( n ) )
95  10 CONTINUE
96  kase = 1
97  jump = 1
98  RETURN
99  END IF
100 *
101  GO TO ( 20, 40, 70, 90, 120 )jump
102 *
103 * ................ ENTRY (JUMP = 1)
104 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X.
105 *
106  20 CONTINUE
107  IF( n.EQ.1 ) THEN
108  v( 1 ) = x( 1 )
109  est = abs( v( 1 ) )
110 * ... QUIT
111  GO TO 130
112  END IF
113  est = dzsum1( n, x, 1 )
114 *
115  DO 30 i = 1, n
116  absxi = abs( x( i ) )
117  IF( absxi.GT.safmin ) THEN
118  x( i ) = dcmplx( dble( x( i ) ) / absxi,
119  $ dimag( x( i ) ) / absxi )
120  ELSE
121  x( i ) = cone
122  END IF
123  30 CONTINUE
124  kase = 2
125  jump = 2
126  RETURN
127 *
128 * ................ ENTRY (JUMP = 2)
129 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY ZTRANS(A)*X.
130 *
131  40 CONTINUE
132  j = izmax1( n, x, 1 )
133  iter = 2
134 *
135 * MAIN LOOP - ITERATIONS 2,3,...,ITMAX.
136 *
137  50 CONTINUE
138  DO 60 i = 1, n
139  x( i ) = czero
140  60 CONTINUE
141  x( j ) = cone
142  kase = 1
143  jump = 3
144  RETURN
145 *
146 * ................ ENTRY (JUMP = 3)
147 * X HAS BEEN OVERWRITTEN BY A*X.
148 *
149  70 CONTINUE
150  CALL zcopy( n, x, 1, v, 1 )
151  estold = est
152  est = dzsum1( n, v, 1 )
153 *
154 * TEST FOR CYCLING.
155  IF( est.LE.estold )
156  $ GO TO 100
157 *
158  DO 80 i = 1, n
159  absxi = abs( x( i ) )
160  IF( absxi.GT.safmin ) THEN
161  x( i ) = dcmplx( dble( x( i ) ) / absxi,
162  $ dimag( x( i ) ) / absxi )
163  ELSE
164  x( i ) = cone
165  END IF
166  80 CONTINUE
167  kase = 2
168  jump = 4
169  RETURN
170 *
171 * ................ ENTRY (JUMP = 4)
172 * X HAS BEEN OVERWRITTEN BY ZTRANS(A)*X.
173 *
174  90 CONTINUE
175  jlast = j
176  j = izmax1( n, x, 1 )
177  IF( ( abs( x( jlast ) ).NE.abs( x( j ) ) ) .AND.
178  $ ( iter.LT.itmax ) ) THEN
179  iter = iter + 1
180  GO TO 50
181  END IF
182 *
183 * ITERATION COMPLETE. FINAL STAGE.
184 *
185  100 CONTINUE
186  altsgn = one
187  DO 110 i = 1, n
188  x( i ) = dcmplx( altsgn*( one+dble( i-1 ) / dble( n-1 ) ) )
189  altsgn = -altsgn
190  110 CONTINUE
191  kase = 1
192  jump = 5
193  RETURN
194 *
195 * ................ ENTRY (JUMP = 5)
196 * X HAS BEEN OVERWRITTEN BY A*X.
197 *
198  120 CONTINUE
199  temp = two*( dzsum1( n, x, 1 ) / dble( 3*n ) )
200  IF( temp.GT.est ) THEN
201  CALL zcopy( n, x, 1, v, 1 )
202  est = temp
203  END IF
204 *
205  130 CONTINUE
206  kase = 0
207  RETURN
208 *
209 * End of ZLACON
210 *
211  END
subroutine zcopy(n, zx, incx, zy, incy)
Definition: zcopy.f:2
subroutine zlacon(N, V, X, EST, KASE)
Definition: zlacon.f:2