/// <summary>
        /// Factory method to create the required implementation of the interpolation algorithm
        /// </summary>
        /// <param name="fit">interpolation algorithm type</param>
        /// <param name="standards">Data points to be fitted</param>
        /// <returns>Interpolation algorithm</returns>
        public static Interpolator Create(CurveFits fit, IEnumerable <DPoint> standards)
        {
            Interpolator interp = null;
            //ensure points are sorted in order of x values
            List <DPoint> standardsList = new List <DPoint>(standards);

            standardsList.Sort((a, b) => a.X.CompareTo(b.X));
            switch (fit)
            {
            case CurveFits.Interpolate:
                interp = new SimpleInterpolator(standardsList);
                break;

            case CurveFits.LinearZero:
                interp = new BestLineThruOriginInterpolation(standardsList);
                break;

            case CurveFits.Linear:
                interp = new BestLineInterpolation(standardsList);
                break;

            case CurveFits.Quadratic:
                interp = new QuadraticInterpolator(standardsList);
                break;

            case CurveFits.QuadraticThruZero:
                interp = new QuadraticThruZeroInterpolator(standardsList);
                break;

            default:
                break;
            }
            return(interp);
        }
 public void CoefficientsTest()
 {
     QuadraticThruZeroInterpolator target = new QuadraticThruZeroInterpolator(standards());
     double[] actual;
     actual = target.Coefficients();
     Assert.AreEqual(3, actual.Length);
     Assert.AreEqual(0, actual[0]);
     Assert.AreEqual(-3, actual[1]);
     Assert.AreEqual(2, actual[2]);
 }
 /// <summary>
 /// Factory method to create the required implementation of the interpolation algorithm
 /// </summary>
 /// <param name="fit">interpolation algorithm type</param>
 /// <param name="standards">Data points to be fitted</param>
 /// <returns>Interpolation algorithm</returns>
 public static Interpolator Create(CurveFits fit, IEnumerable<DPoint> standards)
 {
     Interpolator interp = null;
     //ensure points are sorted in order of x values
     List<DPoint> standardsList = new List<DPoint>(standards);
     standardsList.Sort((a, b) => a.X.CompareTo(b.X));
     switch (fit)
     {
         case CurveFits.Interpolate:
             interp = new SimpleInterpolator(standardsList);
             break;
         case CurveFits.LinearZero:
             interp = new BestLineThruOriginInterpolation(standardsList);
             break;
         case CurveFits.Linear:
             interp = new BestLineInterpolation(standardsList);
             break;
         case CurveFits.Quadratic:
             interp = new QuadraticInterpolator(standardsList);
             break;
         case CurveFits.QuadraticThruZero:
             interp = new QuadraticThruZeroInterpolator(standardsList);
             break;
         default:
             break;
     }
     return interp;
 }