fnrfn
Refine partition of form
Syntax
g = fnrfn(f,addpts)
Description
g = fnrfn(f,addpts)
describes the same
function as does f
, but uses more terms to do it. This is of use
when the sum of two or more functions of different forms is wanted or when the
number of degrees of freedom in the form is to be increased to make fine local
changes possible. The precise action depends on the form in
f
.
If the form in f
is a B-form or BBform, then the entries of
addpts
are inserted into the existing knot sequence, subject
to the following restriction: The multiplicity of no knot exceed the order of the
spline. The equivalent B-form with this refined knot sequence for the function given
by f
is returned.
If the form in f
is a ppform, then the entries of
addpts
are inserted into the existing break sequence, subject
to the following restriction: The break sequence be strictly increasing. The
equivalent ppform with this refined break sequence for the function in
f
is returned.
fnrfn
does not work for functions in stform.
If the function in f
is m-variate, then
addpts
must be a cell array, {addpts1,...,
addptsm}
, and the refinement is carried out in each of the variables.
If the ith entry in this cell array is empty, then the knot or
break sequence in the ith variable is unchanged.
Examples
Construct a spline in B-form, plot it, then apply two midpoint refinements, and also plot the control polygon of the resulting refined spline, expecting it to be quite close to the spline itself:
k = 4; sp = spapi( k, [1,1:10,10], [cos(1),sin(1:10),cos(10)] ); fnplt(sp), hold on sp3 = fnrfn(fnrfn(sp)); plot( aveknt( fnbrk(sp3,'knots'),k), fnbrk(sp3,'coefs'), 'r') hold off
Use fnrfn
to add two B-splines of the same
order:
B1 = spmak([0:4],1); B2 = spmak([2:6],1); B1r = fnrfn(B1,fnbrk(B2,'knots')); B2r = fnrfn(B2,fnbrk(B1,'knots')); B1pB2 = spmak(fnbrk(B1r,'knots'),fnbrk(B1r,'c')+fnbrk(B2r,'c')); fnplt(B1,'r'),hold on, fnplt(B2,'b'), fnplt(B1pB2,'y',2) hold off
Algorithms
The standard knot insertion algorithm is used for the calculation of the B-form coefficients for the refined knot sequence, while Horner's method is used for the calculation of the local polynomial coefficients at the additional breaks in the refined break sequence.