1
*> \brief \b SLACN2 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 SLACN2 + dependencies
10
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slacn2.f">
12
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slacn2.f">
14
*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slacn2.f">
21
* SUBROUTINE SLACN2( N, V, X, ISGN, EST, KASE, ISAVE )
23
* .. Scalar Arguments ..
27
* .. Array Arguments ..
28
* INTEGER ISGN( * ), ISAVE( 3 )
38
*> SLACN2 estimates the 1-norm of a square, real matrix A.
39
*> Reverse communication is used for evaluating matrix-vector products.
48
*> The order of the matrix. N >= 1.
53
*> V is REAL 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 REAL array, dimension (N)
61
*> On an intermediate return, X should be overwritten by
63
*> A**T * X, if KASE=2,
64
*> and SLACN2 must be re-called with all the other parameters
70
*> ISGN is INTEGER array, dimension (N)
76
*> On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be
77
*> unchanged from the previous call to SLACN2.
78
*> On exit, EST is an estimate (a lower bound) for norm(A).
81
*> \param[in,out] KASE
84
*> On the initial call to SLACN2, KASE should be 0.
85
*> On an intermediate return, KASE will be 1 or 2, indicating
86
*> whether X should be overwritten by A * X or A**T * X.
87
*> On the final return from SLACN2, KASE will again be 0.
90
*> \param[in,out] ISAVE
92
*> ISAVE is INTEGER array, dimension (3)
93
*> ISAVE is used to save variables between calls to SLACN2
99
*> \author Univ. of Tennessee
100
*> \author Univ. of California Berkeley
101
*> \author Univ. of Colorado Denver
104
*> \date September 2012
106
*> \ingroup realOTHERauxiliary
108
*> \par Further Details:
109
* =====================
113
*> Originally named SONEST, dated March 16, 1988.
115
*> This is a thread safe version of SLACON, which uses the array ISAVE
116
*> in place of a SAVE statement, as follows:
124
*> \par Contributors:
127
*> Nick Higham, University of Manchester
132
*> N.J. Higham, "FORTRAN codes for estimating the one-norm of
133
*> a real or complex matrix, with applications to condition estimation",
134
*> ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.
136
* =====================================================================
137
SUBROUTINE SLACN2( N, V, X, ISGN, EST, KASE, ISAVE )
139
* -- LAPACK auxiliary routine (version 3.4.2) --
140
* -- LAPACK is a software package provided by Univ. of Tennessee, --
141
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
144
* .. Scalar Arguments ..
148
* .. Array Arguments ..
149
INTEGER ISGN( * ), ISAVE( 3 )
153
* =====================================================================
157
PARAMETER ( ITMAX = 5 )
159
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0, TWO = 2.0E+0 )
161
* .. Local Scalars ..
163
REAL ALTSGN, ESTOLD, TEMP
165
* .. External Functions ..
168
EXTERNAL ISAMAX, SASUM
170
* .. External Subroutines ..
173
* .. Intrinsic Functions ..
174
INTRINSIC ABS, NINT, REAL, SIGN
176
* .. Executable Statements ..
180
X( I ) = ONE / REAL( N )
187
GO TO ( 20, 40, 70, 110, 140 )ISAVE( 1 )
189
* ................ ENTRY (ISAVE( 1 ) = 1)
190
* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X.
199
EST = SASUM( N, X, 1 )
202
X( I ) = SIGN( ONE, X( I ) )
203
ISGN( I ) = NINT( X( I ) )
209
* ................ ENTRY (ISAVE( 1 ) = 2)
210
* FIRST ITERATION. X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X.
213
ISAVE( 2 ) = ISAMAX( N, X, 1 )
216
* MAIN LOOP - ITERATIONS 2,3,...,ITMAX.
222
X( ISAVE( 2 ) ) = ONE
227
* ................ ENTRY (ISAVE( 1 ) = 3)
228
* X HAS BEEN OVERWRITTEN BY A*X.
231
CALL SCOPY( N, X, 1, V, 1 )
233
EST = SASUM( N, V, 1 )
235
IF( NINT( SIGN( ONE, X( I ) ) ).NE.ISGN( I ) )
238
* REPEATED SIGN VECTOR DETECTED, HENCE ALGORITHM HAS CONVERGED.
247
X( I ) = SIGN( ONE, X( I ) )
248
ISGN( I ) = NINT( X( I ) )
254
* ................ ENTRY (ISAVE( 1 ) = 4)
255
* X HAS BEEN OVERWRITTEN BY TRANSPOSE(A)*X.
259
ISAVE( 2 ) = ISAMAX( N, X, 1 )
260
IF( ( X( JLAST ).NE.ABS( X( ISAVE( 2 ) ) ) ) .AND.
261
$ ( ISAVE( 3 ).LT.ITMAX ) ) THEN
262
ISAVE( 3 ) = ISAVE( 3 ) + 1
266
* ITERATION COMPLETE. FINAL STAGE.
271
X( I ) = ALTSGN*( ONE+REAL( I-1 ) / REAL( N-1 ) )
278
* ................ ENTRY (ISAVE( 1 ) = 5)
279
* X HAS BEEN OVERWRITTEN BY A*X.
282
TEMP = TWO*( SASUM( N, X, 1 ) / REAL( 3*N ) )
283
IF( TEMP.GT.EST ) THEN
284
CALL SCOPY( N, X, 1, V, 1 )