G2ppPiecewiseConstantModel { public double[] volatilityMaturityPart(final G2ppPiecewiseConstantParameters g2parameters, double u, double v) { double[] a = g2parameters.getMeanReversion(); double[] result = new double[2]; double expa0u = Math.exp(-a[0] * u); double expa1u = Math.exp(-a[1] * u); result[0] = (expa0u - Math.exp(-a[0] * v)) / a[0]; result[1] = (expa1u - Math.exp(-a[1] * v)) / a[1]; return result; }  double[] volatilityMaturityPart(final G2ppPiecewiseConstantParameters g2parameters, double u, double v); double[][] volatilityMaturityPart(final G2ppPiecewiseConstantParameters g2parameters, double u, double[] v); double[][][] volatilityMaturityPart(final G2ppPiecewiseConstantParameters g2parameters, double u, double[][] v); double[][] gamma(final G2ppPiecewiseConstantParameters g2parameters, double theta0, double theta1); double swapRate(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed, final double[] discountedCashFlowIbor,
      final double[][] alphaIbor, final double[] tau2Ibor); double swapRate(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed, final double[] discountedCashFlowIbor,
      final double[][] alphaIbor, final double[] tau2Ibor, double[] d1); double swapRate(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed, final double[] discountedCashFlowIbor,
      final double[][] alphaIbor, final double[] tau2Ibor, double[] d1, double[][] d2); double[] swapRateDdcfi1(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed, final double[] discountedCashFlowIbor,
      final double[][] alphaIbor, final double[] tau2Ibor); double[] swapRateDdcff1(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed, final double[] discountedCashFlowIbor,
      final double[][] alphaIbor, final double[] tau2Ibor); Pair<double[][][], double[][][]> swapRateDdcfDx2(final double[] x, final double[] discountedCashFlowFixed, final double[][] alphaFixed, final double[] tau2Fixed,
      final double[] discountedCashFlowIbor, final double[][] alphaIbor, final double[] tau2Ibor); double futuresConvexityFactor(final G2ppPiecewiseConstantParameters g2parameters, final double expiry, final double u, final double v);  }
@Test public void volatilityMaturityPart() { final double u = 0.75; final double[] v = new double[] {2.0, 4.0, 7.0 }; final double[][] h = MODEL_G2PP.volatilityMaturityPart(MODEL_PARAMETERS, u, v); final double[][] hExpected = new double[][] { {1.232938151, 3.173861567, 6.013423491 }, {0.832348609, 1.657740023, 2.253532635 } }; ArrayAsserts.assertArrayEquals("G2++: maturity dependent volatility part", hExpected[0], h[0], 1.0E-7); ArrayAsserts.assertArrayEquals("G2++: maturity dependent volatility part", hExpected[1], h[1], 1.0E-7); final double[] hVector = MODEL_G2PP.volatilityMaturityPart(MODEL_PARAMETERS, u, v[0]); assertEquals("G2++: maturity dependent volatility part", hExpected[0][0], hVector[0], 1.0E-7); assertEquals("G2++: maturity dependent volatility part", hExpected[1][0], hVector[1], 1.0E-7); }
@Test public void volatilityMaturityPartArray() { final double u = 0.75; final double[][] v = new double[][] { {2.0, 4.0, 7.0 }, {5.0, 3.0 } }; final double[][][] h = MODEL_G2PP.volatilityMaturityPart(MODEL_PARAMETERS, u, v); final double[][] h0 = MODEL_G2PP.volatilityMaturityPart(MODEL_PARAMETERS, u, v[0]); final double[][] h1 = MODEL_G2PP.volatilityMaturityPart(MODEL_PARAMETERS, u, v[1]); for (int loop = 0; loop < v[0].length; loop++) { assertEquals("G2++: maturity dependent volatility part", h[0][0][loop], h0[0][loop], 1.0E-7); assertEquals("G2++: maturity dependent volatility part", h[1][0][loop], h0[1][loop], 1.0E-7); } for (int loop = 0; loop < v[1].length; loop++) { assertEquals("G2++: maturity dependent volatility part", h[0][1][loop], h1[0][loop], 1.0E-7); assertEquals("G2++: maturity dependent volatility part", h[1][1][loop], h1[1][loop], 1.0E-7); } }