<?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:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
          xml:id="bsplin3val" xml:lang="en">
    <refnamediv>
        <refname>bsplin3val</refname>
        <refpurpose>3d spline arbitrary derivative evaluation
            function
        </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>Syntax</title>
        <synopsis>dfp = bsplin3val(xp, yp, zp, tl, der)</synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>Arguments</title>
        <variablelist>
            <varlistentry>
                <term>xp, yp, zp</term>
                <listitem>
                    <para>real vectors or matrices of same size</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>tl</term>
                <listitem>
                    <para>tlist of type "splin3d", defining a 3d tensor spline (called
                        <literal>s</literal> in the following)
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>der</term>
                <listitem>
                    <para>
                        vector with 3 components <literal>[ox,oy,oz]</literal>
                        defining which derivative of <literal>s</literal> to compute.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>dfp</term>
                <listitem>
                    <para>
                        vector or matrix of same format than <literal>xp</literal>,
                        <literal>yp</literal> and <literal>zp</literal>, elementwise
                        evaluation of the specified derivative of <literal>s</literal> on
                        these points.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>Description</title>
        <para>
            While the function <link linkend="interp3d">interp3d</link> may
            compute only the spline <literal>s</literal> and its first derivatives,
            <literal>bsplin3val</literal> may compute any derivative of
            <literal>s</literal>. The derivative to compute is specified by the
            argument <literal>der=[ox,oy,oz]</literal> :
        </para>
        <para>
            <latex style="display" fontsize="18"
                alt="dfp(i)=∂^{oxoyoz}/(∂^ox.∂^oy.∂^oz) s(xp(i),yp(i),zp(i))">
                dfp(i)=\frac{\partial^{ox\,oy\,oz}}{\partial ^{ox}\,\partial ^{oy}\,\partial ^{oz}}
                        s\left(xp(i),yp(i),zp(i)\right)
            </latex>
        </para>
        <para>
            So <literal>der=[0 0 0]</literal> corresponds to
            <emphasis>s</emphasis>, <literal>der=[1 0 0]</literal> to
            <emphasis>ds/dx</emphasis>, <literal>der=[0 1 0]</literal> to
            <emphasis>ds/dy</emphasis>, <literal>der=[1 1 0]</literal> to
            <emphasis>d2s/dxdy</emphasis>, etc...
        </para>
        <para>For a point with coordinates
            <emphasis>(xp(i),yp(i),zp(i))</emphasis> outside the grid, the function
            returns 0.
        </para>
    </refsection>
    <refsection>
        <title>Examples</title>
        <programlisting role="example"><![CDATA[
deff("v=f(x,y,z)","v=cos(x).*sin(y).*cos(z)");
deff("v=fx(x,y,z)","v=-sin(x).*sin(y).*cos(z)");
deff("v=fxy(x,y,z)","v=-sin(x).*cos(y).*cos(z)");
deff("v=fxyz(x,y,z)","v=sin(x).*cos(y).*sin(z)");
deff("v=fxxyz(x,y,z)","v=cos(x).*cos(y).*sin(z)");
n = 20;  // n x n x n  interpolation points
x = linspace(0,2*%pi,n); y=x; z=x; // interpolation grid
[X,Y,Z] = ndgrid(x,y,z); V = f(X,Y,Z);
tl = splin3d(x,y,z,V,[5 5 5]);

// compute f and some derivates on a point
// and compare with the spline interpolant
xp = grand(1,1,"unf",0,2*%pi);
yp = grand(1,1,"unf",0,2*%pi);
zp = grand(1,1,"unf",0,2*%pi);

f_e = f(xp,yp,zp)
f_i = bsplin3val(xp,yp,zp,tl,[0 0 0])

fx_e = fx(xp,yp,zp)
fx_i = bsplin3val(xp,yp,zp,tl,[1 0 0])

fxy_e = fxy(xp,yp,zp)
fxy_i = bsplin3val(xp,yp,zp,tl,[1 1 0])

fxyz_e = fxyz(xp,yp,zp)
fxyz_i = bsplin3val(xp,yp,zp,tl,[1 1 1])

fxxyz_e = fxxyz(xp,yp,zp)
fxxyz_i = bsplin3val(xp,yp,zp,tl,[2 1 1])
 ]]></programlisting>
    </refsection>
    <refsection role="see also">
        <title>See also</title>
        <simplelist type="inline">
            <member>
                <link linkend="splin3d">splin3d</link>
            </member>
            <member>
                <link linkend="interp3d">interp3d</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
