예제 #1
0
        public void SimpsonsLineIntegrationTest()
        {
            List <Sample> readings = new List <Sample>();

            for (int i = 0; i < 1001; ++i)
            {
                readings.Add(new Sample(i, i));
            }
            IIntegratingModule target = new SimpsonsIntegratingModule();

            Assert.AreEqual(target.Integrate(readings, 0, 1000), 500000.0);
        }
예제 #2
0
        public void SimpsonsParabolaIntegrationTest()
        {
            List <Sample> readings = new List <Sample>();

            for (int i = 0; i < 1001; ++i)
            {
                readings.Add(new Sample((-i * (i - 1000)), i));
            }
            IIntegratingModule target = new SimpsonsIntegratingModule();

            double epsilon  = 2;
            double expected = 500000000.0 / 3.0;

            Assert.IsTrue(Math.Abs(target.Integrate(readings, 0, 1000) - expected) < epsilon);
        }