<?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>E01SGF : 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/E01/e01sgf.pdf">E01SGF (PDF version)</a></div><div><a class="chap" href="e01conts.xml">E01 Chapter Contents</a></div><div><a class="chapint" href="e01intro.xml">E01 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/>E01SGF</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>Choice of Nw and Nq</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">E01SGF generates a two-dimensional interpolant to a set of scattered data points, using a modified Shepard method.</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;E01SGF&#160;(</td><td class="tdfspec2"><a class="arg" href="#M">M</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#Y">Y</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#NW">NW</a>, <a class="arg" href="#NQ">NQ</a>, <a class="arg" href="#IQ">IQ</a>, <a class="arg" href="#LIQ">LIQ</a>, <a class="arg" href="#RQ">RQ</a>, <a class="arg" href="#LRQ">LRQ</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">M, NW, NQ, IQ(LIQ), LIQ, LRQ, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(M), Y(M), F(M), RQ(LRQ)</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">E01SGF constructs a smooth function <m:math><m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;which interpolates a set of <m:math><m:mi>m</m:mi></m:math>&#160;scattered data points  <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>f</m:mi><m:mi>r</m:mi></m:msub></m:mfenced></m:math>, for  <m:math><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>m</m:mi></m:math>, using a modification of Shepard's method.  The surface is continuous and has continuous first partial derivatives.</div><div class="paramtext">The basic <a class="ref" href="#ref051">Shepard (1968)</a> method interpolates the input data with the weighted mean

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mfrac><m:mrow><m:munderover><m:mo>&#8721;</m:mo><m:mrow><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow><m:mi>m</m:mi></m:munderover><m:msub><m:mi>w</m:mi><m:mi>r</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:msub><m:mi>q</m:mi><m:mi>r</m:mi></m:msub></m:mrow>
  <m:mrow><m:munderover><m:mo>&#8721;</m:mo><m:mrow><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow><m:mi>m</m:mi></m:munderover><m:msub><m:mi>w</m:mi><m:mi>r</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:mrow>
 </m:mfrac><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math>
 <m:msub><m:mi>q</m:mi><m:mi>r</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:msub><m:mi>f</m:mi><m:mi>r</m:mi></m:msub>
</m:math>, <m:math>
 <m:msub><m:mi>w</m:mi><m:mi>r</m:mi></m:msub>
 <m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mfrac other="display">
  <m:mn>1</m:mn><m:msubsup><m:mi>d</m:mi><m:mi>r</m:mi><m:mn>2</m:mn></m:msubsup>
 </m:mfrac>
</m:math>&#160;and <m:math>
 <m:msubsup><m:mi>d</m:mi><m:mi>r</m:mi><m:mn>2</m:mn></m:msubsup>
 <m:mo>=</m:mo>
 <m:msup>
  <m:mfenced separators=""><m:mi>x</m:mi><m:mo>-</m:mo><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub></m:mfenced>
  <m:mn>2</m:mn>
 </m:msup>
 <m:mo>+</m:mo>
 <m:msup>
  <m:mfenced separators=""><m:mi>y</m:mi><m:mo>-</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub></m:mfenced>
  <m:mn>2</m:mn>
 </m:msup>
</m:math>.</div><div class="paramtext">The basic method is global in that the interpolated value at any point depends on all the data, but this routine uses a modification  (see <a class="ref" href="#ref050">Franke and Nielson (1980)</a> and <a class="ref" href="#ref609">Renka (1988a)</a>), whereby the method becomes local by adjusting each <m:math><m:msub><m:mi>w</m:mi><m:mi>r</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;to be zero outside a circle with centre <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub></m:mfenced></m:math>&#160;and some radius  <m:math><m:msub><m:mi>R</m:mi><m:mi>w</m:mi></m:msub></m:math>.  Also, to improve the performance of the basic method, each <m:math><m:msub><m:mi>q</m:mi><m:mi>r</m:mi></m:msub></m:math>&#160;above is replaced by a function  <m:math><m:msub><m:mi>q</m:mi><m:mi>r</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>, which is a quadratic fitted by weighted least-squares to data local to <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub></m:mfenced></m:math>&#160;and forced to interpolate <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>f</m:mi><m:mi>r</m:mi></m:msub></m:mfenced></m:math>.  In this context, a point <m:math><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;is defined to be local to another point if it lies within some distance <m:math><m:msub><m:mi>R</m:mi><m:mi>q</m:mi></m:msub></m:math>&#160;of it.  Computation of these quadratics constitutes the main work done by this routine.</div><div class="paramtext">The efficiency of the routine is further enhanced by using a cell method for nearest neighbour searching due to <a class="ref" href="#ref601">Bentley and Friedman (1979)</a>.</div><div class="paramtext">The radii <m:math><m:msub><m:mi>R</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>R</m:mi><m:mi>q</m:mi></m:msub></m:math>&#160;are chosen to be just large enough to include <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and  <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math>&#160;data points, respectively, for user-supplied constants <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math>.  Default values of these parameters are provided by the routine, and advice on alternatives is given in <a class="sec" href="#fcomments2">Section 8.2</a>.</div><div class="paramtext">This routine is derived from the routine QSHEP2 described by <a class="ref" href="#ref610">Renka (1988b)</a>.</div><div class="paramtext">Values of the interpolant <m:math><m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;generated by this  routine, and its first partial derivatives, can subsequently be evaluated for points in the domain of the data by a call to  <a class="rout" href="../E01/e01shf.xml">E01SHF</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref601" id="ref601"/>Bentley J L and Friedman J H (1979)  Data structures for range searching <i>ACM Comput. Surv.</i> <b>11</b> 397&#8211;409 </div>
<div class="paramtext"><a name="ref050" id="ref050"/>Franke R and Nielson G (1980)  Smooth interpolation of large sets of scattered data <i>Internat. J. Num. Methods Engrg.</i> <b>15</b> 1691&#8211;1704 </div>
<div class="paramtext"><a name="ref609" id="ref609"/>Renka R J (1988a)  Multivariate interpolation of large sets of scattered data <i>ACM Trans. Math. Software</i> <b>14</b> 139&#8211;148 </div>
<div class="paramtext"><a name="ref610" id="ref610"/>Renka R J (1988b)  Algorithm 660: QSHEP2D: Quadratic Shepard method for bivariate interpolation of scattered data <i>ACM Trans. Math. Software</i> <b>14</b> 149&#8211;150 </div>
<div class="paramtext"><a name="ref051" id="ref051"/>Shepard D (1968)  A two-dimensional interpolation function for irregularly spaced data <i>Proc. 23rd Nat. Conf. ACM</i> 517&#8211;523 Brandon/Systems Press Inc., Princeton </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 data points.</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:mn>6</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="X" id="X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="#M">M</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="Y" id="Y"/>3: &#160;&#160;&#8194; Y(<a class="arg" href="#M">M</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the Cartesian co-ordinates of the data points <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>r</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>r</m:mi></m:msub></m:mfenced></m:math>, for <m:math><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>m</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
   these co-ordinates must be distinct, and must not all be collinear.</div></dd><dt class="paramhead"><a name="F" id="F"/>4: &#160;&#160;&#8194; F(<a class="arg" href="#M">M</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F"><m:mi mathcolor="#EE0000" mathvariant="bold">F</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>r</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to the data value <m:math><m:msub><m:mi>f</m:mi><m:mi>r</m:mi></m:msub></m:math>, for <m:math><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>m</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="NW" id="NW"/>5: &#160;&#160;&#8194; NW &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;of data points that determines each radius of influence <m:math><m:msub><m:mi>R</m:mi><m:mi>w</m:mi></m:msub></m:math>, appearing in the definition of each of the weights <m:math><m:msub><m:mi>w</m:mi><m:mi>r</m:mi></m:msub></m:math>, for <m:math><m:mi>r</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>m</m:mi></m:math>&#160;(see <a class="sec" href="#description">Section 3</a>). Note that <m:math><m:msub><m:mi>R</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;is different for each weight. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0</m:mn></m:math>&#160;the default value <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>19</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>&#160;is used instead.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>40</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>.
</div></dd><dt class="paramhead"><a name="NQ" id="NQ"/>6: &#160;&#160;&#8194; NQ &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math>&#160;of data points to be used in the least-squares fit for coefficients defining the nodal functions <m:math><m:msub><m:mi>q</m:mi><m:mi>r</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;(see <a class="sec" href="#description">Section 3</a>). If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0</m:mn></m:math>&#160;the default value <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>13</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>&#160;is used instead.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0</m:mn></m:math>&#160;or <m:math><m:mn>5</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>40</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>.
</div></dd><dt class="paramhead"><a name="IQ" id="IQ"/>7: &#160;&#160;&#8194; IQ(<a class="arg" href="#LIQ">LIQ</a>) &#8211; INTEGER array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: integer data defining the interpolant <m:math><m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>.</div></dd><dt class="paramhead"><a name="LIQ" id="LIQ"/>8: &#160;&#160;&#8194; LIQ &#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="#IQ">IQ</a> as declared in the (sub)program from which E01SGF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LIQ"><m:mi mathcolor="#EE0000" mathvariant="bold">LIQ</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>2</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="RQ" id="RQ"/>9: &#160;&#160;&#8194; RQ(<a class="arg" href="#LRQ">LRQ</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: real data defining the interpolant <m:math><m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>.</div></dd><dt class="paramhead"><a name="LRQ" id="LRQ"/>10: &#8194; LRQ &#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="#RQ">RQ</a> as declared in the (sub)program from which E01SGF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LRQ"><m:mi mathcolor="#EE0000" mathvariant="bold">LRQ</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>6</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>+</m:mo><m:mn>5</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>11: &#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="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>6</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>5</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="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction>
  <m:mo>&gt;</m:mo>
  <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>40</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
 </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="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction>
  <m:mo>&gt;</m:mo>
  <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>40</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
 </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="#LIQ"><m:mi mathcolor="#EE0000" mathvariant="bold">LIQ</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>+</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="#LRQ"><m:mi mathcolor="#EE0000" mathvariant="bold">LRQ</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>6</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>+</m:mo><m:mn>5</m:mn></m:math>.</td></tr></table>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><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>2</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:mfenced separators=""><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:mfenced><m:mo>=</m:mo><m:mfenced separators=""><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>j</m:mi></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>j</m:mi></m:mfenced></m:mrow></m:mfenced></m:math>&#160;for some <m:math><m:mi>i</m:mi><m:mo>&#8800;</m:mo><m:mi>j</m:mi></m:math>.</td></tr></table>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><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>3</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90">all the data points are collinear. No unique solution exists.</td></tr></table>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">On successful exit, the function generated interpolates the input data exactly and has quadratic accuracy.</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 for a call to E01SGF will depend in general on the distribution of the data points.  If <a class="arg" href="#X">X</a> and <a class="arg" href="#Y">Y</a> are uniformly randomly distributed, then the time taken should be  O(<a class="arg" href="#M">M</a>).  At worst <m:math><m:mrow><m:mi mathvariant="italic">O</m:mi><m:mfenced separators=""><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mn>2</m:mn></m:msup></m:mfenced></m:mrow></m:math>&#160;time will be required.</div><h3 class="standard"><a class="sec" name="fcomments2" id="fcomments2"/>8.2&#160;&#160;Choice of <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math></h3>
<div class="paramtext">Default values of the parameters <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and  <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math>&#160;may be selected by calling  E01SGF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0</m:mn></m:math>&#160;and  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0</m:mn></m:math>.  These default values may well be satisfactory for many applications.</div><div class="paramtext">If nondefault values are required they must be supplied to  E01SGF through positive values of <a class="arg" href="#NW">NW</a> and <a class="arg" href="#NQ">NQ</a>.  Increasing these parameters makes the method less local.  This may increase the accuracy of the resulting interpolant at the expense of increased computational cost.  The default values  <m:math>
 <m:maction actiontype="link" dsi:type="simple" dsi:href="#NW"><m:mi mathcolor="#EE0000" mathvariant="bold">NW</m:mi></m:maction>
 <m:mo>=</m:mo>
 <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>19</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
</m:math>&#160;and  <m:math>
 <m:maction actiontype="link" dsi:type="simple" dsi:href="#NQ"><m:mi mathcolor="#EE0000" mathvariant="bold">NQ</m:mi></m:maction>
 <m:mo>=</m:mo>
 <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mn>13</m:mn><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
</m:math>&#160;have been chosen on the basis of experimental results reported in  <a class="ref" href="#ref609">Renka (1988a)</a>.  In these experiments the error norm was found to vary smoothly with <m:math><m:msub><m:mi>N</m:mi><m:mi>w</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>N</m:mi><m:mi>q</m:mi></m:msub></m:math>,  generally increasing monotonically and slowly with distance from the optimal pair.  The method is not therefore thought to be particularly sensitive to the parameter values.  For further advice on the choice of these parameters see <a class="ref" href="#ref609">Renka (1988a)</a>.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This program reads in a set of <m:math><m:mn>30</m:mn></m:math>&#160;data points and calls  E01SGF to construct an interpolating function  <m:math><m:mi>Q</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>.  It then calls <a class="rout" href="../E01/e01shf.xml">E01SHF</a> to evaluate the interpolant at a set of points.</div><div class="paramtext">Note that this example is not typical of a realistic problem: the number of data points would normally be larger.</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/e01sgfe.f">Program Text (e01sgfe.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/e01sgfe.d">Program&#160;Data (e01sgfe.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/e01sgfe.r">Program Results (e01sgfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/E01/e01sgf.pdf">E01SGF (PDF version)</a></div><div><a class="chap" href="e01conts.xml">E01 Chapter Contents</a></div><div><a class="chapint" href="e01intro.xml">E01 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>
