function  [u] = hammer(x,t,a,c)

for j = 1:length(x)
if t < a/c
  if x <= -a - c*t
     u(j) = 0;
  elseif (-a - c*t < x(j)) && (x(j) <= -a + c*t)
     u(j) = 1/2/c*(x(j) + c*t + a);
  elseif (-a + c*t < x(j)) && (x(j) <= a - c*t)
     u(j) = t;
  elseif (a - c*t < x(j)) && (x(j) <= a + c*t)
     u(j) = 1/2/c*(-x(j) + c*t + a);
  elseif a + c*t < x(j) 
     u(j) = 0;
  end
elseif t >= a/c
 if x(j) <= -1 - t
   u(j) = 0;
 elseif (-a - c*t < x(j)) && (x(j) <= a - c*t)
   u(j) = 1/2/c*(x(j) + c*t + a);
 elseif (a-c*t < x(j)) && (x(j) <= -a + c*t)
  u(j) = a/c;
 elseif (-a + c*t < x(j)) && (x(j) <= a + c*t)
   u(j) = 1/2/c*(-x(j) + c*t + a);
 elseif a + c*t < x(j) 
   u(j) = 0;
 end
end 
end 
