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