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