Arithmetic with function(s)
fn = fncmb(function,operation)
f = fncmb(function,function)
f = fncmb(function,op,function)
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.
fn = fncmb(function,operation) returns (a
description of) the function obtained by applying to the values of the function in
function the operation specified by
operation. The nature of the operation depends on whether
operation is a scalar, a
vector, a matrix, or a
character vector or string scalar, as follows.
Multiply the function by that scalar.
Add that vector to the function's values; this requires the function to be vector-valued.
Apply that matrix to the function's coefficients.
Character vector or string scalar
Apply the function specified by that character vector or string scalar to the function's coefficients.
The remaining options only work for univariate functions. See Limitations for more information.
f = fncmb(function,function) 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,matrix,function) is the
the same as
f = fncmb(function,op,function) returns
the ppform of the spline obtained by the pointwise combining of the two functions,
as specified by the character vector or string scalar
op can be one of
'*'. If the second function is to
be a constant, it is sufficient simply to supply here that constant.
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
fncmb(f,3,g) adds 3 times the function in
to the function in
If the function f in
f happens to be
f3=fncmb(f,[1;2;3])contains the description
of the function whose value at x is the 3-vector
3f(x)). Note that, by the convention
throughout this toolbox, the subsequent statement fnval(f3,
x) returns a 1-column-matrix.
f describes a surface in R3,
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 (x, z)-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
t is a knot sequence of length
a is a matrix with
n columns, then
fncmb(spmak(t,eye(n)),a) is the same as
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 x|→
B(x|0,1,2,3,4) + x (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
sp describes the B-form of a spline of order
k, the output of
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
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
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
If there are two functions input, then they must be of the same type (see Limitations, below) except for the following.
op one of
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.