public virtual void comparisonDupireVolTest()
        {
            double tol = 1.0e-2;
            ImpliedTrinomialTreeLocalVolatilityCalculator calc = new ImpliedTrinomialTreeLocalVolatilityCalculator(28, 1.45d, INTERP_LINEAR);

            System.Func <double, double> interestRate = (double?x) =>
            {
                return(0.03d);
            };
            System.Func <double, double> dividendRate = (double?x) =>
            {
                return(0.01d);
            };
            InterpolatedNodalSurface resTri = calc.localVolatilityFromImpliedVolatility(VOL_SURFACE, SPOT, interestRate, dividendRate);
            DeformedSurface          resDup = (new DupireLocalVolatilityCalculator()).localVolatilityFromImpliedVolatility(VOL_SURFACE, SPOT, interestRate, dividendRate);

            double[][] sampleStrikes = new double[][]
            {
                new double[] { 0.7 * SPOT, SPOT, 1.1 * SPOT, 1.4 * SPOT },
                new double[] { 0.5 * SPOT, 0.9 * SPOT, SPOT, 1.3 * SPOT, 1.9 * SPOT }
            };
            double[] sampleTimes = new double[] { 0.8, 1.1 };
            for (int i = 0; i < sampleTimes.Length; ++i)
            {
                double time = sampleTimes[i];
                foreach (double strike in sampleStrikes[i])
                {
                    double volTri = resTri.zValue(time, strike);
                    double volDup = resDup.zValue(time, strike);
                    assertEquals(volTri, volDup, tol);
                }
            }
        }
        public virtual void flatVolTest()
        {
            double          tol               = 2.0e-2;
            double          constantVol       = 0.15;
            ConstantSurface impliedVolSurface = ConstantSurface.of("impliedVol", constantVol);

            System.Func <double, double> zeroRate = (double?x) =>
            {
                return(0.05d);
            };
            System.Func <double, double> zeroRate1 = (double?x) =>
            {
                return(0.02d);
            };
            ImpliedTrinomialTreeLocalVolatilityCalculator calc = new ImpliedTrinomialTreeLocalVolatilityCalculator(45, 1d, INTERP_TIMESQ_LINEAR);
            InterpolatedNodalSurface localVolSurface           = calc.localVolatilityFromImpliedVolatility(impliedVolSurface, 100d, zeroRate, zeroRate1);

            assertEquals(localVolSurface.ZValues.Where(d => !DoubleMath.fuzzyEquals(d, constantVol, tol)).Count(), 0);
        }