# mkpp

Piecewise polynomial struct construction.

## Syntax

pp = mkpp(breaks, coefs)

pp = mkpp(breaks, coefs, d)

## Inputs

breaks
The coordinates that define the intervals for each polynomial piece.
The values are assumed to be in strictly increasing order.
Dimension: vector
coefs
The coefficients of each polynomial piece.
In the case of a 2D matrix, the first dimension is the number of polynomial pieces and the second dimension is the number of polynomial coefficients.
In the case of an ND matrix, the matrix is viewed as an array of piecewise polynomials. The leading dimensions of coefs are the dimensions of the pp array. The last two dimension lengths are the number of polynomial pieces, and the number of polynomial coefficients for each piece.
Dimension: matrix
d
The dimensions of the array of piecewise polynomials in coefs.
When coefs is a 2D matrix, d is 1.
Type: integer
Dimension: scalar | vector

## Outputs

pp
The piecewise polynomial struct.
The members are as follows:
breaks
The input intervals vector.
coefs
The input coefficients. In the ND case the matrix is reshaped into 2D upon return.
dim
The dimensions vector.
form
The form, 'pp'.
order
The degree of the polynomial plus 1, which is the number of coefficients. This is the spline order, rather than polynomial order.
pieces
The number of piecewise polynomial segments, which is length(breaks) - 1.

## Example

breaks = [10, 20, 30, 40, 50];
L = length(breaks) - 1;
order = 3;
coefs = zeros(L, order);
coefs(1, :) = [2, 3, 4];
coefs(2, :) = [3, 4, 5];
coefs(3, :) = [4, 5, 6];
coefs(4, :) = [6, 7, 8];
pp = mkpp(breaks,coefs)
R = poly([1,3,5])
pp = struct [
breaks: [Matrix] 1 x 5
10  20  30  40  50
coefs: [Matrix] 4 x 3
2  3  4
3  4  5
4  5  6
6  7  8
dim: 1
form: pp
order: 3
pieces: 4
]