Line | |
---|
1 | REAL FUNCTION SCNRM2(N,X,INCX) |
---|
2 | * .. Scalar Arguments .. |
---|
3 | INTEGER INCX,N |
---|
4 | * .. |
---|
5 | * .. Array Arguments .. |
---|
6 | COMPLEX X(*) |
---|
7 | * .. |
---|
8 | * |
---|
9 | * Purpose |
---|
10 | * ======= |
---|
11 | * |
---|
12 | * SCNRM2 returns the euclidean norm of a vector via the function |
---|
13 | * name, so that |
---|
14 | * |
---|
15 | * SCNRM2 := sqrt( conjg( x' )*x ) |
---|
16 | * |
---|
17 | * |
---|
18 | * |
---|
19 | * -- This version written on 25-October-1982. |
---|
20 | * Modified on 14-October-1993 to inline the call to CLASSQ. |
---|
21 | * Sven Hammarling, Nag Ltd. |
---|
22 | * |
---|
23 | * |
---|
24 | * .. Parameters .. |
---|
25 | REAL ONE,ZERO |
---|
26 | PARAMETER (ONE=1.0E+0,ZERO=0.0E+0) |
---|
27 | * .. |
---|
28 | * .. Local Scalars .. |
---|
29 | REAL NORM,SCALE,SSQ,TEMP |
---|
30 | INTEGER IX |
---|
31 | * .. |
---|
32 | * .. Intrinsic Functions .. |
---|
33 | INTRINSIC ABS,AIMAG,REAL,SQRT |
---|
34 | * .. |
---|
35 | IF (N.LT.1 .OR. INCX.LT.1) THEN |
---|
36 | NORM = ZERO |
---|
37 | ELSE |
---|
38 | SCALE = ZERO |
---|
39 | SSQ = ONE |
---|
40 | * The following loop is equivalent to this call to the LAPACK |
---|
41 | * auxiliary routine: |
---|
42 | * CALL CLASSQ( N, X, INCX, SCALE, SSQ ) |
---|
43 | * |
---|
44 | DO 10 IX = 1,1 + (N-1)*INCX,INCX |
---|
45 | IF (REAL(X(IX)).NE.ZERO) THEN |
---|
46 | TEMP = ABS(REAL(X(IX))) |
---|
47 | IF (SCALE.LT.TEMP) THEN |
---|
48 | SSQ = ONE + SSQ* (SCALE/TEMP)**2 |
---|
49 | SCALE = TEMP |
---|
50 | ELSE |
---|
51 | SSQ = SSQ + (TEMP/SCALE)**2 |
---|
52 | END IF |
---|
53 | END IF |
---|
54 | IF (AIMAG(X(IX)).NE.ZERO) THEN |
---|
55 | TEMP = ABS(AIMAG(X(IX))) |
---|
56 | IF (SCALE.LT.TEMP) THEN |
---|
57 | SSQ = ONE + SSQ* (SCALE/TEMP)**2 |
---|
58 | SCALE = TEMP |
---|
59 | ELSE |
---|
60 | SSQ = SSQ + (TEMP/SCALE)**2 |
---|
61 | END IF |
---|
62 | END IF |
---|
63 | 10 CONTINUE |
---|
64 | NORM = SCALE*SQRT(SSQ) |
---|
65 | END IF |
---|
66 | * |
---|
67 | SCNRM2 = NORM |
---|
68 | RETURN |
---|
69 | * |
---|
70 | * End of SCNRM2. |
---|
71 | * |
---|
72 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.