Accord.Tests.Math.QuadraticObjectiveFunctionTest.FunctionTest3 C# (CSharp) Method

FunctionTest3() private method

private FunctionTest3 ( ) : void
return void
        public void FunctionTest3()
        {
            double x = 0;

            Func<double> expected = () => x * x + 1;
            var actual = new QuadraticObjectiveFunction("x² + 1");

            for (int i = 0; i < 10; i++)
            {
                x = (i - 5) / 10.0;

                double a = actual.Function(new[] { x });
                double e = expected();

                Assert.AreEqual(e, a, 1e-10);
                Assert.IsFalse(Double.IsNaN(a));
                Assert.IsFalse(Double.IsNaN(e));
            }
        }