If monotonicity is imposed, the quadratic B-spline basis functions are used. If the constraints include convexity (or concavity), the cubic B-spline basis functions are used.
The following code has arguments type (monotone, convex, etc.), x, y, k=#knots, q=degree of penalty, and penalty parameter.
It returns the constrained and unconstrained fit, GCV values, effective degrees of freedom, and the estimated function values on a fine grid.
Here is an example implementation, fitting a monotone convex curve to a dataset generated from an exponential function.