function [u1] = waveu1(x, delt, al, x0l, deltal, ar, x0r, deltar)
% waveu1 Initialization function for wave [PHYS210-fda]
%
% Initializes the first time step of the O(h^2) FDA solution of 
% the wave equation using left- and right-moving gaussians.
%
% Assumes that x is monotonically increasing.

   % Define default vector to be 0 length
   err = 0;
   u1  = zeros(0,0);
   if ~ isvector(x) 
      errmsg('x is not a vector');
      return;
   end
   % Initialize u1 to 0 vector
   u1 = zeros(1,length(x));
   if deltal == 0
      errmsg('deltal = 0');
      err = 1;
   end
   if deltar == 0
      errmsg('deltar = 0');
      err = 1;
   end
   if err
      return
   end
   % Compute left- and right-moving gaussian profiles, and 1st & 2nd 
   % derivatives using 'gaussian'
   [gl dgl ddgl] = gaussian(x, al, x0l, deltal);
   [gr dgr ddgr] = gaussian(x, ar, x0r, deltar);
   u1 = gl + gr;
   % Ensure that initial data is compatible with boundary conditions
   u1([1 length(u1)]) = 0;
end

function [] = errmsg(errstr)
   fprintf(stderr,'waveu1: %s\n',errstr);
end
