least squares fitting in c#