A Generalized Problem of Least Squares