function fnew = fnrfn(f,addpts)
%FNRFN Insert additional points into the partition for F
%
%   FNRFN(F,ADDPTS) inserts the specified ADDPTS into the partition 
%   (knots or breaks) for F.  
%
%   For example, if one wants to add the cubic polynomial with coefficient
%   vector [1,-1,1,2] to the cubic spline in F in ppform, then FNRFN is of 
%   help in the following way (taken, more or less, from FNCMB):
%      pp = fnrfn(ppmak([0 1],[1,-1,1,2]),fnbrk(f,'br'));
%      ff = fnrfn(f,[0 1]);
%      pplusf = ppmak(fnbrk(pp,'br'),fnbrk(pp,'c')+fnbrk(ff,'c'),1);
%
%   For example, the ppform of the cubic B-spline  
%      B4 = spmak(-2:2,1);
%   obtained by the command   
%      ppB4 = fn2fm(B4,'pp');
%   will agree with B4 only on its basic interval, [-2 .. 2] in this case,
%   since the ppform outside its basic interval uses continuation of its first,
%   respectively its last piece. To obtain a ppform for B4 that is correct
%   everywhere, first add some a<-2 and some b>2 to the knots of B4, e.g.,
%      ppB4 = fn2fm(fnrfn(B4,[-4 4]),'pp');
%   The same effect can now be had, perhaps more directly, by
%      ppB4 = fn2fm(fnbrk(B4,[-4 4]),'pp');
%   
%   See also PPRFN, SPRFN.

%   Carl de Boor 28oct97
%   cb : 05may98 (standardize the help; accept older version of the forms)
%   cb : 09jan00 (accept also rational splines)
%   cb : 09apr00 (add an example)
%   Copyright 1987-2000 by C. de Boor and The MathWorks, Inc.
%   $Revision: 1.11 $

if ~isstruct(f), f = fn2fm(f); end

switch f.form
case {'B-','BB'},  fnew = sprfn(f,addpts);
case 'pp',         fnew = pprfn(f,addpts);
case 'rB',         fnew = fn2fm(sprfn(fn2fm(f,'B-'),addpts),'rB');
case 'rp',         fnew = fn2fm(pprfn(fn2fm(f,'pp'),addpts),'rp');
otherwise
   error('The function form in F is not (yet) recognized.')
end 
