Пример #1
0
        private List <Point> GeneratePoints(float[] coefficients, float a, float b)
        {
            var points = new List <Point>();

            for (float i = a; i <= b; i += 0.001f)
            {
                float x = ChebyshevApproximation.Squish(i, a, b);
                float y = ChebyshevApproximation.Evaluate(coefficients, x);
                points.Add(new Point(i, y));
            }

            return(points);
        }
Пример #2
0
        public void Approximate()
        {
            float a       = -2.0f;
            float b       = 2.0f;
            float step    = 0.5f;
            int   rank    = ChebyshevApproximation.CalculateRank(a, b, step);
            var   polynom = ChebyshevApproximation.Approximate(a, b, rank, myFunc);

            List <float> results = new List <float>();
            var          xApprox = GenerateX(a, b, 0.0001f);

            for (float i = a; i <= b; i += 0.0001f)
            {
                float x = ChebyshevApproximation.Squish(i, a, b);
                results.Add(ChebyshevApproximation.Evaluate(polynom, x));
            }
            Assert.That(polynom.Length == rank + 1);
        }