1% Include the constrain from the observations.
2%
3% s = divand_obs(s,xi,x,lambda,I)
4%
5% Set observations of variational problem.
6% It is assumed that the each coordinate depends only on one
7% index. If this is not the case, then matrix I must be provided.
8%
9% Input:
10%   s: structure created by divand_background
11%   xi: coordinates of observations*
12%   x: coordinates of grid*
13%   lambda: signal-to-noise ratio of observations
14%   I (optional): fractional indexes of location of observation
15%     within the grid
16%
17% Output:
18%   s: structure to be used by divand_factorize
19%
20% Note:
21%   *these parameters can either be specified as a cell
22%   array of all dimenions:
23%   xi = {Xi,Yi,Zi}
24%   or as n+1 dimensional array
25
26function c = divand_obs(s,xi,x,yo,lambda,I)
27
28if nargin == 5
29  I = [];
30end
31
32xi = cat_cell_array(xi);
33x = cat_cell_array(x);
34
35mask = s.mask;
36iscyclic = s.iscyclic;
37moddim = s.moddim;
38
39
40if isempty(I)
41  I = localize_separable_grid(x,mask,xi);
42end
43
44[H,out] = sparse_interp(mask,I,iscyclic);
45
46nout = sum(out);
47if nout ~= 0
48  fprintf(1,'Observations out of domain: %d\n',nout);
49end
50
51
52H = H * sparse_pack(mask)';
53
54% iB is scaled such that diag(inv(iB)) is 1 far from the
55% boundary
56
57if isscalar(lambda)
58  R = 1/lambda * speye(size(H,1));
59elseif isvector(lambda)
60  R = sparse_diag(lambda);
61else
62  R = lambda;
63end
64
65c.H = H;
66s.out = out;
67c.R = R;
68c.yo = yo;
69
70% Copyright (C) 2014 Alexander Barth <a.barth@ulg.ac.be>
71%
72% This program is free software; you can redistribute it and/or modify it under
73% the terms of the GNU General Public License as published by the Free Software
74% Foundation; either version 2 of the License, or (at your option) any later
75% version.
76%
77% This program is distributed in the hope that it will be useful, but WITHOUT
78% ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
79% FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
80% details.
81%
82% You should have received a copy of the GNU General Public License along with
83% this program; if not, see <http://www.gnu.org/licenses/>.
84