xselect help page removed (the feature was already removed)
[scilab.git] / scilab / modules / interpolation / help / ja_JP / linear_interpn.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <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="linear_interpn" xml:lang="ja">
3     <refnamediv>
4         <refname>linear_interpn</refname>
5         <refpurpose>n 次元線形補間</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>呼び出し手順</title>
9         <synopsis>vp = linear_interpn(xp1,xp2,..,xpn, x1, ..., xn, v [,out_mode])</synopsis>
10     </refsynopsisdiv>
11     <refsection>
12         <title>パラメータ</title>
13         <variablelist>
14             <varlistentry>
15                 <term>xp1, xp2, .., xpn</term>
16                 <listitem>
17                     <para>同じ大きさの実数ベクトル (または行列)</para>
18                 </listitem>
19             </varlistentry>
20             <varlistentry>
21                 <term>x1 ,x2, ..., xn</term>
22                 <listitem>
23                     <para>
24                         n次元の補間グリッドを定義する
25                         (最低でも2つの要素を有する)単調増加の行ベクトル 
26                     </para>
27                 </listitem>
28             </varlistentry>
29             <varlistentry>
30                 <term>v</term>
31                 <listitem>
32                     <para>ベクトル ( n=1の場合), 行列 (n=2の場合) またはハイパー行列 ( n
33                         &gt; 2の場合) で,
34                         グリッド点における補間関数の基準値を指定します.
35                     </para>
36                 </listitem>
37             </varlistentry>
38             <varlistentry>
39                 <term>out_mode</term>
40                 <listitem>
41                     <para>(オプションの) 文字列で,
42                         グリッド外の評価方法(捕外)を定義します.
43                     </para>
44                 </listitem>
45             </varlistentry>
46             <varlistentry>
47                 <term>vp</term>
48                 <listitem>
49                     <para>
50                         <literal>xp1, ...,
51                             xpn
52                         </literal>
53                         と同じ大きさのベクトルまたは行列
54                     </para>
55                 </listitem>
56             </varlistentry>
57         </variablelist>
58     </refsection>
59     <refsection>
60         <title>説明</title>
61         <para>
62             n個のベクトル<literal>x1 ,x2,..., xn</literal>で定義された n次元グリッド
63             とそのグリッドにおける関数(例えば <emphasis>f</emphasis>)の値を次のように指定すると:
64         </para>
65         <informalequation>
66             <mediaobject>
67                 <imageobject>
68                     <imagedata align="center" fileref="../mml/linear_interpn_equation1.mml"/>
69                 </imageobject>
70             </mediaobject>
71         </informalequation>
72         <para>
73             この関数は, ベクトル<literal>xp1, xp2, ..., xpn</literal>(または行列)により定義された座標にある
74             (以下 <emphasis>s</emphasis> と呼ぶ)グリッドから次のように
75             <emphasis>f</emphasis>の線形補間を計算します:
76         </para>
77         <informalequation>
78             <mediaobject>
79                 <imageobject>
80                     <imagedata align="center" fileref="../mml/linear_interpn_equation2.mml"/>
81                 </imageobject>
82             </mediaobject>
83         </informalequation>
84         <para>
85             <literal>out_mode</literal> パラメータは捕外の評価規則を設定します:
86             <emphasis>Pi=(xp1(i),xp2(i),...,xpn(i))</emphasis> とすると,
87             <literal>out_mode</literal> は次の場合に評価規則を定義します:
88         </para>
89         <informalequation>
90             <mediaobject>
91                 <imageobject>
92                     <imagedata align="center" fileref="../mml/linear_interpn_equation3.mml"/>
93                 </imageobject>
94             </mediaobject>
95         </informalequation>
96         <para>その他の選択肢は以下があります:</para>
97         <variablelist>
98             <varlistentry>
99                 <term>"by_zero"</term>
100                 <listitem>
101                     <para>ゼロによる捕外が行われますa</para>
102                 </listitem>
103             </varlistentry>
104             <varlistentry>
105                 <term>"by_nan"</term>
106                 <listitem>
107                     <para>Nanによる捕外</para>
108                 </listitem>
109             </varlistentry>
110             <varlistentry>
111                 <term>"C0"</term>
112                 <listitem>
113                     <para>捕外が以下のように定義されます:</para>
114                     <programlisting role=""><![CDATA[ 
115 s(P) = s(proj(P)) where proj(P) is nearest point from P 
116                   located on the grid boundary.
117  ]]></programlisting>
118                 </listitem>
119             </varlistentry>
120             <varlistentry>
121                 <term>"natural"</term>
122                 <listitem>
123                     <para>捕外はその点に最も近いn線形パッチにより行われます.
124                     </para>
125                 </listitem>
126             </varlistentry>
127             <varlistentry>
128                 <term>"periodic"</term>
129                 <listitem>
130                     <para>
131                         <literal>s</literal> は周期的に拡張されます.
132                     </para>
133                 </listitem>
134             </varlistentry>
135         </variablelist>
136     </refsection>
137     <refsection>
138         <title>例</title>
139         <programlisting role="example"><![CDATA[ 
140 // example 1 : 1d linear interpolation
141 x = linspace(0,2*%pi,11);
142 y = sin(x);
143 xx = linspace(-2*%pi,4*%pi,400)';
144 yy = linear_interpn(xx, x, y, "periodic");
145 clf()
146 plot2d(xx,yy,style=2)
147 plot2d(x,y,style=-9, strf="000")
148 xtitle("linear interpolation of sin(x) with 11 interpolation points")
149
150 // example 2 : bilinear interpolation
151 n = 8;
152 x = linspace(0,2*%pi,n); y = x;
153 z = 2*sin(x')*sin(y);
154 xx = linspace(0,2*%pi, 40);
155 [xp,yp] = ndgrid(xx,xx);
156 zp = linear_interpn(xp,yp, x, y, z);
157 clf()
158 plot3d(xx, xx, zp, flag=[2 6 4])
159 [xg,yg] = ndgrid(x,x);
160 param3d1(xg,yg, list(z,-9*ones(1,n)), flag=[0 0])
161 xtitle("Bilinear interpolation of 2sin(x)sin(y)")
162 legends("interpolation points",-9,1)
163 show_window()
164
165 // example 3 : bilinear interpolation and experimentation
166 //             with all the outmode features
167 nx = 20; ny = 30;
168 x = linspace(0,1,nx);
169 y = linspace(0,2, ny);
170 [X,Y] = ndgrid(x,y);
171 z = 0.4*cos(2*%pi*X).*cos(%pi*Y);
172 nxp = 60 ; nyp = 120;
173 xp = linspace(-0.5,1.5, nxp);
174 yp = linspace(-0.5,2.5, nyp);
175 [XP,YP] = ndgrid(xp,yp);
176 zp1 = linear_interpn(XP, YP, x, y, z, "natural");
177 zp2 = linear_interpn(XP, YP, x, y, z, "periodic");
178 zp3 = linear_interpn(XP, YP, x, y, z, "C0");
179 zp4 = linear_interpn(XP, YP, x, y, z, "by_zero");
180 zp5 = linear_interpn(XP, YP, x, y, z, "by_nan");
181 clf()
182 subplot(2,3,1)
183 plot3d(x, y, z, leg="x@y@z", flag = [2 4 4])
184 xtitle("initial function 0.4 cos(2 pi x) cos(pi y)")
185 subplot(2,3,2)
186 plot3d(xp, yp, zp1, leg="x@y@z", flag = [2 4 4])
187 xtitle("Natural")
188 subplot(2,3,3)
189 plot3d(xp, yp, zp2, leg="x@y@z", flag = [2 4 4])
190 xtitle("Periodic")
191 subplot(2,3,4)
192 plot3d(xp, yp, zp3, leg="x@y@z", flag = [2 4 4])
193 xtitle("C0")
194 subplot(2,3,5)
195 plot3d(xp, yp, zp4, leg="x@y@z", flag = [2 4 4])
196 xtitle("by_zero")
197 subplot(2,3,6)
198 plot3d(xp, yp, zp5, leg="x@y@z", flag = [2 4 4])
199 xtitle("by_nan")
200 show_window()
201
202 // example 4 : trilinear interpolation (see splin3d help
203 //             page which have the same example with
204 //             tricubic spline interpolation)
205 exec("SCI/modules/interpolation/demos/interp_demo.sci")
206 func =  "v=(x-0.5).^2 + (y-0.5).^3 + (z-0.5).^2";
207 deff("v=f(x,y,z)",func);
208 n = 5; 
209 x = linspace(0,1,n); y=x; z=x;
210 [X,Y,Z] = ndgrid(x,y,z);
211 V = f(X,Y,Z);
212 // compute (and display) the linear interpolant on some slices
213 m = 41;
214 dir = ["z="  "z="  "z="  "x="  "y="];
215 val = [ 0.1   0.5   0.9   0.5   0.5];
216 ebox = [0 1 0 1 0 1];
217
218 XF=[]; YF=[]; ZF=[]; VF=[];
219 for i = 1:length(val)
220   [Xm,Xp,Ym,Yp,Zm,Zp] = slice_parallelepiped(dir(i), val(i), ebox, m, m, m);
221   Vm = linear_interpn(Xm,Ym,Zm, x, y, z, V);
222   [xf,yf,zf,vf] = nf3dq(Xm,Ym,Zm,Vm,1);
223   XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf]; VF = [VF vf]; 
224   Vp =  linear_interpn(Xp,Yp,Zp, x, y, z, V);
225   [xf,yf,zf,vf] = nf3dq(Xp,Yp,Zp,Vp,1);
226   XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf]; VF = [VF vf]; 
227 end
228 nb_col = 128;
229 vmin = min(VF); vmax = max(VF);
230 color = dsearch(VF,linspace(vmin,vmax,nb_col+1));
231 xset("colormap",jetcolormap(nb_col));
232 clf()
233 xset("hidden3d",xget("background"))
234 colorbar(vmin,vmax)
235 plot3d(XF, YF, list(ZF,color), flag=[-1 6 4])
236 xtitle("tri-linear interpolation of "+func)
237 show_window()
238  ]]></programlisting>
239     </refsection>
240     <refsection role="see also">
241         <title>参照</title>
242         <simplelist type="inline">
243             <member>
244                 <link linkend="interpln">interpln</link>
245             </member>
246             <member>
247                 <link linkend="splin">splin</link>
248             </member>
249             <member>
250                 <link linkend="splin2d">splin2d</link>
251             </member>
252             <member>
253                 <link linkend="splin3d">splin3d</link>
254             </member>
255         </simplelist>
256     </refsection>
257 </refentry>