scnrm2.f.html
来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 95 行
HTML
95 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>scnrm2.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>
REAL FUNCTION <a name="SCNRM2.1"></a><a href="scnrm2.f.html#SCNRM2.1">SCNRM2</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> 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="SCNRM2.12"></a><a href="scnrm2.f.html#SCNRM2.1">SCNRM2</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="SCNRM2.15"></a><a href="scnrm2.f.html#SCNRM2.1">SCNRM2</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">
</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="CLASSQ.20"></a><a href="classq.f.html#CLASSQ.1">CLASSQ</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> REAL ONE,ZERO
PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
<span class="comment">*</span><span class="comment"> ..
</span><span class="comment">*</span><span class="comment"> .. Local Scalars ..
</span> REAL 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,AIMAG,REAL,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="CLASSQ.42"></a><a href="classq.f.html#CLASSQ.1">CLASSQ</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 (REAL(X(IX)).NE.ZERO) THEN
TEMP = ABS(REAL(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 (AIMAG(X(IX)).NE.ZERO) THEN
TEMP = ABS(AIMAG(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="SCNRM2.67"></a><a href="scnrm2.f.html#SCNRM2.1">SCNRM2</a> = NORM
RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment"> End of <a name="SCNRM2.70"></a><a href="scnrm2.f.html#SCNRM2.1">SCNRM2</a>.
</span><span class="comment">*</span><span class="comment">
</span> END
</pre>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?