function v2h=coarsen(vh)

% Coarsening by full weight averaging for multigrid
% F. Waleffe 11/15/2000

Nh =length(vh); %N must be 2^m+1
N2h=(Nh-1)/2+1; v2h=zeros(N2h,1);

for j=2:N2h-1,
  v2h(j)=( vh(2*j-2)+2*vh(2*j-1)+vh(2*j) )/4;
end

v2h(1)=vh(1); v2h(N2h)=vh(Nh); % Dirichlet BC
