ArgumentChecker.notNull(swaption, "swaption");
ArgumentChecker.notNull(g2Data, "G2++ data");
final YieldAndDiscountCurve dsc = g2Data.getCurve(swaption.getUnderlyingSwap().getFixedLeg().getDiscountCurve());
final double notional = swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(0).getNotional();
final double strike = swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(0).getFixedRate();
final AnnuityPaymentFixed cfeIbor = swaption.getUnderlyingSwap().getSecondLeg().accept(CFEC, g2Data);
final double theta = swaption.getTimeToExpiry();
final double dft0 = dsc.getDiscountFactor(swaption.getSettlementTime());
final int nbCfFixed = swaption.getUnderlyingSwap().getFixedLeg().getNumberOfPayments();
final int nbCfIbor = cfeIbor.getNumberOfPayments();
final double[] tFixed = new double[nbCfFixed];
final double[] dfFixed = new double[nbCfFixed];
final double[] discountedCashFlowFixed = new double[nbCfFixed];
for (int loopcf = 0; loopcf < nbCfFixed; loopcf++) {
tFixed[loopcf] = swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(loopcf).getPaymentTime();
dfFixed[loopcf] = dsc.getDiscountFactor(tFixed[loopcf]);
discountedCashFlowFixed[loopcf] = dfFixed[loopcf] * swaption.getUnderlyingSwap().getFixedLeg().getNthPayment(loopcf).getPaymentYearFraction();
}
final double[] tIbor = new double[nbCfIbor];
final double[] dfIbor = new double[nbCfIbor];
final double[] discountedCashFlowIbor = new double[nbCfIbor];
for (int loopcf = 0; loopcf < nbCfIbor; loopcf++) {
tIbor[loopcf] = cfeIbor.getNthPayment(loopcf).getPaymentTime();
dfIbor[loopcf] = dsc.getDiscountFactor(tIbor[loopcf]);
discountedCashFlowIbor[loopcf] = dfIbor[loopcf] * cfeIbor.getNthPayment(loopcf).getAmount() / notional;
}
final double rhog2pp = g2Data.getG2ppParameter().getCorrelation();
final double[][] gamma = MODEL_G2PP.gamma(g2Data.getG2ppParameter(), 0, theta);
final double rhobar = rhog2pp * gamma[0][1] / Math.sqrt(gamma[0][0] * gamma[1][1]);