%
% Construct a two-dimensional, second-order roughening matrix
% for a PSCALE by PSCALE square nodal model (with 
% model wrap-around)
%
for i=1:PSCALE
  for j=1:PSCALE
    L((j-1)*PSCALE+i,(j-1)*PSCALE+i)=-4;
%
% Up
%
    if (i>1)
      L((j-1)*PSCALE+i,(j-1)*PSCALE+i-1)=1;
    else
      L((j-1)*PSCALE+i,(j-1)*PSCALE+PSCALE)=1;
    end
%
% Down
%
    if (i<PSCALE)
      L((j-1)*PSCALE+i,(j-1)*PSCALE+i+1)=1;
    else
      L((j-1)*PSCALE+i,(j-1)*PSCALE+1)=1;
    end
%
% Left
%
    if (j>1)
      L((j-1)*PSCALE+i,(j-2)*PSCALE+i)=1;
    else
      L((j-1)*PSCALE+i,(PSCALE-1)*PSCALE+i)=1;
    end
%
% Right
%
    if (j<PSCALE)
      L((j-1)*PSCALE+i,j*PSCALE+i)=1;
    else
      L((j-1)*PSCALE+i,i)=1;
    end
  end
end
