<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?>
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/><title>F02WDF : NAG Library, Mark 22</title><link rel="stylesheet" href="../styles/libdoc.css" type="text/css"/><script type="text/javascript">
   function showLevel(_levelId){
    var thisLevel = document.getElementById(_levelId);
    var thisplus = document.getElementById( _levelId.concat('plus'));
    var thisminus = document.getElementById( _levelId.concat('minus'));
    if(thisLevel.style.display != "block"){
     thisLevel.style.display = "block";
     thisplus.style.display = "none";
     thisminus.style.display = "inline";
     }
    else{
     thisLevel.style.display = "none";
     thisminus.style.display = "none";
     thisplus.style.display = "inline";
     }
    }
  </script></head><body><hr/><div><a class="rout" href="../../pdf/F02/f02wdf.pdf">F02WDF (PDF version)</a></div><div><a class="chap" href="f02conts.xml">F02 Chapter Contents</a></div><div><a class="chapint" href="f02intro.xml">F02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library Routine Document<br/><br/>F02WDF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocfcomments');"><span class="htmltocplus" id="tocfcommentsplus">+</span><span class="htmltocminus" id="tocfcommentsminus">&#8722;</span></span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
<div class="htmltocitem" id="tocfcomments">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments1">8.1&#160;&#160;<b>Timing</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments2">8.2&#160;&#160;<b>General Remarks</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments3">8.3&#160;&#160;<b>Determining the Rank of A</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments4">8.4&#160;&#160;<b>Storage Details of the QU Factorization</b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">F02WDF returns the Householder <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization of a real rectangular <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;<m:math><m:mfenced separators=""><m:mi>m</m:mi><m:mo>&#8805;</m:mo><m:mi>n</m:mi></m:mfenced></m:math>&#160;matrix <m:math><m:mi>A</m:mi></m:math>.  Further, on request or if <m:math><m:mi>A</m:mi></m:math>&#160;is not of full rank, part or all of the singular value decomposition of <m:math><m:mi>A</m:mi></m:math>&#160;is returned.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;F02WDF&#160;(</td><td class="tdfspec2"><a class="arg" href="#M">M</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#LDA">LDA</a>, <a class="arg" href="#WANTB">WANTB</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#SVD">SVD</a>, <a class="arg" href="#IRANK">IRANK</a>, <a class="arg" href="#Z">Z</a>, <a class="arg" href="#SV">SV</a>, <a class="arg" href="#WANTR">WANTR</a>, <a class="arg" href="#R">R</a>, <a class="arg" href="#LDR">LDR</a>, <a class="arg" href="#WANTPT">WANTPT</a>, <a class="arg" href="#PT">PT</a>, <a class="arg" href="#LDPT">LDPT</a>, <a class="arg" href="#WORK">WORK</a>, <a class="arg" href="#LWORK">LWORK</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">M, N, LDA, IRANK, LDR, LDPT, LWORK, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">A(LDA,N), B(M), TOL, Z(N), SV(N), R(LDR,N), PT(LDPT,N), WORK(LWORK)</td></tr><tr><td class="tdfspec1">LOGICAL</td><td class="tdfspec2">WANTB, SVD, WANTR, WANTPT</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">The real <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;<m:math><m:mfenced separators=""><m:mi>m</m:mi><m:mo>&#8805;</m:mo><m:mi>n</m:mi></m:mfenced></m:math>&#160;matrix <m:math><m:mi>A</m:mi></m:math>&#160;is first factorized as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>A</m:mi><m:mo>=</m:mo><m:mi>Q</m:mi>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>U</m:mi></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>Q</m:mi></m:math>&#160;is an <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>m</m:mi></m:math>&#160;orthogonal matrix and <m:math><m:mi>U</m:mi></m:math>&#160;is an <m:math><m:mi>n</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;upper triangular matrix.</div><div class="paramtext">If either <m:math><m:mi>U</m:mi></m:math>&#160;is singular or <a class="arg" href="#SVD">SVD</a> is supplied as .TRUE., then the singular value decomposition (SVD) of <m:math><m:mi>U</m:mi></m:math>&#160;is obtained so that  <m:math><m:mi>U</m:mi></m:math>&#160;is factorized as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>U</m:mi><m:mo>=</m:mo><m:mi>R</m:mi><m:mi>D</m:mi><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>R</m:mi></m:math>&#160;and <m:math><m:mi>P</m:mi></m:math>&#160;are <m:math><m:mi>n</m:mi></m:math>&#160;by  <m:math><m:mi>n</m:mi></m:math>&#160;orthogonal matrices and <m:math><m:mi>D</m:mi></m:math>&#160;is the <m:math><m:mi>n</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;diagonal matrix

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>D</m:mi><m:mo>=</m:mo><m:mrow><m:mi>diag</m:mi><m:mfenced separators=""><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mi>n</m:mi></m:msub></m:mfenced></m:mrow><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

with <m:math><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub><m:mo>&#8805;</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>2</m:mn></m:msub><m:mo>&#8805;</m:mo><m:mo>&#8943;</m:mo><m:mo>&#8805;</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mi>n</m:mi></m:msub><m:mo>&#8805;</m:mo><m:mn>0</m:mn><m:mtext>.</m:mtext></m:math></div><div class="paramtext">Note that the SVD of <m:math><m:mi>A</m:mi></m:math>&#160;is then given by

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>A</m:mi><m:mo>=</m:mo><m:msub><m:mi>Q</m:mi><m:mn>1</m:mn></m:msub>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>D</m:mi></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mtext>&#8195; where &#8195;</m:mtext><m:msub><m:mi>Q</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mi>Q</m:mi>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>R</m:mi></m:mtd>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
   <m:mtd><m:mi>I</m:mi></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

the diagonal elements of <m:math><m:mi>D</m:mi></m:math>&#160;being the singular values of  <m:math><m:mi>A</m:mi></m:math>.</div><div class="paramtext">The option to form a vector <m:math><m:msup><m:mi>Q</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mi>b</m:mi></m:math>, or if appropriate <m:math>
 <m:msubsup><m:mi>Q</m:mi><m:mn>1</m:mn><m:mi mathvariant="normal">T</m:mi></m:msubsup>
<m:mi>b</m:mi></m:math>, is also provided.</div><div class="paramtext">The rank of the matrix <m:math><m:mi>A</m:mi></m:math>, based upon a user-supplied parameter <a class="arg" href="#TOL">TOL</a>, is also returned.</div><div class="paramtext">The <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization of <m:math><m:mi>A</m:mi></m:math>&#160;is obtained by  Householder transformations.  To obtain the SVD of <m:math><m:mi>U</m:mi></m:math>&#160;the matrix is first reduced to bidiagonal form by means of plane rotations and then the <m:math><m:mi>Q</m:mi><m:mi>R</m:mi></m:math>&#160;algorithm is used to obtain the SVD of the bidiagonal form.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref115" id="ref115"/>Wilkinson J H (1978)  Singular Value Decomposition &#8211; Basic Aspects <i>Numerical Software &#8211; Needs and Availability</i> (ed D A H Jacobs) Academic Press </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="M" id="M"/>1: &#160;&#160;&#8194; M &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 

<m:math><m:mi>m</m:mi></m:math>, the number of rows of the matrix <m:math><m:mi>A</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="N" id="N"/>2: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 



<m:math><m:mi>n</m:mi></m:math>, the number of columns of the matrix <m:math><m:mi>A</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="A" id="A"/>3: &#160;&#160;&#8194; A(<a class="arg" href="#LDA">LDA</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: the leading <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;part of <a class="arg" href="#A">A</a> must contain the matrix to be factorized.</div>
<div class="paramtext"><i>On exit</i>: the leading <m:math><m:mi>m</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;part of <a class="arg" href="#A">A</a>, together with the <m:math><m:mi>n</m:mi></m:math>&#160;element vector <a class="arg" href="#Z">Z</a>, contains details of the Householder <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization.
<div class="paramtext">Details of the storage of the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization are given in <a class="sec" href="#fcomments4">Section 8.4</a>.</div>
</div></dd><dt class="paramhead"><a name="LDA" id="LDA"/>4: &#160;&#160;&#8194; LDA &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the first dimension of the array <a class="arg" href="#A">A</a> as declared in the (sub)program from which F02WDF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDA"><m:mi mathcolor="#EE0000" mathvariant="bold">LDA</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="WANTB" id="WANTB"/>5: &#160;&#160;&#8194; WANTB &#8211; LOGICAL<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must be .TRUE. if <m:math><m:msup><m:mi>Q</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mi>b</m:mi></m:math>&#160;or <m:math>
 <m:msubsup><m:mi>Q</m:mi><m:mn>1</m:mn><m:mi mathvariant="normal">T</m:mi></m:msubsup>
 <m:mi>b</m:mi>
</m:math>&#160;is required.
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTB"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTB</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>, <a class="arg" href="#B">B</a> is not referenced.</div>
</div></dd><dt class="paramhead"><a name="B" id="B"/>6: &#160;&#160;&#8194; B(<a class="arg" href="#M">M</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: if <a class="arg" href="#WANTB">WANTB</a> is supplied as .TRUE., <a class="arg" href="#B">B</a> must contain the <m:math><m:mi>m</m:mi></m:math>&#160;element vector <m:math><m:mi>b</m:mi></m:math>. Otherwise, <a class="arg" href="#B">B</a> is not referenced.</div>
<div class="paramtext"><i>On exit</i>: contains <m:math>
 <m:msubsup><m:mi>Q</m:mi><m:mn>1</m:mn><m:mi mathvariant="normal">T</m:mi></m:msubsup>
 <m:mi>b</m:mi>
</m:math>&#160;if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE. and <m:math><m:msup><m:mi>Q</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mi>b</m:mi></m:math>&#160;if <a class="arg" href="#SVD">SVD</a> is returned as .FALSE..</div></dd><dt class="paramhead"><a name="TOL" id="TOL"/>7: &#160;&#160;&#8194; TOL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must specify a relative tolerance to be used to determine the rank of <m:math><m:mi>A</m:mi></m:math>. <a class="arg" href="#TOL">TOL</a> should be chosen as approximately the largest relative error in the elements of <m:math><m:mi>A</m:mi></m:math>. For example, if the elements of <m:math><m:mi>A</m:mi></m:math>&#160;are correct to about <m:math><m:mn>4</m:mn></m:math>&#160;significant figures, <a class="arg" href="#TOL">TOL</a> should be set to about <m:math><m:mn>5</m:mn><m:mo>&#215;</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mn>4</m:mn></m:mrow></m:msup></m:math>. See <a class="sec" href="#fcomments3">Section 8.3</a> for a description of how <a class="arg" href="#TOL">TOL</a> is used to determine rank.
<div class="paramtext">If <a class="arg" href="#TOL">TOL</a> is outside the range <m:math><m:mfenced separators=""><m:mi>&#949;</m:mi><m:mo>,</m:mo><m:mn>1.0</m:mn></m:mfenced></m:math>, where <m:math><m:mi>&#949;</m:mi></m:math>&#160;is the <span class="bitalic">machine precision</span>, the value <m:math><m:mi>&#949;</m:mi></m:math>&#160;is used in place of <a class="arg" href="#TOL">TOL</a>. For most problems this is unreasonably small.</div>
</div></dd><dt class="paramhead"><a name="SVD" id="SVD"/>8: &#160;&#160;&#8194; SVD &#8211; LOGICAL<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: must be .TRUE. if the singular values are to be found even if <m:math><m:mi>A</m:mi></m:math>&#160;is of full rank.
<div class="paramtext">If before entry, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SVD"><m:mi mathcolor="#EE0000" mathvariant="bold">SVD</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>&#160;<b>and</b> <m:math><m:mi>A</m:mi></m:math>&#160;is determined to be of full rank, only the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization of <m:math><m:mi>A</m:mi></m:math>&#160;is computed.</div>
</div>
<div class="paramtext"><i>On exit</i>: is returned as .FALSE. if only the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization of <m:math><m:mi>A</m:mi></m:math>&#160;has been obtained and is returned as .TRUE. if the singular values of <m:math><m:mi>A</m:mi></m:math>&#160;have been obtained.</div></dd><dt class="paramhead"><a name="IRANK" id="IRANK"/>9: &#160;&#160;&#8194; IRANK &#8211; INTEGER<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: returns the rank of the matrix <m:math><m:mi>A</m:mi></m:math>. (It should be noted that it is possible for <a class="arg" href="#IRANK">IRANK</a> to be returned as <m:math><m:mi>n</m:mi></m:math>&#160;and <a class="arg" href="#SVD">SVD</a> to be returned as .TRUE., even if <a class="arg" href="#SVD">SVD</a> was supplied as .FALSE.. This means that the matrix <m:math><m:mi>U</m:mi></m:math>&#160;only just failed the test for nonsingularity.)</div></dd><dt class="paramhead"><a name="Z" id="Z"/>10: &#8194; Z(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the <m:math><m:mi>n</m:mi></m:math>&#160;element vector <a class="arg" href="#Z">Z</a> contains some details of the Householder transformations. See <a class="sec" href="#fcomments4">Section 8.4</a> for further information.</div></dd><dt class="paramhead"><a name="SV" id="SV"/>11: &#8194; SV(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE., <a class="arg" href="#SV">SV</a> contains the <m:math><m:mi>n</m:mi></m:math>&#160;singular values of <m:math><m:mi>A</m:mi></m:math>&#160;arranged in descending order.</div></dd><dt class="paramhead"><a name="WANTR" id="WANTR"/>12: &#8194; WANTR &#8211; LOGICAL<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must be .TRUE. if the orthogonal matrix <m:math><m:mi>R</m:mi></m:math>&#160;is required when the singular values are computed.
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTR</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>, <a class="arg" href="#R">R</a> is not referenced.</div>
</div></dd><dt class="paramhead"><a name="R" id="R"/>13: &#8194; R(<a class="arg" href="#LDR">LDR</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><b>Note:</b> the second dimension of the array <a class="arg" href="#R">R</a>
must be at least
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTR</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, and at least <m:math><m:mn>1</m:mn></m:math>&#160;otherwise.</div>
<div class="paramtext"><i>On exit</i>: if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE. and <a class="arg" href="#WANTR">WANTR</a> was supplied as .TRUE., the leading <m:math><m:mi>n</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;part of <a class="arg" href="#R">R</a> will contain the left-hand orthogonal matrix of the <a class="arg" href="#SVD">SVD</a> of <m:math><m:mi>U</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="LDR" id="LDR"/>14: &#8194; LDR &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the first dimension of the array <a class="arg" href="#R">R</a> as declared in the (sub)program from which F02WDF is called.</div><div class="paramtext"><i>Constraints</i>:
   <div class="paramtext"/><ul class="listcons">
<li class="listcons">if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTR</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDR"><m:mi mathcolor="#EE0000" mathvariant="bold">LDR</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>;</li>
<li class="listcons">otherwise <m:math><m:mn>1</m:mn></m:math>.</li>
</ul></div></dd><dt class="paramhead"><a name="WANTPT" id="WANTPT"/>15: &#8194; WANTPT &#8211; LOGICAL<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must be .TRUE. if the orthogonal matrix <m:math><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:math>&#160;is required when the singular values are computed.
<div class="paramtext">Note that if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE., <a class="arg" href="#PT">PT</a> is referenced even if <a class="arg" href="#WANTPT">WANTPT</a> is supplied as .FALSE., but see parameter <a class="arg" href="#PT">PT</a>.</div>
</div></dd><dt class="paramhead"><a name="PT" id="PT"/>16: &#8194; PT(<a class="arg" href="#LDPT">LDPT</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE. and <a class="arg" href="#WANTPT">WANTPT</a> was supplied as .TRUE., the leading <m:math><m:mi>n</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;part of <a class="arg" href="#PT">PT</a> contains the orthogonal matrix <m:math><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:math>. 
<div class="paramtext">If <a class="arg" href="#SVD">SVD</a> is returned as .TRUE., but  <a class="arg" href="#WANTPT">WANTPT</a> was supplied as .FALSE., the leading <m:math><m:mi>n</m:mi></m:math>&#160;by  <m:math><m:mi>n</m:mi></m:math>&#160;part of <a class="arg" href="#PT">PT</a> is used for internal workspace.</div>
</div></dd><dt class="paramhead"><a name="LDPT" id="LDPT"/>17: &#8194; LDPT &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the first dimension of the array <a class="arg" href="#PT">PT</a> as declared in the (sub)program from which F02WDF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDPT"><m:mi mathcolor="#EE0000" mathvariant="bold">LDPT</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="WORK" id="WORK"/>18: &#8194; WORK(<a class="arg" href="#LWORK">LWORK</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: if <a class="arg" href="#SVD">SVD</a> is returned as .FALSE., <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WORK"><m:mi mathcolor="#EE0000" mathvariant="bold">WORK</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;contains the condition number <m:math><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>U</m:mi></m:mfenced><m:mi>E</m:mi></m:msub><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:msup><m:mi>U</m:mi><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup></m:mfenced><m:mi>E</m:mi></m:msub></m:math>&#160;of the upper triangular matrix <m:math><m:mi>U</m:mi></m:math>.
<div class="paramtext">If <a class="arg" href="#SVD">SVD</a> is returned as .TRUE., <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WORK"><m:mi mathcolor="#EE0000" mathvariant="bold">WORK</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;will contain the total number of iterations taken by the <m:math><m:mi>Q</m:mi><m:mi>R</m:mi></m:math>&#160;algorithm.</div>
<div class="paramtext">The rest of the array is used as workspace and so contains no meaningful information.</div>
</div></dd><dt class="paramhead"><a name="LWORK" id="LWORK"/>19: &#8194; LWORK &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the dimension of the array <a class="arg" href="#WORK">WORK</a> as declared in the (sub)program from which F02WDF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LWORK"><m:mi mathcolor="#EE0000" mathvariant="bold">LWORK</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>3</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>20: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>). <div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, if you are not familiar with this parameter, the recommended value is <m:math><m:mn>0</m:mn></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn mathvariant="bold">1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div></div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDA"><m:mi mathcolor="#EE0000" mathvariant="bold">LDA</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDR"><m:mi mathcolor="#EE0000" mathvariant="bold">LDR</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTR</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDPT"><m:mi mathcolor="#EE0000" mathvariant="bold">LDPT</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LWORK"><m:mi mathcolor="#EE0000" mathvariant="bold">LWORK</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>3</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</td></tr></table>
<div class="paramtext">(The routine only checks <a class="arg" href="#LDR">LDR</a> if <a class="arg" href="#WANTR">WANTR</a> is supplied as .TRUE..)</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFgt1" id="IFgt1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<div class="paramtext">The <m:math><m:mi>Q</m:mi><m:mi>R</m:mi></m:math>&#160;algorithm has failed to converge to the singular values in <m:math><m:mn>50</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;iterations.  In this case  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>&#160;may not have been correctly found and the remaining singular values may not be the smallest singular values.  The matrix <m:math><m:mi>A</m:mi></m:math>&#160;has nevertheless been factorized as <m:math><m:mi>A</m:mi><m:mo>=</m:mo><m:msub><m:mi>Q</m:mi><m:mn>1</m:mn></m:msub><m:mi>C</m:mi><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:math>, where <m:math><m:mi>C</m:mi></m:math>&#160;is an upper bidiagonal matrix with  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#SV"><m:mi mathcolor="#EE0000" mathvariant="bold">SV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>n</m:mi></m:mfenced></m:mrow></m:math>&#160;as its diagonal elements and  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WORK"><m:mi mathcolor="#EE0000" mathvariant="bold">WORK</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WORK"><m:mi mathcolor="#EE0000" mathvariant="bold">WORK</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>3</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WORK"><m:mi mathcolor="#EE0000" mathvariant="bold">WORK</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>n</m:mi></m:mfenced></m:mrow></m:math>&#160;as its superdiagonal elements.</div>
<div class="paramtext">This failure cannot occur if <a class="arg" href="#SVD">SVD</a> is returned as .FALSE. and in any case is extremely rare.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The computed factors <m:math><m:mi>Q</m:mi></m:math>, <m:math><m:mi>U</m:mi></m:math>, <m:math><m:mi>R</m:mi></m:math>,  <m:math><m:mi>D</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:math>&#160;satisfy the relations

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>Q</m:mi>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>U</m:mi></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced><m:mo>=</m:mo><m:mi>A</m:mi><m:mo>+</m:mo><m:mi>E</m:mi><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div><div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>Q</m:mi>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>R</m:mi></m:mtd>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
   <m:mtd><m:mi>I</m:mi></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mi>D</m:mi></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mo>=</m:mo><m:mi>A</m:mi><m:mo>+</m:mo><m:mi>F</m:mi>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>E</m:mi></m:mfenced><m:mn>2</m:mn></m:msub><m:mo>&#8804;</m:mo><m:msub><m:mi>c</m:mi><m:mn>1</m:mn></m:msub><m:mi>&#949;</m:mi>  <m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>A</m:mi></m:mfenced><m:mn>2</m:mn></m:msub></m:math>, <m:math><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>F</m:mi></m:mfenced><m:mn>2</m:mn></m:msub><m:mo>&#8804;</m:mo><m:msub><m:mi>c</m:mi><m:mn>2</m:mn></m:msub><m:mi>&#949;</m:mi>  <m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>A</m:mi></m:mfenced><m:mn>2</m:mn></m:msub></m:math>,</div><div class="paramtext"><m:math><m:mi>&#949;</m:mi></m:math>&#160;being the <span class="bitalic">machine precision</span> and <m:math><m:msub><m:mi>c</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;and  <m:math><m:msub><m:mi>c</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;are modest functions of <m:math><m:mi>m</m:mi></m:math>&#160;and  <m:math><m:mi>n</m:mi></m:math>.  Note that <m:math><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>A</m:mi></m:mfenced><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2><h3 class="standard"><a class="sec" name="fcomments1" id="fcomments1"/>8.1&#160;&#160;Timing</h3>
<div class="paramtext">The time taken by F02WDF to obtain the Householder <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization is approximately proportional to <m:math><m:msup><m:mi>n</m:mi><m:mn>2</m:mn></m:msup><m:mfenced separators=""><m:mn>3</m:mn><m:mi>m</m:mi><m:mo>-</m:mo><m:mi>n</m:mi></m:mfenced></m:math>.</div><div class="paramtext">The <b>additional</b> time taken to obtain the singular value decomposition is approximately proportional to <m:math><m:msup><m:mi>n</m:mi><m:mn>3</m:mn></m:msup></m:math>,  where the constant of proportionality depends upon whether or not the orthogonal matrices <m:math><m:mi>R</m:mi></m:math>&#160;and <m:math><m:msup><m:mi>P</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:math>&#160;are required.</div><h3 class="standard"><a class="sec" name="fcomments2" id="fcomments2"/>8.2&#160;&#160;General Remarks</h3>
<div class="paramtext">Singular vectors associated with a zero or multiple singular value, are not uniquely determined, even in exact arithmetic, and very different results may be obtained if they are computed on different machines.</div><div class="paramtext">Unless otherwise stated in the <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a> for your implementation, the routine may be called with the same array for parameters <a class="arg" href="#Z">Z</a> and <a class="arg" href="#SV">SV</a>, in which case, if <a class="arg" href="#SVD">SVD</a> is returned as .TRUE., the singular values will overwrite the original contents of <a class="arg" href="#Z">Z</a>;  also, if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#WANTPT"><m:mi mathcolor="#EE0000" mathvariant="bold">WANTPT</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>, it may be called with the same array for parameters <a class="arg" href="#R">R</a> and <a class="arg" href="#PT">PT</a>.  However this is not standard Fortran 77,  and may not work on all systems.</div><div class="paramtext">This routine is called by the least-squares routine <a class="rout" href="../F04/f04jgf.xml">F04JGF</a>.</div><h3 class="standard"><a class="sec" name="fcomments3" id="fcomments3"/>8.3&#160;&#160;Determining the Rank of <m:math><m:mi>A</m:mi></m:math></h3>
<div class="paramtext">Following the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization of <m:math><m:mi>A</m:mi></m:math>, if <a class="arg" href="#SVD">SVD</a>  is supplied as
.FALSE., then the condition number of <m:math><m:mi>U</m:mi></m:math>&#160;given by

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>C</m:mi><m:mfenced separators=""><m:mi>U</m:mi></m:mfenced><m:mo>=</m:mo><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>U</m:mi></m:mfenced><m:mi>F</m:mi></m:msub>  <m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:msup><m:mi>U</m:mi><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup></m:mfenced><m:mi>F</m:mi></m:msub>
</m:math></td><td class="formula2"/></tr></table></div>

is found, where <m:math><m:msub><m:mfenced open="&#8214;" close="&#8214;" separators=""><m:mi>.</m:mi></m:mfenced><m:mi>F</m:mi></m:msub></m:math>&#160;denotes the Frobenius norm, and if <m:math><m:mi>C</m:mi><m:mfenced separators=""><m:mi>U</m:mi></m:mfenced></m:math>&#160;is such that

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>C</m:mi><m:mfenced separators=""><m:mi>U</m:mi></m:mfenced><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>1.0</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>

then <m:math><m:mi>U</m:mi></m:math>&#160;is regarded as singular and the singular values of  <m:math><m:mi>A</m:mi></m:math>&#160;are computed.  If this test is not satisfied, then the rank of <m:math><m:mi>A</m:mi></m:math>&#160;is set to <m:math><m:mi>n</m:mi></m:math>.  Note that if <a class="arg" href="#SVD">SVD</a> is supplied as .TRUE. then this test is omitted.</div><div class="paramtext">When the singular values are computed, then the rank of <m:math><m:mi>A</m:mi></m:math>,  <m:math><m:mi>r</m:mi></m:math>, is returned as the largest integer such that

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mi>r</m:mi></m:msub><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&#215;</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

unless <m:math><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;in which case <m:math><m:mi>r</m:mi></m:math>&#160;is returned as zero.  That is, singular values which satisfy  <m:math><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mi>i</m:mi></m:msub><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&#215;</m:mo><m:mi>s</m:mi><m:msub><m:mi>v</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;are regarded as negligible because relative perturbations of order <a class="arg" href="#TOL">TOL</a> can make such singular values zero.</div><h3 class="standard"><a class="sec" name="fcomments4" id="fcomments4"/>8.4&#160;&#160;Storage Details of the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;Factorization</h3>
<div class="paramtext">The <m:math><m:mi>k</m:mi></m:math>th Householder transformation matrix, <m:math><m:msub><m:mi>T</m:mi><m:mi>k</m:mi></m:msub></m:math>,  used in the <m:math><m:mi>Q</m:mi><m:mi>U</m:mi></m:math>&#160;factorization is chosen to introduce the zeros into the <m:math><m:mi>k</m:mi></m:math>th column and has the form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msub><m:mi>T</m:mi><m:mi>k</m:mi></m:msub><m:mo>=</m:mo><m:mi>I</m:mi><m:mo>-</m:mo><m:mn>2</m:mn>
<m:mfenced><m:mtable>
  <m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mi>u</m:mi></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mfenced><m:mtable>
  <m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
   <m:mtd><m:msup><m:mi>u</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mtext>, &#8195;</m:mtext><m:msup><m:mi>u</m:mi><m:mi mathvariant="normal">T</m:mi></m:msup><m:mi>u</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>u</m:mi></m:math>&#160;is an <m:math><m:mfenced separators=""><m:mi>m</m:mi><m:mo>-</m:mo><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced></m:math>&#160;element vector.</div><div class="paramtext">In place of <m:math><m:mi>u</m:mi></m:math>&#160;the routine actually computes the vector  <m:math><m:mi>z</m:mi></m:math>&#160;given by

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>z</m:mi><m:mo>=</m:mo><m:mn>2</m:mn><m:msub><m:mi>u</m:mi><m:mn>1</m:mn></m:msub><m:mi>u</m:mi><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

The first element of <m:math><m:mi>z</m:mi></m:math>&#160;is stored in <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>k</m:mi></m:mfenced></m:mrow></m:math>&#160;and the remaining elements of <m:math><m:mi>z</m:mi></m:math>&#160;are overwritten on the subdiagonal elements of the <m:math><m:mi>k</m:mi></m:math>th column of <a class="arg" href="#A">A</a>.  The upper triangular matrix <m:math><m:mi>U</m:mi></m:math>&#160;is overwritten on the <m:math><m:mi>n</m:mi></m:math>&#160;by <m:math><m:mi>n</m:mi></m:math>&#160;upper triangular part of <a class="arg" href="#A">A</a>.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example obtains the rank and the singular value decomposition of the <m:math><m:mn>6</m:mn></m:math>&#160;by <m:math><m:mn>4</m:mn></m:math>&#160;matrix <m:math><m:mi>A</m:mi></m:math>&#160;given by

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>A</m:mi><m:mo>=</m:mo><m:mfenced><m:mtable columnalign="right">
  <m:mtr>
   <m:mtd><m:mn>22.25</m:mn></m:mtd>
   <m:mtd><m:mn>31.75</m:mn></m:mtd>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>38.25</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mn>65.50</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>20.00</m:mn></m:mtd>
   <m:mtd><m:mn>26.75</m:mn></m:mtd>
   <m:mtd><m:mn>28.50</m:mn></m:mtd>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>26.50</m:mn></m:mrow></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>15.25</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mn>24.25</m:mn></m:mtd>
   <m:mtd><m:mn>27.75</m:mn></m:mtd>
   <m:mtd><m:mn>18.50</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>27.25</m:mn></m:mtd>
   <m:mtd><m:mn>10.00</m:mn></m:mtd>
   <m:mtd><m:mn>3.00</m:mn></m:mtd>
   <m:mtd><m:mn>2.00</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>17.25</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>30.75</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mn>11.25</m:mn></m:mtd>
   <m:mtd><m:mn>7.50</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>17.25</m:mn></m:mtd>
   <m:mtd><m:mn>30.75</m:mn></m:mtd>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>11.25</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>7.50</m:mn></m:mrow></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

the value <a class="arg" href="#TOL">TOL</a> to be taken as <m:math><m:mn>5</m:mn><m:mo>&#215;</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mn>4</m:mn></m:mrow></m:msup></m:math>.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/f02wdfe.f">Program Text (f02wdfe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<p><a class="verbatimref" href="../../examples/data/f02wdfe.d">Program&#160;Data (f02wdfe.d)</a></p><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/f02wdfe.r">Program Results (f02wdfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/F02/f02wdf.pdf">F02WDF (PDF version)</a></div><div><a class="chap" href="f02conts.xml">F02 Chapter Contents</a></div><div><a class="chapint" href="f02intro.xml">F02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div>
<div><hr/><a class="genint" href="../FRONTMATTER/copyright.xml">&#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2009</a></div></body></html>
