function [ut]=derv(n,t,u)
%
% Function derv computes the derivative vector 
% of the linear PDE
%
% Global variables
  global ndss;
%
% Problem parameters
  xl=0.0;
  xu=1.0;
%
% Select spatial differentiator
  if ndss==0
%
%   BC at x = 0
    ut(1)=0.0;
%
%   BC at x = 1
    ut(n)=0.0;
%
%   Interior points
    dx=(xu-xl)/(n-1);
    dxs=dx*dx;
    for i=2:n-1
      ut(i)=(u(i+1)-2.0*u(i)+u(i-1))/dxs;
    end
%
% End of explicit finite differences
%
% Differentiation routines dss002, dss004, dss006,
% dss008, dss010
  elseif ndss > 0 & ndss < 6
%
%   BCs at x = 0,1
    u(1)=0.0;
    u(n)=0.0;
%
%   uxx
    if ndss == 1
       [ux]=dss002(xl,xu,n,u);
      [uxx]=dss002(xl,xu,n,ux);
    elseif ndss == 2
       [ux]=dss004(xl,xu,n,u);
      [uxx]=dss004(xl,xu,n,ux);
    elseif ndss == 3
       [ux]=dss006(xl,xu,n,u);
      [uxx]=dss006(xl,xu,n,ux);
    elseif ndss == 4
       [ux]=dss008(xl,xu,n,u);
      [uxx]=dss008(xl,xu,n,ux);
    elseif ndss == 5
       [ux]=dss010(xl,xu,n,u);
      [uxx]=dss010(xl,xu,n,ux);
    end
%
%   PDE
    ut=uxx;
%
% Differentiation routines dss042, dss044, dss046,
% dss048, dss050
  elseif ndss > 5 & ndss < 11
%
%   BCs at x = 0,1
    u(1)=0.0;
    u(n)=0.0;
    nl=1;
    nu=1;
%
%   For Dirichlet boundary consitions (nl = nu
%   = 1), ux at the boundaries is not required
%   and not used by dss042 to dss050.  However,
%   Matlab terminates with a fatal error and a
%   message concerning ux.  Therefore, in order
%   to satisfy Matlab, the following statements
%   were added (presumably to size ux as a one
%   dimensional array, which is an input argument
%   to dss042 to dss050).  However, these state-
%   ments have no effect on the solution
    ux(1)=0.0;
    ux(n)=0.0;
%
%   uxx
    if ndss == 6
      [uxx]=dss042(xl,xu,n,u,ux,nl,nu);
    elseif ndss == 7
      [uxx]=dss044(xl,xu,n,u,ux,nl,nu);
    elseif ndss == 8
      [uxx]=dss046(xl,xu,n,u,ux,nl,nu);
    elseif ndss == 9
      [uxx]=dss048(xl,xu,n,u,ux,nl,nu);
    elseif ndss == 10
      [uxx]=dss050(xl,xu,n,u,ux,nl,nu);
    end
%
%   PDE
    ut=uxx;
%
% End of derv.m
  end


