dznrm2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 94 行
HTML
94 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>dznrm2.f</title>
<meta name="generator" content="emacs 21.3.1; htmlfontify 0.20">
<style type="text/css"><!--
body { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.default a { background: rgb(255, 255, 255); color: rgb(0, 0, 0); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
span.comment { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: none; }
span.comment a { color: rgb(178, 34, 34); background: rgb(255, 255, 255); font-style: normal; font-weight: 500; font-stretch: normal; font-family: adobe-courier; font-size: 11pt; text-decoration: underline; }
--></style>
</head>
<body>
<pre>
DOUBLE PRECISION FUNCTION <a name="DZNRM2.1"></a><a href="dznrm2.f.html#DZNRM2.1">DZNRM2</a>(N,X,INCX)
<span class="comment">*</span><span class="comment"> .. Scalar Arguments ..
</span> INTEGER INCX,N
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Array Arguments ..
</span> DOUBLE COMPLEX X(*)
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> Purpose
</span><span class="comment">*</span><span class="comment"> =======
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> <a name="DZNRM2.12"></a><a href="dznrm2.f.html#DZNRM2.1">DZNRM2</a> returns the euclidean norm of a vector via the function
</span><span class="comment">*</span><span class="comment"> name, so that
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> <a name="DZNRM2.15"></a><a href="dznrm2.f.html#DZNRM2.1">DZNRM2</a> := sqrt( conjg( x' )*x )
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> -- This version written on 25-October-1982.
</span><span class="comment">*</span><span class="comment"> Modified on 14-October-1993 to inline the call to <a name="ZLASSQ.19"></a><a href="zlassq.f.html#ZLASSQ.1">ZLASSQ</a>.
</span><span class="comment">*</span><span class="comment"> Sven Hammarling, Nag Ltd.
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> .. Parameters ..
</span> DOUBLE PRECISION ONE,ZERO
PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> DOUBLE PRECISION NORM,SCALE,SSQ,TEMP
INTEGER IX
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Intrinsic Functions ..
</span> INTRINSIC ABS,DBLE,DIMAG,SQRT
<span class="comment">*</span><span class="comment"> ..
</span> IF (N.LT.1 .OR. INCX.LT.1) THEN
NORM = ZERO
ELSE
SCALE = ZERO
SSQ = ONE
<span class="comment">*</span><span class="comment"> The following loop is equivalent to this call to the LAPACK
</span><span class="comment">*</span><span class="comment"> auxiliary routine:
</span><span class="comment">*</span><span class="comment"> CALL <a name="ZLASSQ.41"></a><a href="zlassq.f.html#ZLASSQ.1">ZLASSQ</a>( N, X, INCX, SCALE, SSQ )
</span><span class="comment">*</span><span class="comment">
</span> 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
<span class="comment">*</span><span class="comment">
</span> <a name="DZNRM2.66"></a><a href="dznrm2.f.html#DZNRM2.1">DZNRM2</a> = NORM
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="DZNRM2.69"></a><a href="dznrm2.f.html#DZNRM2.1">DZNRM2</a>.
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?