@Override
 public DecisionSchedule visitSwaptionCashFixedIbor(
     final SwaptionCashFixedIbor swaption, final MulticurveProviderInterface multicurves) {
   final double[] decisionTime = new double[] {swaption.getTimeToExpiry()};
   final AnnuityPaymentFixed cfeIbor =
       swaption.getUnderlyingSwap().getSecondLeg().accept(CFEC, multicurves);
   final int nbCfeIbor = cfeIbor.getNumberOfPayments();
   final int nbCpnFixed = swaption.getUnderlyingSwap().getFixedLeg().getNumberOfPayments();
   final double[][] impactTime = new double[1][nbCpnFixed + nbCfeIbor];
   final double[][] impactAmount = new double[1][nbCpnFixed + nbCfeIbor];
   // Fixed leg
   for (int loopcf = 0; loopcf < nbCpnFixed; loopcf++) {
     impactTime[0][loopcf] =
         swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(loopcf).getPaymentTime();
     impactAmount[0][loopcf] =
         swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(loopcf).getPaymentYearFraction()
             * swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(loopcf).getNotional();
   }
   // Ibor leg
   for (int loopcf = 0; loopcf < nbCfeIbor; loopcf++) {
     impactTime[0][nbCpnFixed + loopcf] = cfeIbor.getNthPayment(loopcf).getPaymentTime();
     impactAmount[0][nbCpnFixed + loopcf] = cfeIbor.getNthPayment(loopcf).getAmount();
   }
   final DecisionSchedule decision = new DecisionSchedule(decisionTime, impactTime, impactAmount);
   return decision;
 }
 @Test
 /** Tests the curve sensitivity. */
 public void presentValueCurveSensitivity() {
   InterestRateCurveSensitivity pvsSwaption =
       METHOD_HW_APPROXIMATION.presentValueCurveSensitivity(SWAPTION_PAYER_LONG, BUNDLE_HW);
   pvsSwaption = pvsSwaption.cleaned();
   final double deltaTolerancePrice = 1.0E+4;
   // Testing note: Sensitivity is for a movement of 1. 1E+2 = 1 cent for a 1 bp move. Tolerance
   // increased to cope with numerical imprecision of finite difference.
   final double deltaShift = 1.0E-6;
   // 1. Forward curve sensitivity
   final String bumpedCurveName = "Bumped Curve";
   final SwaptionCashFixedIbor swptBumpedForward =
       SWAPTION_PAYER_LONG_DEFINITION.toDerivative(
           REFERENCE_DATE, new String[] {CURVES_NAME[0], bumpedCurveName});
   DoubleAVLTreeSet forwardTime = new DoubleAVLTreeSet();
   for (int loopcpn = 0;
       loopcpn < SWAPTION_PAYER_LONG.getUnderlyingSwap().getSecondLeg().getNumberOfPayments();
       loopcpn++) {
     CouponIbor cpn =
         (CouponIbor)
             SWAPTION_PAYER_LONG.getUnderlyingSwap().getSecondLeg().getNthPayment(loopcpn);
     forwardTime.add(cpn.getFixingPeriodStartTime());
     forwardTime.add(cpn.getFixingPeriodEndTime());
   }
   double[] nodeTimesForward = forwardTime.toDoubleArray();
   final double[] sensiForwardMethod =
       SensitivityFiniteDifference.curveSensitivity(
           swptBumpedForward,
           BUNDLE_HW,
           CURVES_NAME[1],
           bumpedCurveName,
           nodeTimesForward,
           deltaShift,
           METHOD_HW_APPROXIMATION);
   final List<DoublesPair> sensiPvForward = pvsSwaption.getSensitivities().get(CURVES_NAME[1]);
   for (int loopnode = 0; loopnode < sensiForwardMethod.length; loopnode++) {
     final DoublesPair pairPv = sensiPvForward.get(loopnode);
     assertEquals(
         "Sensitivity swaption pv to forward curve: Node " + loopnode,
         nodeTimesForward[loopnode],
         pairPv.getFirst(),
         1E-8);
     assertEquals(
         "Sensitivity finite difference method: node sensitivity " + loopnode,
         sensiForwardMethod[loopnode],
         pairPv.second,
         deltaTolerancePrice);
   }
   // 2. Discounting curve sensitivity
   final SwaptionCashFixedIbor swptBumpedDisc =
       SWAPTION_PAYER_LONG_DEFINITION.toDerivative(
           REFERENCE_DATE, new String[] {bumpedCurveName, CURVES_NAME[1]});
   DoubleAVLTreeSet discTime = new DoubleAVLTreeSet();
   discTime.add(SWAPTION_PAYER_LONG.getSettlementTime());
   for (int loopcpn = 0;
       loopcpn < SWAPTION_PAYER_LONG.getUnderlyingSwap().getSecondLeg().getNumberOfPayments();
       loopcpn++) {
     CouponIbor cpn =
         (CouponIbor)
             SWAPTION_PAYER_LONG.getUnderlyingSwap().getSecondLeg().getNthPayment(loopcpn);
     discTime.add(cpn.getPaymentTime());
   }
   double[] nodeTimesDisc = discTime.toDoubleArray();
   final double[] sensiDiscMethod =
       SensitivityFiniteDifference.curveSensitivity(
           swptBumpedDisc,
           BUNDLE_HW,
           CURVES_NAME[0],
           bumpedCurveName,
           nodeTimesDisc,
           deltaShift,
           METHOD_HW_APPROXIMATION);
   assertEquals(
       "Sensitivity finite difference method: number of node", 11, sensiDiscMethod.length);
   final List<DoublesPair> sensiPvDisc = pvsSwaption.getSensitivities().get(CURVES_NAME[0]);
   for (int loopnode = 0; loopnode < sensiDiscMethod.length; loopnode++) {
     final DoublesPair pairPv = sensiPvDisc.get(loopnode);
     assertEquals(
         "Sensitivity swaption pv to forward curve: Node " + loopnode,
         nodeTimesDisc[loopnode],
         pairPv.getFirst(),
         1E-8);
     assertEquals(
         "Sensitivity finite difference method: node sensitivity",
         sensiDiscMethod[loopnode],
         pairPv.second,
         deltaTolerancePrice);
   }
 }