1% Testing divand in 3 dimensions.
2
3% grid of background field
4[xi,yi,zi] = ndgrid(linspace(0,1.,15));
5fi_ref = sin(6*xi) .* cos(6*yi) .* sin(6*zi);
6
7% grid of observations
8[x,y,z] = ndgrid(linspace(eps,1-eps,10));
9x = x(:);
10y = y(:);
11z = z(:);
12
13% reference field
14f = sin(6*x) .* cos(6*y) .* sin(6*z);
15
16% all points are valid points
17mask = ones(size(xi));
18
19% this problem has a simple cartesian metric
20% pm is the inverse of the resolution along the 1st dimension
21% pn is the inverse of the resolution along the 2nd dimension
22% po is the inverse of the resolution along the 3rd dimension
23pm = ones(size(xi)) / (xi(2,1,1)-xi(1,1,1));
24pn = ones(size(xi)) / (yi(1,2,1)-yi(1,1,1));
25po = ones(size(xi)) / (zi(1,1,2)-zi(1,1,1));
26
27% correlation length
28len = 0.1;
29
30% signal-to-noise ratio
31lambda = 100;
32
33% fi is the interpolated field
34fi = divand(mask,{pm,pn,po},{xi,yi,zi},{x,y,z},f,len,lambda);
35
36% compute RMS to background field
37rms = sqrt(mean((fi_ref(:) - fi(:)).^2));
38
39if (rms > 0.04)
40  error('unexpected large difference with reference field');
41end
42
43fprintf('(max difference=%g) ',rms);
44
45% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be>
46%
47% This program is free software; you can redistribute it and/or modify it under
48% the terms of the GNU General Public License as published by the Free Software
49% Foundation; either version 2 of the License, or (at your option) any later
50% version.
51%
52% This program is distributed in the hope that it will be useful, but WITHOUT
53% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
55% details.
56%
57% You should have received a copy of the GNU General Public License along with
58% this program; if not, see <http://www.gnu.org/licenses/>.
59