On Tue, Mar 5, 2013 at 12:41 AM, Jaime Fernández del Río
<jaime.frio@gmail.com> wrote:
I think the place to add this is to lstsq as linear constraints. That is, the coefficients must satisfy B * c = y_c for some set of equations B. In the polynomial case the rows of B would be the powers of x at the points you want to constrain. Then do an svd on B, B = u * d * v. Apply v to the design matrix of the unconstrained points A' = A * v.T so that B' becomes u * d. The coefficients are now replaced by new variables c' with the contraints in the first two columns. If there are, say, 2 constraints, u * d will be 2x2. Solve that equation for the first two constraints then multiply the first two columns of the design matrix A' by the result and put them on the rhs, i.e.,
y = y - A'[:, :2] * c'[:2]
then solve the usual l least squares thing with
A[:, 2:] * c'[2:] = y
to get the rest of the transformed coefficients c'. Put the coefficients altogether and multiply with v^T to get
c = v^T * c'
Chuck