コード例 #1
0
        /// <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);
        }
コード例 #2
0
 public void BestLineCalculateTest()
 {
     BestLineInterpolation target = new BestLineInterpolation(standards());
     Assert.AreEqual("0.9406", target.RSquared().ToString("0.0000"));
     //passes thru origin
     Assert.AreEqual("-1.700", target.Calculate(0).ToString("0.000"));
     Assert.AreEqual("2698.3", target.Calculate(1000).ToString("0.0"));
 }
コード例 #3
0
 public void CoefficientsTest()
 {
     BestLineInterpolation target = new BestLineInterpolation(standards());
     double[] actual;
     actual = target.Coefficients();
     Assert.AreEqual(2, actual.Length);
     Assert.AreEqual(-2.5, actual[0]);
     Assert.AreEqual(5, actual[1]);
 }
コード例 #4
0
 /// <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;
 }