Statistiques
| Révision :

root / src / blas / snrm2.f @ 4

Historique | Voir | Annoter | Télécharger (1,5 ko)

1 1 pfleura2
      REAL FUNCTION SNRM2(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
      REAL X(*)
7 1 pfleura2
*     ..
8 1 pfleura2
*
9 1 pfleura2
*  Purpose
10 1 pfleura2
*  =======
11 1 pfleura2
*
12 1 pfleura2
*  SNRM2 returns the euclidean norm of a vector via the function
13 1 pfleura2
*  name, so that
14 1 pfleura2
*
15 1 pfleura2
*     SNRM2 := sqrt( x'*x ).
16 1 pfleura2
*
17 1 pfleura2
*  Further Details
18 1 pfleura2
*  ===============
19 1 pfleura2
*
20 1 pfleura2
*  -- This version written on 25-October-1982.
21 1 pfleura2
*     Modified on 14-October-1993 to inline the call to SLASSQ.
22 1 pfleura2
*     Sven Hammarling, Nag Ltd.
23 1 pfleura2
*
24 1 pfleura2
*
25 1 pfleura2
*     .. Parameters ..
26 1 pfleura2
      REAL ONE,ZERO
27 1 pfleura2
      PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
28 1 pfleura2
*     ..
29 1 pfleura2
*     .. Local Scalars ..
30 1 pfleura2
      REAL ABSXI,NORM,SCALE,SSQ
31 1 pfleura2
      INTEGER IX
32 1 pfleura2
*     ..
33 1 pfleura2
*     .. Intrinsic Functions ..
34 1 pfleura2
      INTRINSIC ABS,SQRT
35 1 pfleura2
*     ..
36 1 pfleura2
      IF (N.LT.1 .OR. INCX.LT.1) THEN
37 1 pfleura2
          NORM = ZERO
38 1 pfleura2
      ELSE IF (N.EQ.1) THEN
39 1 pfleura2
          NORM = ABS(X(1))
40 1 pfleura2
      ELSE
41 1 pfleura2
          SCALE = ZERO
42 1 pfleura2
          SSQ = ONE
43 1 pfleura2
*        The following loop is equivalent to this call to the LAPACK
44 1 pfleura2
*        auxiliary routine:
45 1 pfleura2
*        CALL SLASSQ( N, X, INCX, SCALE, SSQ )
46 1 pfleura2
*
47 1 pfleura2
          DO 10 IX = 1,1 + (N-1)*INCX,INCX
48 1 pfleura2
              IF (X(IX).NE.ZERO) THEN
49 1 pfleura2
                  ABSXI = ABS(X(IX))
50 1 pfleura2
                  IF (SCALE.LT.ABSXI) THEN
51 1 pfleura2
                      SSQ = ONE + SSQ* (SCALE/ABSXI)**2
52 1 pfleura2
                      SCALE = ABSXI
53 1 pfleura2
                  ELSE
54 1 pfleura2
                      SSQ = SSQ + (ABSXI/SCALE)**2
55 1 pfleura2
                  END IF
56 1 pfleura2
              END IF
57 1 pfleura2
   10     CONTINUE
58 1 pfleura2
          NORM = SCALE*SQRT(SSQ)
59 1 pfleura2
      END IF
60 1 pfleura2
*
61 1 pfleura2
      SNRM2 = NORM
62 1 pfleura2
      RETURN
63 1 pfleura2
*
64 1 pfleura2
*     End of SNRM2.
65 1 pfleura2
*
66 1 pfleura2
      END