%
%  Purpose: to set initial conditions for solution U and
%           initialise other variables.
%
%  Variables:
%
%  U  Array for numerical solution
%
function [X,U] = LagenExactSmooth(N,TIME,SPEEDA)
  % Calculate mesh size DX
  DX = 2.0/N ;
  X = [-1+DX/2-TIME*SPEEDA:DX:1-DX/2-TIME*SPEEDA] ;
  % put the solution in [-1..1]
  for i=1:N
    while ( X(i) < -1 )
      X(i) = X(i) + 2 ;
    end ;
    while ( X(i) >  1 )
      X(i) = X(i) - 2 ;
    end ;
  end
  % smooth profile
  U = exp( -8 .* X .^ 2 ) ;
  X = [-1+DX/2:DX:1-DX/2] ;
end
