<?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="interp" xml:lang="ja">
    <refnamediv>
        <refname>interp</refname>
        <refpurpose>3次スプライン評価関数</refpurpose>
    </refnamediv>
    <refsynopsisdiv>
        <title>呼び出し手順</title>
        <synopsis>
            [yp, yp1, yp2, yp3] = interp(xp, x, y, d)
            [yp, yp1, yp2, yp3] = interp(xp, x, y, d, out_mode)
        </synopsis>
    </refsynopsisdiv>
    <refsection>
        <title>引数</title>
        <variablelist>
            <varlistentry>
                <term>x,y</term>
                <listitem>
                    <para>
                        同じ大きさ <literal>n</literal> の実数ベクトル:
                        補間および関連する3次スプライン
                        (以下,<literal>s(X)</literal>と呼びます)または
                        サブスプライン関数を定義します.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>d</term>
                <listitem>
                    <para>size(x)の実数ベクトル:
                        微分 s'(x). 多くの場合, s'(x) は関数splin(x, y,..)により
                        適当に推定されます.
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>out_mode</term>
                <listitem>
                    <para>
                        (オプション)[x<subscript>1</subscript>, x<subscript>n</subscript>]の外側で.
                        <literal>X</literal> に対する<literal>s(X)</literal>を定義します.
                        利用可能な値: "by_zero" | "by_nan" | "C0" | "natural" | "linear" | "periodic"
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>xp</term>
                <listitem>
                    <para>
                        実数ベクトルまたは行列:
                        <literal>Y</literal> が未知の座標で,
                        <literal>s(xp)</literal>で推定されます
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>yp</term>
                <listitem>
                    <para>
                        size(xp)のベクトルまたは行列:
                        <literal>yp(i) = s(xp(i))</literal> または
                        <literal>yp(i,j) = s(xp(i,j))</literal>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>yp1, yp2, yp3</term>
                <listitem>
                    <para>
                        size(x) のベクトル(または行列):
                        微分<literal>s'(xp)</literal>, <literal>s''(xp)</literal> および
                        <literal>s'''(xp)</literal>の要素毎の評価.
                    </para>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>説明</title>
        <para>
            指定した点の<literal>(x,y)</literal> 集合を補間する3次スプライン関数 <literal>s(X)</literal>
            は,[x<subscript>1</subscript>, x<subscript>n</subscript>]の範囲で定義された,連続で微分可能な関数です.
            これは,3次元多項式の集合からなり,その各々はp<subscript>k</subscript>(X)が
            [x<subscript>k</subscript>, x<subscript>k+1</subscript>]で定義され,
            隣接する多項式と値と傾きで接続されています. つまり,
            <emphasis>
                X &#8712; [x<subscript>k</subscript>, x<subscript>k+1</subscript>],
                s(X) = p<subscript>k</subscript>(X)
            </emphasis> の各々について,
            <emphasis>
                s(x<subscript>i</subscript>) = y<subscript>i</subscript>,  and  
                s'(x<subscript>i</subscript>) = d<subscript>i</subscript>
            </emphasis>
            を記述できます.
        </para>
        <para>
            <table align="center">
            <tr align="center">
                <td><emphasis>
                        yp<subscript>i</subscript> = s(xp<subscript>i</subscript>)
                           or   
                        yp<subscript>ij</subscript> = s(xp<subscript>ij</subscript>)
                    </emphasis>
                </td>
            </tr>
            <tr align="center">
                <td><emphasis>
                        yp1<subscript>i</subscript> = s'(xp<subscript>i</subscript>)
                           or   
                        yp1<subscript>ij</subscript> = s'(xp<subscript>ij</subscript>)
                    </emphasis>
                </td>
            </tr>
            <tr align="center">
                <td><emphasis>
                        yp2<subscript>i</subscript> = s''(xp<subscript>i</subscript>)
                           or   
                        yp2<subscript>ij</subscript> = s''(xp<subscript>ij</subscript>)
                    </emphasis>
                </td>
            </tr>
            <tr align="center">
                <td><emphasis>
                        yp3<subscript>i</subscript> = s'''(xp<subscript>i</subscript>)
                           or   
                        yp3<subscript>ij</subscript> = s'''(xp<subscript>ij</subscript>)
                    </emphasis>
                </td>
            </tr>
            </table>
        </para>
        <para>
            <literal>out_mode</literal>パラメータは
            補外,すなわち,<literal>xp(i)</literal>が[x<subscript>1</subscript>, x<subscript>n</subscript>] の範囲にない場合
            の評価規則を設定します :
        </para>
        <variablelist>
            <varlistentry>
                <term>"by_zero"</term>
                <listitem>
                    <para>0による補外が行われます</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"by_nan"</term>
                <listitem>
                    <para>Nan (%nan)による補外</para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"C0"</term>
                <listitem>
                    <para>以下のように定義される補外 :
                        <table align="center">
                        <tr align="center"><td><emphasis>
                            xp<subscript>i</subscript> &lt; x<subscript>1</subscript>  ⇒ 
                            yp<subscript>i</subscript> = y<subscript>1</subscript>
                            </emphasis></td></tr>
                        <tr align="center"><td><emphasis>
                            xp<subscript>i</subscript> > x<subscript>n</subscript>  ⇒ 
                            yp<subscript>i</subscript> = y<subscript>n</subscript>
                            </emphasis></td></tr>
                        </table>
                    </para>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"natural"</term>
                <listitem>
                    <para>以下のように定義される補外
                        (p<subscript>i</subscript>(x) は,[x<subscript>i</subscript>, x<subscript>i+1</subscript>]
                        において<literal>s(X)</literal>を定義する多項式です)
                    </para>
                    <table align="center">
                    <tr align="center"><td><emphasis>
                        xp<subscript>i</subscript> &lt; x<subscript>1</subscript>  ⇒ 
                        yp<subscript>i</subscript> = p<subscript>1</subscript>(xp<subscript>i</subscript>)
                        </emphasis></td></tr>
                    <tr align="center"><td><emphasis>
                        xp<subscript>i</subscript> > x<subscript>n</subscript>  ⇒ 
                        yp<subscript>i</subscript> = p<subscript>n-1</subscript>(xp<subscript>i</subscript>)
                        </emphasis></td></tr>
                    </table>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"linear"</term>
                <listitem>
                    <para>補外は以下のように定義されます :</para>
                    <table align="center">
                    <tr align="center"><td><emphasis>
                        xp<subscript>i</subscript> &lt; x<subscript>1</subscript>  ⇒ 
                        yp<subscript>i</subscript> = y<subscript>1</subscript> +
                            d<subscript>1</subscript>.(xp<subscript>i</subscript> - x<subscript>1</subscript>)
                        </emphasis></td></tr>
                    <tr align="center"><td><emphasis>
                        xp<subscript>i</subscript> > x<subscript>n</subscript>  ⇒ 
                        yp<subscript>i</subscript> = y<subscript>n</subscript> +
                            d<subscript>n</subscript>.(xp<subscript>i</subscript> - x<subscript>n</subscript>)
                        </emphasis></td></tr>
                    </table>
                </listitem>
            </varlistentry>
            <varlistentry>
                <term>"periodic"</term>
                <listitem>
                    <para>
                        <literal>s</literal> は周期性により拡張されます.
                    </para>
                    <table align="center">
                    <tr><td><emphasis>
                        yp<subscript>i</subscript> = s( x<subscript>1</subscript> + (xp<subscript>i</subscript> - x<subscript>1</subscript>) modulo (x<subscript>n</subscript>-x<subscript>1</subscript>) )
                        </emphasis></td></tr>
                    </table>
                </listitem>
            </varlistentry>
        </variablelist>
    </refsection>
    <refsection>
        <title>例</title>
        <programlisting role="example"><![CDATA[
// splin および lsq_splinの例を参照
// スプラインおよびサブスプラインの C2およびC1連続性を示す例
a = -8; b = 8;
x = linspace(a,b,20)';
y = sinc(x);
dk = splin(x,y);  // not_a_knot
df = splin(x,y, "fast");
xx = linspace(a,b,800)';
[yyk, yy1k, yy2k] = interp(xx, x, y, dk);
[yyf, yy1f, yy2f] = interp(xx, x, y, df);
clf()
subplot(3,1,1)
plot2d(xx, [yyk yyf])
plot2d(x, y, style=-9)
legends(["not_a_knot spline","fast sub-spline","interpolation points"],...
        [1 2 -9], "ur",%f)
xtitle("spline interpolation")
subplot(3,1,2)
plot2d(xx, [yy1k yy1f])
legends(["not_a_knot spline","fast sub-spline"], [1 2], "ur",%f)
xtitle("spline interpolation (derivatives)")
subplot(3,1,3)
plot2d(xx, [yy2k yy2f])
legends(["not_a_knot spline","fast sub-spline"], [1 2], "lr",%f)
xtitle("spline interpolation (second derivatives)")
 ]]></programlisting>
        <scilab:image>
            a = -8; b = 8;
            x = linspace(a,b,20)';
            y = sinc(x);
            dk = splin(x,y);  // not_a_knot
            df = splin(x,y, "fast");
            xx = linspace(a,b,800)';
            [yyk, yy1k, yy2k] = interp(xx, x, y, dk);
            [yyf, yy1f, yy2f] = interp(xx, x, y, df);
            clf()
            subplot(3,1,1)
            plot2d(xx, [yyk yyf])
            plot2d(x, y, style=-9)
            legends(["not_a_knot spline","fast sub-spline","interpolation points"],...
            [1 2 -9], "ur",%f)
            xtitle("spline interpolation")
            subplot(3,1,2)
            plot2d(xx, [yy1k yy1f])
            legends(["not_a_knot spline","fast sub-spline"], [1 2], "ur",%f)
            xtitle("spline interpolation (derivatives)")
            subplot(3,1,3)
            plot2d(xx, [yy2k yy2f])
            legends(["not_a_knot spline","fast sub-spline"], [1 2], "lr",%f)
            xtitle("spline interpolation (second derivatives)")
        </scilab:image>
        <programlisting role="example"><![CDATA[
// 異なる補外の方法を示す例
x = linspace(0,1,11)';
y = cosh(x-0.5);
d = splin(x,y);
xx = linspace(-0.5,1.5,401)';
yy0 = interp(xx,x,y,d,"C0");
yy1 = interp(xx,x,y,d,"linear");
yy2 = interp(xx,x,y,d,"natural");
yy3 = interp(xx,x,y,d,"periodic");
clf()
plot2d(xx,[yy0 yy1 yy2 yy3],style=2:5,frameflag=2,leg="C0@linear@natural@periodic")
xtitle(" different way to evaluate a spline outside its domain")
 ]]></programlisting>
        <scilab:image>
            x = linspace(0,1,11)';
            y = cosh(x-0.5);
            d = splin(x,y);
            xx = linspace(-0.5,1.5,401)';
            yy0 = interp(xx,x,y,d,"C0");
            yy1 = interp(xx,x,y,d,"linear");
            yy2 = interp(xx,x,y,d,"natural");
            yy3 = interp(xx,x,y,d,"periodic");
            clf()
            plot2d(xx,[yy0 yy1 yy2 yy3],style=2:5,frameflag=2,leg="C0@linear@natural@periodic")
            xtitle(" different way to evaluate a spline outside its domain")
        </scilab:image>
    </refsection>
    <refsection role="see also">
        <title>参照</title>
        <simplelist type="inline">
            <member>
                <link linkend="splin">splin</link>
            </member>
            <member>
                <link linkend="lsq_splin">lsq_splin</link>
            </member>
        </simplelist>
    </refsection>
</refentry>
