Topic/plat 6703

The k^th order difference matrix will act on a vector to produce the k^th order difference series.  Related to this is the k^th order finite difference differentiation matrix which acts on the values of a function evaluated at a (non-uniformly spaced) set of points, to give the estimate of the k^th order derivative at those points (for unit spaces points these are identical). 
One use of these matrices, is to  provide matrices that penalise the gradient or curvature of data on a non-uniform grid. This should work for an arbitrary number of dimensions (for data that has been flattened to a vector). 
Is P the k^th-order penalty matrix returned by this function? If so, it could be a bit more explicit. If not, what is P?