public void CheckNaturalSplineMinMaxValuesPerformance()
        {
            //first generate the test data and spline
            double      amplitude = 100;
            double      ofset     = 0;
            double      period    = 10;
            double      decay     = 0.1;
            double      minX      = -50;
            double      maxX      = 50;
            int         points    = 100000;
            var         data      = GenerateSplineData(amplitude, period, decay, minX, maxX, ofset, points);
            CubicSpline it        = CubicSpline.InterpolateBoundaries(data.Item1, data.Item2, SplineBoundaryCondition.Natural, 0, SplineBoundaryCondition.Natural, 0);
            //start the time and calculate the min max values
            var t      = DateTime.Now;
            var minMax = it.Extrema();

            Assert.IsTrue(minMax.Item2.AlmostEqual(ofset, 0.3), "Expexted max value near ofset.");
            Assert.IsTrue(minMax.Item1.AlmostEqual(ofset + period / 2, 0.3) || minMax.Item1.AlmostEqual(ofset - period / 2, 0.3), "Expexted min value near ofset +- period/2.");
            //spit out the time it took to calculate
            Console.WriteLine("Extrema took: " + (DateTime.Now - t).TotalMilliseconds.ToString("000.00") + " ms for " + points.ToString() + " points.");
            //determine if the values are correct
            var sp = it.StationaryPoints();

            foreach (var x in sp)
            {
                //check that the stationary point falls roughly at a half period
                Assert.IsTrue(Math.Abs((Math.Abs((x - ofset) * 2 / period) - Math.Round(Math.Abs(x - ofset) * 2 / period, 0))).AlmostEqual(0, 0.3), "Stationary point found outside of period/2 for x=" + x.ToString());
            }
        }
        public void NaturalSplineGetMinMaxTvalues()
        {
            CubicSpline it     = CubicSpline.InterpolateBoundaries(_x, _z, SplineBoundaryCondition.SecondDerivative, -4.0, SplineBoundaryCondition.SecondDerivative, 4.0);
            var         minMax = it.Extrema();

            Assert.AreEqual(-4, minMax.Item1, "Spline returns wrong t value for global minimum");
            Assert.AreEqual(4, minMax.Item2, "Spline returns wrong t value for global maximum");
            Console.WriteLine("GetMinMaxTValues checked out ok for cubic spline.");
        }