public virtual void test_volatility()
 {
     for (int i = 0; i < NB_TEST; i++)
     {
         double expiryTime  = VOLS.relativeTime(TEST_OPTION_EXPIRY[i]);
         double volExpected = SURFACE.zValue(expiryTime, TEST_STRIKE[i]);
         double volComputed = VOLS.volatility(TEST_OPTION_EXPIRY[i], TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD);
         assertEquals(volComputed, volExpected, TOLERANCE_VOL);
     }
 }
        public virtual void test_volatility_sensitivity()
        {
            double eps   = 1.0e-6;
            int    nData = TIME.size();

            for (int i = 0; i < NB_TEST; i++)
            {
                double expiryTime = VOLS.relativeTime(TEST_OPTION_EXPIRY[i]);
                SwaptionSensitivity            point      = SwaptionSensitivity.of(VOLS.Name, expiryTime, TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD, GBP, TEST_SENSITIVITY[i]);
                CurrencyParameterSensitivities sensActual = VOLS.parameterSensitivity(point);
                CurrencyParameterSensitivity   sensi      = sensActual.getSensitivity(SURFACE.Name, GBP);
                DoubleArray computed = sensi.Sensitivity;

                IDictionary <DoublesPair, double> map = new Dictionary <DoublesPair, double>();
                for (int j = 0; j < nData; ++j)
                {
                    DoubleArray volDataUp            = VOL.subArray(0, nData).with(j, VOL.get(j) + eps);
                    DoubleArray volDataDw            = VOL.subArray(0, nData).with(j, VOL.get(j) - eps);
                    InterpolatedNodalSurface paramUp = InterpolatedNodalSurface.of(METADATA, TIME, STRIKE, volDataUp, INTERPOLATOR_2D);
                    InterpolatedNodalSurface paramDw = InterpolatedNodalSurface.of(METADATA, TIME, STRIKE, volDataDw, INTERPOLATOR_2D);
                    NormalSwaptionExpiryStrikeVolatilities provUp = NormalSwaptionExpiryStrikeVolatilities.of(CONVENTION, VAL_DATE_TIME, paramUp);
                    NormalSwaptionExpiryStrikeVolatilities provDw = NormalSwaptionExpiryStrikeVolatilities.of(CONVENTION, VAL_DATE_TIME, paramDw);
                    double volUp = provUp.volatility(TEST_OPTION_EXPIRY[i], TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD);
                    double volDw = provDw.volatility(TEST_OPTION_EXPIRY[i], TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD);
                    double fd    = 0.5 * (volUp - volDw) / eps;
                    map[DoublesPair.of(TIME.get(j), STRIKE.get(j))] = fd;
                }
                IList <ParameterMetadata> list = sensi.ParameterMetadata;
                assertEquals(computed.size(), nData);
                for (int j = 0; j < list.Count; ++j)
                {
                    SwaptionSurfaceExpiryStrikeParameterMetadata metadata = (SwaptionSurfaceExpiryStrikeParameterMetadata)list[i];
                    double expected = map[DoublesPair.of(metadata.YearFraction, metadata.Strike)];
                    assertEquals(computed.get(i), expected, eps);
                }
            }
        }