1 *> \brief \b CLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vector products.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download CLACN2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/clacn2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/clacn2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/clacn2.f">
21 * SUBROUTINE CLACN2( N, V, X, EST, KASE, ISAVE )
23 * .. Scalar Arguments ..
27 * .. Array Arguments ..
29 * COMPLEX V( * ), X( * )
38 *> CLACN2 estimates the 1-norm of a square, complex matrix A.
39 *> Reverse communication is used for evaluating matrix-vector products.
48 *> The order of the matrix. N >= 1.
53 *> V is COMPLEX array, dimension (N)
54 *> On the final return, V = A*W, where EST = norm(V)/norm(W)
55 *> (W is not returned).
60 *> X is COMPLEX array, dimension (N)
61 *> On an intermediate return, X should be overwritten by
63 *> A**H * X, if KASE=2,
64 *> where A**H is the conjugate transpose of A, and CLACN2 must be
65 *> re-called with all the other parameters unchanged.
71 *> On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be
72 *> unchanged from the previous call to CLACN2.
73 *> On exit, EST is an estimate (a lower bound) for norm(A).
76 *> \param[in,out] KASE
79 *> On the initial call to CLACN2, KASE should be 0.
80 *> On an intermediate return, KASE will be 1 or 2, indicating
81 *> whether X should be overwritten by A * X or A**H * X.
82 *> On the final return from CLACN2, KASE will again be 0.
85 *> \param[in,out] ISAVE
87 *> ISAVE is INTEGER array, dimension (3)
88 *> ISAVE is used to save variables between calls to SLACN2
94 *> \author Univ. of Tennessee
95 *> \author Univ. of California Berkeley
96 *> \author Univ. of Colorado Denver
99 *> \date September 2012
101 *> \ingroup complexOTHERauxiliary
103 *> \par Further Details:
104 * =====================
108 *> Originally named CONEST, dated March 16, 1988.
110 *> Last modified: April, 1999
112 *> This is a thread safe version of CLACON, which uses the array ISAVE
113 *> in place of a SAVE statement, as follows:
121 *> \par Contributors:
124 *> Nick Higham, University of Manchester
129 *> N.J. Higham, "FORTRAN codes for estimating the one-norm of
130 *> a real or complex matrix, with applications to condition estimation",
131 *> ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.
133 * =====================================================================
134 SUBROUTINE CLACN2( N, V, X, EST, KASE, ISAVE )
136 * -- LAPACK auxiliary routine (version 3.4.2) --
137 * -- LAPACK is a software package provided by Univ. of Tennessee, --
138 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141 * .. Scalar Arguments ..
145 * .. Array Arguments ..
147 COMPLEX V( * ), X( * )
150 * =====================================================================
154 PARAMETER ( ITMAX = 5 )
156 PARAMETER ( ONE = 1.0E0, TWO = 2.0E0 )
158 PARAMETER ( CZERO = ( 0.0E0, 0.0E0 ),
159 $ CONE = ( 1.0E0, 0.0E0 ) )
161 * .. Local Scalars ..
163 REAL ABSXI, ALTSGN, ESTOLD, SAFMIN, TEMP
165 * .. External Functions ..
168 EXTERNAL ICMAX1, SCSUM1, SLAMCH
170 * .. External Subroutines ..
173 * .. Intrinsic Functions ..
174 INTRINSIC ABS, AIMAG, CMPLX, REAL
176 * .. Executable Statements ..
178 SAFMIN = SLAMCH( 'Safe minimum' )
181 X( I ) = CMPLX( ONE / REAL( N ) )
188 GO TO ( 20, 40, 70, 90, 120 )ISAVE( 1 )
190 * ................ ENTRY (ISAVE( 1 ) = 1)
191 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X.
200 EST = SCSUM1( N, X, 1 )
203 ABSXI = ABS( X( I ) )
204 IF( ABSXI.GT.SAFMIN ) THEN
205 X( I ) = CMPLX( REAL( X( I ) ) / ABSXI,
206 $ AIMAG( X( I ) ) / ABSXI )
215 * ................ ENTRY (ISAVE( 1 ) = 2)
216 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.
219 ISAVE( 2 ) = ICMAX1( N, X, 1 )
222 * MAIN LOOP - ITERATIONS 2,3,...,ITMAX.
228 X( ISAVE( 2 ) ) = CONE
233 * ................ ENTRY (ISAVE( 1 ) = 3)
234 * X HAS BEEN OVERWRITTEN BY A*X.
237 CALL CCOPY( N, X, 1, V, 1 )
239 EST = SCSUM1( N, V, 1 )
246 ABSXI = ABS( X( I ) )
247 IF( ABSXI.GT.SAFMIN ) THEN
248 X( I ) = CMPLX( REAL( X( I ) ) / ABSXI,
249 $ AIMAG( X( I ) ) / ABSXI )
258 * ................ ENTRY (ISAVE( 1 ) = 4)
259 * X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.
263 ISAVE( 2 ) = ICMAX1( N, X, 1 )
264 IF( ( ABS( X( JLAST ) ).NE.ABS( X( ISAVE( 2 ) ) ) ) .AND.
265 $ ( ISAVE( 3 ).LT.ITMAX ) ) THEN
266 ISAVE( 3 ) = ISAVE( 3 ) + 1
270 * ITERATION COMPLETE. FINAL STAGE.
275 X( I ) = CMPLX( ALTSGN*( ONE + REAL( I-1 ) / REAL( N-1 ) ) )
282 * ................ ENTRY (ISAVE( 1 ) = 5)
283 * X HAS BEEN OVERWRITTEN BY A*X.
286 TEMP = TWO*( SCSUM1( N, X, 1 ) / REAL( 3*N ) )
287 IF( TEMP.GT.EST ) THEN
288 CALL CCOPY( N, X, 1, V, 1 )