summaryrefslogtreecommitdiff
path: root/2.3-1/src/fortran/blas/dznrm2.f
diff options
context:
space:
mode:
Diffstat (limited to '2.3-1/src/fortran/blas/dznrm2.f')
-rw-r--r--2.3-1/src/fortran/blas/dznrm2.f67
1 files changed, 67 insertions, 0 deletions
diff --git a/2.3-1/src/fortran/blas/dznrm2.f b/2.3-1/src/fortran/blas/dznrm2.f
new file mode 100644
index 00000000..205ce393
--- /dev/null
+++ b/2.3-1/src/fortran/blas/dznrm2.f
@@ -0,0 +1,67 @@
+ DOUBLE PRECISION FUNCTION DZNRM2( N, X, INCX )
+* .. Scalar Arguments ..
+ INTEGER INCX, N
+* .. Array Arguments ..
+ COMPLEX*16 X( * )
+* ..
+*
+* DZNRM2 returns the euclidean norm of a vector via the function
+* name, so that
+*
+* DZNRM2 := sqrt( conjg( x' )*x )
+*
+*
+*
+* -- This version written on 25-October-1982.
+* Modified on 14-October-1993 to inline the call to ZLASSQ.
+* Sven Hammarling, Nag Ltd.
+*
+*
+* .. Parameters ..
+ DOUBLE PRECISION ONE , ZERO
+ PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
+* .. Local Scalars ..
+ INTEGER IX
+ DOUBLE PRECISION NORM, SCALE, SSQ, TEMP
+* .. Intrinsic Functions ..
+ INTRINSIC ABS, DIMAG, DBLE, SQRT
+* ..
+* .. Executable Statements ..
+ IF( N.LT.1 .OR. INCX.LT.1 )THEN
+ NORM = ZERO
+ ELSE
+ SCALE = ZERO
+ SSQ = ONE
+* The following loop is equivalent to this call to the LAPACK
+* auxiliary routine:
+* CALL ZLASSQ( N, X, INCX, SCALE, SSQ )
+*
+ DO 10, IX = 1, 1 + ( N - 1 )*INCX, INCX
+ IF( DBLE( X( IX ) ).NE.ZERO )THEN
+ TEMP = ABS( DBLE( X( IX ) ) )
+ IF( SCALE.LT.TEMP )THEN
+ SSQ = ONE + SSQ*( SCALE/TEMP )**2
+ SCALE = TEMP
+ ELSE
+ SSQ = SSQ + ( TEMP/SCALE )**2
+ END IF
+ END IF
+ IF( DIMAG( X( IX ) ).NE.ZERO )THEN
+ TEMP = ABS( DIMAG( X( IX ) ) )
+ IF( SCALE.LT.TEMP )THEN
+ SSQ = ONE + SSQ*( SCALE/TEMP )**2
+ SCALE = TEMP
+ ELSE
+ SSQ = SSQ + ( TEMP/SCALE )**2
+ END IF
+ END IF
+ 10 CONTINUE
+ NORM = SCALE * SQRT( SSQ )
+ END IF
+*
+ DZNRM2 = NORM
+ RETURN
+*
+* End of DZNRM2.
+*
+ END