/// <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 BestLineThruOriginCalculateTest()
 {
     BestLineThruOriginInterpolation target = new BestLineThruOriginInterpolation(standards());
     Assert.AreEqual("0.9130", target.RSquared().ToString("0.0000"));
     //passes thru origin
     Assert.AreEqual(0, target.Calculate(0));
     Assert.AreEqual("2259.3", target.Calculate(1000).ToString("0.0"));
 }
 public void CoefficientsTest()
 {
     BestLineThruOriginInterpolation target = new BestLineThruOriginInterpolation(standards());
     double[] actual;
     actual = target.Coefficients();
     Assert.AreEqual(2, actual.Length);
     Assert.AreEqual(0, actual[0]);
     Assert.AreEqual(7, actual[1]);
 }
 /// <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;
 }