dnrm2.f.html

来自「famous linear algebra library (LAPACK) p」· HTML 代码 · 共 87 行

HTML
87
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>dnrm2.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="DNRM2.1"></a><a href="dnrm2.f.html#DNRM2.1">DNRM2</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 PRECISION 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="DNRM2.12"></a><a href="dnrm2.f.html#DNRM2.1">DNRM2</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="DNRM2.15"></a><a href="dnrm2.f.html#DNRM2.1">DNRM2</a> := sqrt( 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="DLASSQ.19"></a><a href="dlassq.f.html#DLASSQ.1">DLASSQ</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 ABSXI,NORM,SCALE,SSQ
      INTEGER IX
<span class="comment">*</span><span class="comment">     ..
</span><span class="comment">*</span><span class="comment">     .. Intrinsic Functions ..
</span>      INTRINSIC ABS,SQRT
<span class="comment">*</span><span class="comment">     ..
</span>      IF (N.LT.1 .OR. INCX.LT.1) THEN
          NORM = ZERO
      ELSE IF (N.EQ.1) THEN
          NORM = ABS(X(1))
      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="DLASSQ.43"></a><a href="dlassq.f.html#DLASSQ.1">DLASSQ</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 (X(IX).NE.ZERO) THEN
                  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
<span class="comment">*</span><span class="comment">
</span>      <a name="DNRM2.59"></a><a href="dnrm2.f.html#DNRM2.1">DNRM2</a> = NORM
      RETURN
<span class="comment">*</span><span class="comment">
</span><span class="comment">*</span><span class="comment">     End of <a name="DNRM2.62"></a><a href="dnrm2.f.html#DNRM2.1">DNRM2</a>.
</span><span class="comment">*</span><span class="comment">
</span>      END

</pre>

 </body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?