1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
<?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="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 [, 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>
(オプション)<latex>[x_1,\ x_n]</latex>の外側で.
<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>
は,<latex>[x_1,\ x_n]</latex>の範囲で定義された,連続で微分可能な関数です.
これは,3次元多項式の集合からなり,その各々は<latex>p_k(X)</latex>が
<latex>[x_k,\ x_{k+1}]</latex>で定義され,
隣接する多項式と値と傾きで接続されています.
つまり, <latex>X\ \in\ [x_k,\ x_{k+1}],\ s(X) = p_k(X)</latex>の各々について,
<latex>s(x_i) = y_i,\quad \mbox{and}\quad s'(x_i) = d_i</latex>を記述できます.
</para>
<latex style="display" align="center"><![CDATA[ yp_i = s(xp_i) \quad or \quad yp_{i,j} = s(xp_{i,j}) ]]></latex>
<latex style="display" align="center"><![CDATA[ yp1_i = s'(xp_i) \quad or \quad yp1_{i,j} = s'(xp_{i,j}) ]]></latex>
<latex style="display" align="center"><![CDATA[ yp2_i = s''(xp_i) \quad or \quad yp2_{i,j} = s''(xp_{i,j}) ]]></latex>
<latex style="display" align="center"><![CDATA[ yp3_i = s'''(xp_i) \quad or \quad yp3_{i,j} = s'''(xp_{i,j}) ]]></latex>
<para>
<literal>out_mode</literal>パラメータは
補外,すなわち,<literal>xp(i)</literal>が<latex>[x_1,\ x_n]</latex> の範囲にない場合
の評価規則を設定します :
</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>以下のように定義される補外 :</para>
<latex style="display" align="center"><![CDATA[ xp_i < x_1 \Rightarrow yp_i = y_1 ]]></latex>
<latex style="display" align="center"><![CDATA[ xp_i > x_n \Rightarrow yp_i = y_n ]]></latex>
</listitem>
</varlistentry>
<varlistentry>
<term>"natural"</term>
<listitem>
<para>以下のように定義される補外
(<latex>p_i(x)</latex> は,<latex>[x_i,\ x_{i+1}]</latex>
において<literal>s(X)</literal>を定義する多項式です)
</para>
<latex style="display" align="center"><![CDATA[ xp_i < x_1 \Rightarrow yp_i = p_1(xp_i) ]]></latex>
<latex style="display" align="center"><![CDATA[ xp_i > x_n \Rightarrow yp_i = p_{n-1}(xp_i) ]]></latex>
</listitem>
</varlistentry>
<varlistentry>
<term>"linear"</term>
<listitem>
<para>補外は以下のように定義されます :</para>
<latex style="display" align="center"><![CDATA[ xp_i < x_1 \Rightarrow yp_i = y_1 + d_1.(xp_i - x_1) ]]></latex>
<latex style="display" align="center"><![CDATA[ xp_i > x_n \Rightarrow yp_i = y_n + d_n.(xp_i - x_n) ]]></latex>
</listitem>
</varlistentry>
<varlistentry>
<term>"periodic"</term>
<listitem>
<para>
<literal>s</literal> は周期性により拡張されます.
</para>
<latex style="display" align="center"><![CDATA[ yp_i = s( x_1 + ( (xp_i-x_1)\ \mbox{modulo}\ [x_n-x_1] ) ) ]]></latex>
</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>
<refsection>
<title>履歴</title>
<revhistory>
<revision>
<revnumber>5.4.0</revnumber>
<revremark>以前では, 入力引数の虚部は暗黙のうちに無視されていました.</revremark>
</revision>
</revhistory>
</refsection>
</refentry>
|