File: splin3d.xml

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (186 lines) | stat: -rw-r--r-- 5,840 bytes parent folder | download
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
<?xml version="1.0" encoding="UTF-8"?>
<refentry version="5.0-subset Scilab" xml:id="splin3d" xml:lang="en"
          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">
  <info>
    <pubdate>$LastChangedDate$</pubdate>
  </info>

  <refnamediv>
    <refname>splin3d</refname>

    <refpurpose>spline gridded 3d interpolation</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <title>Calling Sequence</title>

    <synopsis>tl = splin3d(x, y, z, v, [order])</synopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Parameters</title>

    <variablelist>
      <varlistentry>
        <term>x,y,z</term>

        <listitem>
          <para>strictly increasing row vectors (each with at least 3
          components) defining the 3d interpolation grid</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>v</term>

        <listitem>
          <para>nx x ny x nz hypermatrix (nx, ny, nz being the length of
          <literal>x</literal>, <literal>y</literal> and
          <literal>z</literal>)</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>order</term>

        <listitem>
          <para>(optional) a 1x3 vector [kx,ky,kz] given the order of the
          tensor spline in each direction (default [4,4,4], i.e. tricubic
          spline)</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>tl</term>

        <listitem>
          <para>a tlist of type splin3d defining the spline</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>

  <refsection>
    <title>Description</title>

    <para>This function computes a 3d tensor spline <emphasis>s</emphasis>
    which interpolates the <emphasis>(xi,yj,zk,vijk)</emphasis> points, ie, we
    have <emphasis>s(xi,yj,zk)=vijk</emphasis> for all
    <emphasis>i=1,..,nx</emphasis>, <emphasis>j=1,..,ny</emphasis> and
    <emphasis>k=1,..,nz</emphasis>. The resulting spline
    <emphasis>s</emphasis> is defined by <literal>tl</literal> which consists
    in a B-spline-tensor representation of <emphasis>s</emphasis>. The
    evaluation of <emphasis>s</emphasis> at some points must be done by the
    <link linkend="interp3d">interp3d</link> function (to compute
    <emphasis>s</emphasis> and its first derivatives) or by the <link
    linkend="bsplin3val">bsplin3val</link> function (to compute an arbitrary
    derivative of <emphasis>s</emphasis>) . Several kind of splines may be
    computed by selecting the order of the spline in each direction
    <literal>order=[kx,ky,kz]</literal>.</para>
  </refsection>

  <refsection>
    <title>Remark</title>

    <para>This function works under the conditions:</para>

    <informalequation>
      <mediaobject>
        <imageobject>
          <imagedata align="center" fileref="../mml/splin3d_equation1.mml" />
        </imageobject>
      </mediaobject>
    </informalequation>

    <para>an error being issued when they are not respected.</para>
  </refsection>

  <refsection>
    <title>Examples</title>

    <programlisting role="example"><![CDATA[ 
// example 1
// =============================================================================

func =  "v=cos(2*%pi*x).*sin(2*%pi*y).*cos(2*%pi*z)";
deff("v=f(x,y,z)",func);
n = 10;  // n x n x n  interpolation points
x = linspace(0,1,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]);
m = 10000;
// compute an approximated error
xp = grand(m,1,"def"); yp = grand(m,1,"def"); zp = grand(m,1,"def");
vp_exact = f(xp,yp,zp);
vp_interp = interp3d(xp,yp,zp, tl);
er = max(abs(vp_exact - vp_interp))
// now retry with n=20 and see the error

// example 2 (see linear_interpn help page which have the
//            same example with trilinear interpolation)
// =============================================================================

exec("SCI/modules/interpolation/demos/interp_demo.sci")
func =  "v=(x-0.5).^2 + (y-0.5).^3 + (z-0.5).^2";
deff("v=f(x,y,z)",func);
n = 5; 
x = linspace(0,1,n); y=x; z=x;
[X,Y,Z] = ndgrid(x,y,z);
V = f(X,Y,Z);
tl = splin3d(x,y,z,V);
// compute (and display) the 3d spline interpolant on some slices
m = 41;
dir = ["z="  "z="  "z="  "x="  "y="];
val = [ 0.1   0.5   0.9   0.5   0.5];
ebox = [0 1 0 1 0 1];
XF=[]; YF=[]; ZF=[]; VF=[];
for i = 1:length(val)
  [Xm,Xp,Ym,Yp,Zm,Zp] = slice_parallelepiped(dir(i), val(i), ebox, m, m, m);
  Vm = interp3d(Xm,Ym,Zm, tl);
  [xf,yf,zf,vf] = nf3dq(Xm,Ym,Zm,Vm,1);
  XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf]; VF = [VF vf]; 
  Vp = interp3d(Xp,Yp,Zp, tl);
  [xf,yf,zf,vf] = nf3dq(Xp,Yp,Zp,Vp,1);
  XF = [XF xf]; YF = [YF yf]; ZF = [ZF zf]; VF = [VF vf]; 
end
nb_col = 128;
vmin = min(VF); vmax = max(VF);
color = dsearch(VF,linspace(vmin,vmax,nb_col+1));
xset("colormap",jetcolormap(nb_col));
clf(); xset("hidden3d",xget("background"));
colorbar(vmin,vmax)
plot3d(XF, YF, list(ZF,color), flag=[-1 6 4])
xtitle("3d spline interpolation of "+func)
xselect()
 ]]></programlisting>
  </refsection>

  <refsection>
    <title>See Also</title>

    <simplelist type="inline">
      <member><link linkend="linear_interpn">linear_interpn</link></member>

      <member><link linkend="interp3d">interp3d</link></member>

      <member><link linkend="bsplin3val">bsplin3val</link></member>
    </simplelist>
  </refsection>

  <refsection>
    <title>Authors</title>

    <simplelist type="vert">
      <member>R.F. Boisvert, C. De Boor (code from the CMLIB fortran
      lib)</member>

      <member>B. Pincon (scilab interface)</member>
    </simplelist>
  </refsection>
</refentry>