Put together spline in ppform

`ppmak(breaks,coefs) `

ppmak

ppmak(breaks,coefs,d)

ppmak(breaks,coefs,sizec)

The command `ppmak(...)`

puts together a spline in ppform from minimal information, with the rest inferred from that
information. `fnbrk`

provides any or all of the
parts of the completed description. In this way, the actual data structure used for
the storage of the ppform is easily modified without any effect on the various
`fn...`

commands that use this construct. However, the casual
user is not likely to use `ppmak`

explicitly, relying instead on
the various spline construction commands in the toolbox to construct particular
splines.

`ppmak(breaks,coefs) `

returns the ppform of
the spline specified by the break information in `breaks`

and the
coefficient information in `coefs`

. How that information is
interpreted depends on whether the function is univariate or multivariate, as
indicated by `breaks`

being a sequence or a cell array.

If `breaks`

is a sequence, it must be nondecreasing, with its
first entry different from its last. Then the function is assumed to be univariate,
and the various parts of its ppform are determined as follows:

The number

`l`

of polynomial pieces is computed as`length(breaks)`

-`1`

, and the basic interval is, correspondingly, the interval`[breaks(1)`

..`breaks(l+1)]`

.The dimension

`d`

of the function's target is taken to be the number of rows in`coefs`

. In other words, each column of`coefs`

is taken to be one coefficient. More explicitly,`coefs(:,i*k+j)`

is assumed to contain the`j`

th coefficient of the`(i+1)`

st polynomial piece (with the first coefficient the highest and the`k`

th coefficient the lowest, or constant, coefficient). Thus, with`kl`

the number of columns of`coefs`

, the order`k`

of the piecewise-polynomial is computed as`fix(kl/l)`

.

After that, the entries of `coefs`

are reordered, by the
command

coefs = reshape(permute(reshape(coefs,[d,k,l]),[1 3 2]),[d*l,k])

in order to conform with the internal interpretation of the coefficient array in
the ppform for a univariate spline. This only applies when you use the syntax
`ppmak(breaks,coefs)`

where `breaks`

is a
sequence (row vector), not when it is a cell-array. The permutation is not made when
you use the three-argument forms of `ppmak`

. For the three-argument
forms only a reshape is done, not a permute.

If `breaks`

is a cell array, of length `m`

, then
the function is assumed to be `m`

-variate (tensor product), and the
various parts of its ppform are determined from the input as follows:

The

`m`

-vector l has`length(breaks{i})-1`

as its`i`

th entry and, correspondingly, the`m`

-cell array of its basic intervals has the interval`[breaks{i}(1) .. breaks{i}(end)]`

as its`i`

th entry.The dimension

`d`

of the function's target and the`m`

-vector`k`

of (coordinate-wise polynomial) orders of its pieces are obtained directly from the size of`coefs`

, as follows.If

`coefs`

is an`m`

-dimensional array, then the function is taken to be scalar-valued, i.e.,`d`

is 1, and the`m`

-vector`k`

is computed as`size(coefs)./l`

. After that,`coefs`

is reshaped by the command`coefs = reshape(coefs,[1,size(coefs)])`

.If

`coefs`

is an (`r+m`

)-dimensional array, with`sizec = size(c)`

say, then`d`

is set to`sizec(1:r)`

, and the`vector`

`k`

is computed as`sizec(r+(1:m))./l`

. After that,`coefs`

is reshaped by the command`coefs = reshape(coefs,[prod(d),sizec(r+(1:m))])`

.

Then, `coefs`

is interpreted as an equivalent array of size
`[d,l(1),k(1),l(2),k(2),...,l(m),k(m)]`

, with its```
(:,i(1),r(1),i(2),r(2),...,i(m),r(m))
```

th entry the coefficient
of

$$\prod _{\mu =1}^{m}{\left(x(\mu )-\text{breaks|}\mu ](i(\mu ))\right)}^{\left(k(\mu )-r(\mu )\right)}$$

in the local polynomial representation of the function on the (hyper)rectangle with sides

$$[\text{breaks}|\mu ]\left(i(\mu )\right)\text{}\mathrm{..}\text{breaks}|\mu ]\left(i(\mu )+1\right)],\text{}\mu =1:m$$

This is, in fact, the internal interpretation of the coefficient array in the ppform of a multivariate spline.

`ppmak `

prompts you for
`breaks`

and `coefs`

.

`ppmak(breaks,coefs,d) `

with
`d`

a positive integer, also puts together the ppform of a
spline from the information supplied, but expects the function to be univariate. In
that case, `coefs`

is taken to be of size
`[d*l,k]`

, with `l`

obtained as
`length(breaks)-1`

, and this determines the order,
`k`

, of the spline. With this,
`coefs(i*d+j,:)`

is taken to be the `j`

th
components of the coefficient vector for the (`i+1`

)st polynomial
piece.

`ppmak(breaks,coefs,sizec) `

with
`sizec`

a row vector of positive integers, also puts together
the ppform of a spline from the information supplied, but interprets
`coefs`

to be of size `sizec`

(and returns an
error when `prod(size(coefs))`

differs from
`prod(sizec)`

). This option is important only in the rare case
that the input argument `coefs`

is an array with one or more
trailing singleton dimensions. For, MATLAB^{®} suppresses trailing singleton dimensions, hence, without this explicit
specification of the intended size of `coefs`

,
`ppmak`

would interpret `coefs`

incorrectly.

The two splines

p1 = ppmak([1 3 4],[1 2 5 6;3 4 7 8]); p2 = ppmak([1 3 4],[1 2;3 4;5 6;7 8],2);

have exactly the same ppform (2-vector-valued, of order 2). But the second command provides the coefficients in the arrangement used internally.

`ppmak([0:2],[1:6])`

constructs a piecewise-polynomial function
with basic interval [`0`

..`2`

] and consisting of
two pieces of order 3, with the sole interior break 1. The resulting function is
scalar, i.e., the dimension `d`

of its target is 1. The function
happens to be continuous at that break since the first piece is
*x*|→*x*^{2} +
2*x* + 3, while the second piece is
*x*|→4(*x* – 1)^{2} + 5(*x*–1) + 6.

When the function is univariate and the dimension `d`

is not
explicitly specified, then it is taken to be the row number of
`coefs`

. The column number should be an integer multiple of the
number `l`

of pieces specified by `breaks`

. For
example, the statement `ppmak([0:2],[1:3;4:6])`

leads to an error,
since the break sequence `[0:2]`

indicates two polynomial pieces,
hence an even number of columns are expected in the coefficient matrix. The modified
statement `ppmak([0:1],[1:3;4:6])`

specifies the parabolic curve
*x*|→(1,4)*x*^{2} +
(2,5)*x* + (3,6). In particular, the dimension
`d`

of its target is 2. The differently modified statement
`ppmak([0:2],[1:4;5:8])`

also specifies a planar curve (i.e.,
`d`

is `2`

), but this one is piecewise linear;
its first polynomial piece
is *x*|→(1,5)*x* + (2,6).

Explicit specification of the dimension `d`

leads, in the
univariate case, to a different interpretation of the entries of
`coefs`

. Now the column number indicates the polynomial order
of the pieces, and the row number should equal `d`

times the number
of pieces. Thus, the statement `ppmak([0:2],[1:4;5:8],2)`

is in
error, while the statement `ppmak([0:2],[1:4;5:8],1)`

specifies a
scalar piecewise cubic whose first piece is
*x*|→*x*^{3} +
2*x*^{2} + 3*x* +
4.

If you wanted to make up the constant polynomial, with basic interval [0..1] say, whose value is the matrix eye(2), then you would have to use the full optional third argument, i.e., use the command

pp = ppmak(0:1,eye(2),[2,2,1,1]);

Finally, if you want to construct a 2-vector-valued bivariate polynomial on the rectangle [–1 .. 1] x [0 .. 1], linear in the first variable and constant in the second, say

coefs = zeros(2,2,1); coefs(:,:,1) = [1 0; 0 1];

then the straightforward

pp = ppmak({[-1 1],[0 1]},coefs);

will fail, producing a scalar-valued function of order 2 in each variable, as will

pp = ppmak({[-1 1],[0 1]},coefs,size(coefs));

while the following command will succeed:

pp = ppmak({[-1 1],[0 1]},coefs,[2 2 1]);

See the example “Intro to ppform” for other examples.