function Sv = splice( v, t, rcfn, a, eps)
% Apply the splicing operator defined by a 
% rising cutoff function rcfn() to a signal
% function v(), at the point a, with reach eps.
%
% Inputs:
%     v     signal function
%     t     vector of time values
%     rcfn  rising cutoff function
%     a     point at which to fray
%     eps   reach of the fraying operator
%
% Output:
%     Sv    vector of Sv(t) for all times t.
%
% Example:
%     r=@(x) rcf(x,1); u=@(x)cos(x/2); t=-2:0.1:2; a=0; eps=1;
%     plot(t,splice(u,t,r,a,eps)); % plot the spliced signal
%     hold on; plot(t,u(t));    % overlay the original signal
%
% M.V.Wickerhauser, 2017-02-21
% Example added 2023-02-22
%
  Sv=t;   % initialize output array
  for(i=1:length(t))
    s=t(i);
    rplus = rcfn( (s-a)/eps );
    rminus = rcfn( (a-s)/eps );
    vplus = v(s);
    vminus = v(2*a-s);
    if(s>a)
      Sv(i)= vplus*rplus - vminus*rminus;
    else
      if(s<a)
        Sv(i)= vplus*rminus + vminus*rplus;
      else
        Sv(i)=v(a);
      endif
    endif
  end
end

