Spline Toolbox | ![]() ![]() |
Syntax
fn = fncmb(function,operation
) fn = fncmb(function,function) fn = fncmb(function,matrix,function) fn = fncmb(function,matrix,function,matrix) fn = fncmb(function,op
,function)
Description
The intent is to make it easy to carry out the standard linear operations of scaling and adding within a spline space without having to deal explicitly with the relevant parts of the function(s) involved.
returns (a description of) the function obtained by applying to the values of the function in fncmb(function,operation)
function
the operation specified by operation
. The nature of the operation depends on whether operation
is a scalar, a vector, a matrix, or a string, as follows
The remaining options only work for univariate functions. See Limitations for more information.
returns (a description of) the pointwise sum of the two functions. The two functions must be of the same form. This particular case of just two input arguments is not included in the above table since it only works for univariate functions.fncmb(function,function)
is the same as fncmb(function,matrix,function)
fncmb(fncmb(function,matrix),function)
.
is the same as fncmb(function,matrix,function,matrix)
fncmb((fncmb(function,matrix),fncmb(function,matrix))
.
returns the ppform of the spline obtained by the pointwise combining of the two functions, as specified by the string fncmb(function,op,function)
op
. op can be
one of the strings '+'
, '-'
, '*'
. If the second function is to be a constant, it is sufficient simply to supply here that constant.
Examples
fncmb(fn,3.5)
multiplies (the coefficients of) the function in fn
by 3.5.
fncmb(f,3,g,
-4)
returns the linear combination, with weights 3 and -4, of the function in f
and the function in g
.
fncmb(f,3,g)
adds 3 times the function in f
to the function in g
.
If the function in
f
happens to be scalar-valued, then f3=fncmb(f,[1;2;3]
) contains the description of the function whose value at is the 3-vector
. Note that, by the convention throughout this toolbox, the subsequent statement
returns a 1-column-matrix.
If f
describes a surface in , i.e., the function in
f
is 3-vector-valued bivariate, then f2 = fncmb(f,[1 0 0;0 0 1])
describes the projection of that surface to the -plane.
The following commands produce the picture of a ... spirochete?
c = rsmak('circle'); fnplt(fncmb(c,diag([1.5,1]))); axis equal, hold on sc = fncmb(c,.4); fnplt(fncmb(sc,-[.2;-.5])) fnplt(fncmb(sc,-[.2,-.5])) hold off, axis off
If t
is a knot sequence of length n+k
and a
is a matrix with n
columns, then fncmb(spmak(t,eye(n,n)),a)
is the same as spmak(t,a)
.
fncmb(spmak([0:4],1),'+',ppmak([
-1 5],[1
-1]))
is the piecewise-polynomial with breaks -1:5
that, on the interval [0 .. 4], agrees with the function
(but has no active break at 0 or 1, hence differs from this function outside the interval [0 .. 4]).
fncmb(spmak([0:4],1),'
-',0)
has the same effect as fn2fm(spmak([0:4],1),'pp')
.
Algorithm
The coefficients are extracted (via fnbrk
) and operated on by the specified matrix or operation (and, possibly, added), then recombined with the rest of the function description (via ppmak
, spmak,rpmak,rsmak,stmak
). To be sure, when the function is rational, the matrix is only applied to the coefficients of the numerator. Again, if we are to translate the function values by a given vector and the function is in ppform, then only the coefficients corresponding to constant terms are so translated.
If there are two functions input, then they must be of the same type (see Limitations, below) except for the following.
fncmb(f1,op,f2)
returns the ppform of the function
with op
one of '+', '-'
, '*'
, and f1
, f2
of arbitrary polynomial form. If, in addition, f2
is a scalar or vector, it is taken to be the function that is constantly equal to that scalar or vector.
Limitations
fncmb
only works for univariate functions, except for the case fncmb(function,operation)
, i.e., when there is just one function in the input.
Further, if two functions are involved, then they must be of the same type. This means that they must either both be in B-form or both be in ppform, and, moreover, have the same knots or breaks, the same order, and the same target. The only exception to this is the command of the form fncmb(function,op,function)
.
Cautionary Note
The condition mentioned under Limitations, that the second input function, if any, must be of the same type as the first, is not checked for explicitly. But, MATLAB will issue an error message about incompatible sizes if the two coefficient arrays involved do not agree in size.
![]() | fnbrk | fnder | ![]() |