dnrm2
C DNRM2 SOURCE CHAT 06/03/29 21:18:45 5360 IMPLICIT INTEGER(I-N) IMPLICIT REAL*8 (A-H,O-Z) -INC PPARAM -INC CCOPTIO * .. Scalar Result .. * .. Scalar Arguments .. INTEGER INCX, N * .. Array Arguments .. REAL*8 X( * ) * .. * * DNRM2 returns the euclidean norm of a vector via the function * name, so that * * DNRM2 := sqrt( x'*x ) * * * * -- This version written on 25-October-1982. * Modified on 14-October-1993 to inline the call to DLASSQ. * Sven Hammarling, Nag Ltd. * * Modified on 16/2/98 double precision -> real*8 * added error handling * commented INTRINSIC (not esope compatible) * real*8 function f -> function f ; real*8 f * .. Parameters .. * .. Local Scalars .. INTEGER IX REAL*8 ABSXI, NORM, SCALE, SSQ * .. Intrinsic Functions .. * INTRINSIC ABS, SQRT * .. * .. Executable Statements .. IF( N.LT.1 .OR. INCX.LT.1 )THEN NORM = ZERO GOTO 9999 ELSE IF( N.EQ.1 )THEN NORM = ABS( X( 1 ) ) ELSE SSQ = ONE * The following loop is equivalent to this call to the LAPACK * auxiliary routine: * CALL DLASSQ( N, X, INCX, SCALE, SSQ ) * DO 10, IX = 1, 1 + ( N - 1 )*INCX, INCX ABSXI = ABS( X( IX ) ) IF( SCALE.LT.ABSXI )THEN SSQ = ONE + SSQ*( SCALE/ABSXI )**2 SCALE = ABSXI ELSE SSQ = SSQ + ( ABSXI/SCALE )**2 END IF END IF 10 CONTINUE NORM = SCALE * SQRT( SSQ ) END IF * DNRM2 = NORM RETURN C Error handling 9999 CONTINUE WRITE(IOIMP,*) 'Dimension or increment lower than 1' WRITE(IOIMP,*) 'transmitted to function dnrm2' WRITE(IOIMP,*) 'nil value returned' DNRM2 = NORM RETURN * * End of DNRM2. * END
© Cast3M 2003 - Tous droits réservés.
Mentions légales