1 function y=prolongation_2d(x)
6 % y bilinear interpolation wrapped by zeros
9 % x=magic(2); prolongation_2d(x)
11 % map vector to 2d grid with zero boundary
14 xx(2:nn(1)+1,2:nn(2)+1)=reshape(x,nn);
17 % copy values on coarse points
18 y(2:2:end-1,2:2:end-1)=xx(2:end-1,2:end-1);
19 % averages to coarse edge midpoints in direction 1
20 y(1:2:end,2:2:end-1)=0.5*(xx(1:end-1,2:end-1)+xx(2:end,2:end-1));
21 % averages to coarse edge midpoints in direction 2
22 y(2:2:end-1,1:2:end)=0.5*(xx(2:end-1,1:end-1)+xx(2:end-1,2:end));
23 % averages to coarse cell centers in directions 1 and 2
24 y(1:2:end,1:2:end)=0.25*(xx(1:end-1,1:end-1)+xx(2:end,1:end-1)+...
25 xx(1:end-1,2:end) +xx(2:end,2:end));