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