rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
dirichlet_values_weighted_boxes.m
1 function Udirichlet = dirichlet_values_weighted_boxes(glob, params)
2 % function Udirichlet = dirichlet_values_weighted_boxes(glob, params)
3 %
4 % function computing dirichlet-values by pointwise evaluations
5 %
6 % values constant params.c_dir in box given by
7 % (beta=1): params.dir_box_xrange{1} and dir_box_yrange{1}
8 % (beta=0): params.dir_box_xrange{2} and dir_box_yrange{2}
9 % for intermediate betas, the two boxes are weighted
10 %
11 % required fields of params:
12 % dir_middle : y coordinate where upper and lower regions are separated
13 % c_dir : dirichlet value in box given by beta and
14 % 'dir_box_{xrange,yrange}'
15 % beta : dirichlet values == params.c_dir in box given by
16 % - '(beta=1)' params.dir_box_xrange{1} and dir_box_yrange{1}
17 % - '(beta=0)' params.dir_box_xrange{2} and dir_box_yrange{2}
18 % - for intermediate betas, the two boxes are weighted
19 % dir_box_xrange : cell array with two cells for length of the two boxes in
20 % x-direction
21 % dir_box_yxange : cell array with two cells for length of the two boxes in
22 % y-direction
23 
24 %
25 % in 'coefficients' mode, the parameters in brackets are empty
26 
27 % glob column check
28 if params.debug
29  if ~isempty(glob) && size(glob,1) < size(glob,2)
30  warning('coordinates in variable glob are given row-wise, but expected them to be column-wise');
31  if params.debug > 2
32  keyboard;
33  end
34  end
35 end
36 decomp_mode = params.decomp_mode;
37 
38 if decomp_mode == 2
39  if ~ismember('beta',params.mu_names)
40  Udirichlet = params.c_dir;
41  else
42  Udirichlet = params.c_dir * [params.beta; 1-params.beta];
43  end;
44 else % decomp_mode < 2
45  X = glob(:,1);
46  Y = glob(:,2);
47 
48  if decomp_mode == 0
49  Udirichlet = zeros(size(X));
50  xrange = params.dir_box_xrange{1};
51  yrange = params.dir_box_yrange{1};
52  fi = X > xrange(1) & ...
53  X < xrange(2) & ...
54  Y > yrange(1) & ...
55  Y < yrange(2);
56  Udirichlet(fi) = params.c_dir*params.beta;
57  xrange = params.dir_box_xrange{2};
58  yrange = params.dir_box_yrange{2};
59  fi = X > xrange(1) & ...
60  X < xrange(2) & ...
61  Y > yrange(1) & ...
62  Y < yrange(2);
63  Udirichlet(fi) = params.c_dir*(1-params.beta);
64  elseif decomp_mode == 1
65  % two components if beta is in mu, otherwise one component
66  Udirichlet = cell(2,1);
67  for q=1:2
68  Udirichlet{q} = zeros(size(X));
69  xrange = params.dir_box_xrange{q};
70  yrange = params.dir_box_yrange{q};
71  fi = X > xrange(1) & ...
72  X < xrange(2) & ...
73  Y > yrange(1) & ...
74  Y < yrange(2);
75  Udirichlet{q}(fi) = 1;
76  end;
77  if ~ismember('beta',params.mu_names)
78  % merge to one component
79  Udirichlet = {params.beta*Udirichlet{1} + ...
80  (1-params.beta)*Udirichlet{2}};
81  end;
82  else
83  error('decomp_mode unknown');
84  end
85 end
86 %| \docupdate