1 function y=restriction_2d(x)
5 % y bilinear average on twice coarser grid
6 % this is transpose of prolongation with weighting
9 % x=magic(2); restriction_2d(x)
11 % map vector to 2d grid with zero boundary
12 % average from neighbors with the same weights as prolongation
14 % y = zeros(size(xx(2:2:end-1,2:2:end-1)));
15 if any(mod(size(x),2))==0
16 error('restriction_2d: input dimensions must be odd')
20 y = tw*x(2+i1:2:end-1+i1,2+i2:2:end-1+i2);
23 if (i1 ~=0) || (i2 ~=0)
24 w = tw/((1+abs(i1))*(1+abs(i2)));
25 y = y + w*x(2+i1:2:end-1+i1,2+i2:2:end-1+i2);