Beispiel #1
0
        public void TrapezoidalLineIntegrationTest()
        {
            List <Sample> readings = new List <Sample>();

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

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

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

            double epsilon  = 200;
            double expected = 500000000.0 / 3.0;
            double result   = target.Integrate(readings, 0, 1000);

            Assert.IsTrue(Math.Abs(result - expected) < epsilon);
        }