LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ clacn2()

subroutine clacn2 ( integer  N,
complex, dimension( * )  V,
complex, dimension( * )  X,
real  EST,
integer  KASE,
integer, dimension( 3 )  ISAVE 
)

CLACN2 estimates the 1-norm of a square matrix, using reverse communication for evaluating matrix-vector products.

Download CLACN2 + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 CLACN2 estimates the 1-norm of a square, complex matrix A.
 Reverse communication is used for evaluating matrix-vector products.
Parameters
[in]N
          N is INTEGER
         The order of the matrix.  N >= 1.
[out]V
          V is COMPLEX array, dimension (N)
         On the final return, V = A*W,  where  EST = norm(V)/norm(W)
         (W is not returned).
[in,out]X
          X is COMPLEX array, dimension (N)
         On an intermediate return, X should be overwritten by
               A * X,   if KASE=1,
               A**H * X,  if KASE=2,
         where A**H is the conjugate transpose of A, and CLACN2 must be
         re-called with all the other parameters unchanged.
[in,out]EST
          EST is REAL
         On entry with KASE = 1 or 2 and ISAVE(1) = 3, EST should be
         unchanged from the previous call to CLACN2.
         On exit, EST is an estimate (a lower bound) for norm(A).
[in,out]KASE
          KASE is INTEGER
         On the initial call to CLACN2, KASE should be 0.
         On an intermediate return, KASE will be 1 or 2, indicating
         whether X should be overwritten by A * X  or A**H * X.
         On the final return from CLACN2, KASE will again be 0.
[in,out]ISAVE
          ISAVE is INTEGER array, dimension (3)
         ISAVE is used to save variables between calls to SLACN2
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Further Details:
  Originally named CONEST, dated March 16, 1988.

  Last modified:  April, 1999

  This is a thread safe version of CLACON, which uses the array ISAVE
  in place of a SAVE statement, as follows:

     CLACON     CLACN2
      JUMP     ISAVE(1)
      J        ISAVE(2)
      ITER     ISAVE(3)
Contributors:
Nick Higham, University of Manchester
References:
N.J. Higham, "FORTRAN codes for estimating the one-norm of a real or complex matrix, with applications to condition estimation", ACM Trans. Math. Soft., vol. 14, no. 4, pp. 381-396, December 1988.

Definition at line 132 of file clacn2.f.

133 *
134 * -- LAPACK auxiliary routine --
135 * -- LAPACK is a software package provided by Univ. of Tennessee, --
136 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
137 *
138 * .. Scalar Arguments ..
139  INTEGER KASE, N
140  REAL EST
141 * ..
142 * .. Array Arguments ..
143  INTEGER ISAVE( 3 )
144  COMPLEX V( * ), X( * )
145 * ..
146 *
147 * =====================================================================
148 *
149 * .. Parameters ..
150  INTEGER ITMAX
151  parameter( itmax = 5 )
152  REAL ONE, TWO
153  parameter( one = 1.0e0, two = 2.0e0 )
154  COMPLEX CZERO, CONE
155  parameter( czero = ( 0.0e0, 0.0e0 ),
156  $ cone = ( 1.0e0, 0.0e0 ) )
157 * ..
158 * .. Local Scalars ..
159  INTEGER I, JLAST
160  REAL ABSXI, ALTSGN, ESTOLD, SAFMIN, TEMP
161 * ..
162 * .. External Functions ..
163  INTEGER ICMAX1
164  REAL SCSUM1, SLAMCH
165  EXTERNAL icmax1, scsum1, slamch
166 * ..
167 * .. External Subroutines ..
168  EXTERNAL ccopy
169 * ..
170 * .. Intrinsic Functions ..
171  INTRINSIC abs, aimag, cmplx, real
172 * ..
173 * .. Executable Statements ..
174 *
175  safmin = slamch( 'Safe minimum' )
176  IF( kase.EQ.0 ) THEN
177  DO 10 i = 1, n
178  x( i ) = cmplx( one / real( n ) )
179  10 CONTINUE
180  kase = 1
181  isave( 1 ) = 1
182  RETURN
183  END IF
184 *
185  GO TO ( 20, 40, 70, 90, 120 )isave( 1 )
186 *
187 * ................ ENTRY (ISAVE( 1 ) = 1)
188 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY A*X.
189 *
190  20 CONTINUE
191  IF( n.EQ.1 ) THEN
192  v( 1 ) = x( 1 )
193  est = abs( v( 1 ) )
194 * ... QUIT
195  GO TO 130
196  END IF
197  est = scsum1( n, x, 1 )
198 *
199  DO 30 i = 1, n
200  absxi = abs( x( i ) )
201  IF( absxi.GT.safmin ) THEN
202  x( i ) = cmplx( real( x( i ) ) / absxi,
203  $ aimag( x( i ) ) / absxi )
204  ELSE
205  x( i ) = cone
206  END IF
207  30 CONTINUE
208  kase = 2
209  isave( 1 ) = 2
210  RETURN
211 *
212 * ................ ENTRY (ISAVE( 1 ) = 2)
213 * FIRST ITERATION. X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.
214 *
215  40 CONTINUE
216  isave( 2 ) = icmax1( n, x, 1 )
217  isave( 3 ) = 2
218 *
219 * MAIN LOOP - ITERATIONS 2,3,...,ITMAX.
220 *
221  50 CONTINUE
222  DO 60 i = 1, n
223  x( i ) = czero
224  60 CONTINUE
225  x( isave( 2 ) ) = cone
226  kase = 1
227  isave( 1 ) = 3
228  RETURN
229 *
230 * ................ ENTRY (ISAVE( 1 ) = 3)
231 * X HAS BEEN OVERWRITTEN BY A*X.
232 *
233  70 CONTINUE
234  CALL ccopy( n, x, 1, v, 1 )
235  estold = est
236  est = scsum1( n, v, 1 )
237 *
238 * TEST FOR CYCLING.
239  IF( est.LE.estold )
240  $ GO TO 100
241 *
242  DO 80 i = 1, n
243  absxi = abs( x( i ) )
244  IF( absxi.GT.safmin ) THEN
245  x( i ) = cmplx( real( x( i ) ) / absxi,
246  $ aimag( x( i ) ) / absxi )
247  ELSE
248  x( i ) = cone
249  END IF
250  80 CONTINUE
251  kase = 2
252  isave( 1 ) = 4
253  RETURN
254 *
255 * ................ ENTRY (ISAVE( 1 ) = 4)
256 * X HAS BEEN OVERWRITTEN BY CTRANS(A)*X.
257 *
258  90 CONTINUE
259  jlast = isave( 2 )
260  isave( 2 ) = icmax1( n, x, 1 )
261  IF( ( abs( x( jlast ) ).NE.abs( x( isave( 2 ) ) ) ) .AND.
262  $ ( isave( 3 ).LT.itmax ) ) THEN
263  isave( 3 ) = isave( 3 ) + 1
264  GO TO 50
265  END IF
266 *
267 * ITERATION COMPLETE. FINAL STAGE.
268 *
269  100 CONTINUE
270  altsgn = one
271  DO 110 i = 1, n
272  x( i ) = cmplx( altsgn*( one + real( i-1 ) / real( n-1 ) ) )
273  altsgn = -altsgn
274  110 CONTINUE
275  kase = 1
276  isave( 1 ) = 5
277  RETURN
278 *
279 * ................ ENTRY (ISAVE( 1 ) = 5)
280 * X HAS BEEN OVERWRITTEN BY A*X.
281 *
282  120 CONTINUE
283  temp = two*( scsum1( n, x, 1 ) / real( 3*n ) )
284  IF( temp.GT.est ) THEN
285  CALL ccopy( n, x, 1, v, 1 )
286  est = temp
287  END IF
288 *
289  130 CONTINUE
290  kase = 0
291  RETURN
292 *
293 * End of CLACN2
294 *
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
Definition: ccopy.f:81
integer function icmax1(N, CX, INCX)
ICMAX1 finds the index of the first vector element of maximum absolute value.
Definition: icmax1.f:81
real function scsum1(N, CX, INCX)
SCSUM1 forms the 1-norm of the complex vector using the true absolute value.
Definition: scsum1.f:81
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: