1% Testing divand in 2 dimensions. 2 3%try 4% grid of background field 5[xi,yi] = ndgrid(linspace(0,1,30)); 6fi_ref = sin( xi*6 ) .* cos( yi*6); 7 8% grid of observations 9[x,y] = ndgrid(linspace(eps,1-eps,20)); 10x = x(:); 11y = y(:); 12 13f = sin( x*6 ) .* cos( y*6); 14 15mask = ones(size(xi)); 16pm = ones(size(xi)) / (xi(2,1)-xi(1,1)); 17pn = ones(size(xi)) / (yi(1,2)-yi(1,1)); 18 19%fi = divand(mask,{pm,pn},{xi,yi},{x,y},f,.1,20); 20fi = divand(mask,{pm,pn},{xi,yi},{x,y},f,.1,20,'factorize',0); 21rms = divand_rms(fi_ref,fi); 22 23if (rms > 0.005) 24 error('unexpected large difference with reference field'); 25end 26 27%fprintf('OK (rms=%g)\n',rms); 28 29 30fi_dual = divand(mask,{pm,pn},{xi,yi},{x,y},f,.1,20,'primal',0); 31rms = divand_rms(fi_dual,fi); 32 33%fprintf(1,'Testing dual 2D-optimal variational inverse: '); 34 35if (rms > 1e-6) 36 error('unexpected large difference with reference field'); 37end 38 39fprintf('(max difference=%g) ',rms); 40 41 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