<?xml version="1.0" encoding="UTF-8"?>
<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
          xmlns:scilab="http://www.scilab.org" xml:id="eval_cshep2d" xml:lang="en">
    <refnamediv>
        <refname>eval_cshep2d</refname>
        <refpurpose>bidimensional cubic shepard interpolation
            evaluation
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>
        zp                                            = eval_cshep2d(xp, yp, tl_coef)
        [zp, dzpdx, dzpdy]                            = eval_cshep2d(xp, yp, tl_coef)
        [zp, dzpdx, dzpdy, d2zpdxx, d2zpdyy, d2zpdxy] = eval_cshep2d(xp, yp, tl_coef)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>xp, yp</term>
                <listitem>
                    <para>two real vectors (or matrices) of the same size</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>tl_coef</term>
                <listitem>
                    <para>a tlist scilab structure (of type cshep2d) defining a cubic
                        Shepard interpolation function (named <literal>S</literal> in the
                        following)
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>zp</term>
                <listitem>
                    <para>
                        vector (or matrix) of the same size than <literal>xp</literal>
                        and <literal>yp</literal>, evaluation of the interpolant
                        <literal>S</literal> at these points
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>dzpdx,dzpdy</term>
                <listitem>
                    <para>vectors (or matrices) of the same size than
                        <literal>xp</literal> and <literal>yp</literal>, evaluation of the
                        first derivatives of <literal>S</literal> at these points
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>d2zpdxx,d2zpdxy,d2zpdyy</term>
                <listitem>
                    <para>vectors (or matrices) of the same size than
                        <literal>xp</literal> and <literal>yp</literal>, evaluation of the
                        second derivatives of <literal>S</literal> at these points
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>This is the evaluation routine for cubic Shepard interpolation
            function computed with <link linkend="cshep2d">cshep2d</link>, that is
            :
        </para>
        <informalequation>
            <mediaobject>
                <imageobject>
                    <imagedata align="center" fileref="../mml/eval_cshep2d_equation1.mml"/>
                </imageobject>
            </mediaobject>
        </informalequation>
    </refsection>
    <refsection>
        <title>Remark</title>
        <para>
            The interpolant <emphasis>S</emphasis> is C2 (twice continuously
            differentiable) but is also extended by zero for
            <emphasis>(x,y)</emphasis> far enough the interpolation points. This leads
            to a discontinuity in a region far outside the interpolation points, and
            so, is not cumbersome in practice (in a general manner, evaluation outside
            interpolation points (i.e. extrapolation) leads to very inaccurate
            results).
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
// see example section of cshep2d

// this example shows the behavior far from the interpolation points ...
deff("z=f(x,y)","z = 1+ 50*(x.*(1-x).*y.*(1-y)).^2")
x = linspace(0,1,10);
[X,Y] = ndgrid(x,x);
X = X(:); Y = Y(:); Z = f(X,Y);
S = cshep2d([X Y Z]);
// evaluation inside and outside the square [0,1]x[0,1]
m = 40;
xx = linspace(-1.5,0.5,m);
[xp,yp] = ndgrid(xx,xx);
zp = eval_cshep2d(xp,yp,S);
// compute facet (to draw one color for extrapolation region
// and another one for the interpolation region)
[xf,yf,zf] = genfac3d(xx,xx,zp);
colors = 2*ones(1,size(zf,2));
// indices corresponding to facet in the interpolation region
ind=find( mean(xf,"r")>0 & mean(xf,"r")<1 & mean(yf,"r")>0 & mean(yf,"r")<1 );
colors(ind)=3;
clf();
plot3d(xf,yf,list(zf,colors), flag=[2 6 4])
legends(["extrapolation region","interpolation region"],[2 3],1)
show_window()
 ]]></programlisting>
        <scilab:image><![CDATA[
deff("z=f(x,y)","z = 1+ 50*(x.*(1-x).*y.*(1-y)).^2")
x = linspace(0,1,10);
[X,Y] = ndgrid(x,x);
X = X(:); Y = Y(:); Z = f(X,Y);
S = cshep2d([X Y Z]);
// evaluation inside and outside the square [0,1]x[0,1]
m = 40;
xx = linspace(-1.5,0.5,m);
[xp,yp] = ndgrid(xx,xx);
zp = eval_cshep2d(xp,yp,S);
// compute facet (to draw one color for extrapolation region
// and another one for the interpolation region)
[xf,yf,zf] = genfac3d(xx,xx,zp);
colors = 2*ones(1,size(zf,2));
// indices corresponding to facet in the interpolation region
ind=find( mean(xf,"r")>0 & mean(xf,"r")<1 & mean(yf,"r")>0 & mean(yf,"r")<1 );
colors(ind)=3;
clf();
plot3d(xf,yf,list(zf,colors), flag=[2 6 4])
legends(["extrapolation region","interpolation region"],[2 3],1)
show_window()
]]></scilab:image>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="cshep2d">cshep2d</link>
            </member>
        </simplelist>
    </refsection>
    <refsection>
        <title>History</title>
        <revhistory>
            <revision>
                <revnumber>5.4.0</revnumber>
                <revremark>previously, imaginary part of input arguments were implicitly ignored.</revremark>
            </revision>
        </revhistory>
    </refsection>
</refentry>
