HestonCharacteristicExponent implements MartingaleCharacteristicExponent { public ComplexNumber[] getCharacteristicExponentAdjointDebug(final ComplexNumber u, final double t) { ComplexNumber[] res = new ComplexNumber[6]; ComplexNumber[] w = forwardSweep(u, t); ComplexNumber[] wBar = backwardsSweep(w, t); res[0] = w[18]; res[1] = subtract(multiply(_theta / _omega / _omega, wBar[0]), wBar[2]); res[2] = multiply(_kappa / _omega / _omega, wBar[0]); res[3] = multiply(w[17], wBar[18]); res[4] = multiply(1 / _omega, add(multiply(-2, w[0], wBar[0]), multiply(w[1], wBar[1]), multiply(2, w[4], wBar[4]), multiply(2, w[5], wBar[5]), multiply(-2, w[17], wBar[17]))); res[5] = multiply(1 / _rho, w[1], wBar[1]); return res; } HestonCharacteristicExponent(final double kappa, final double theta, final double vol0, final double omega, final double rho);  HestonCharacteristicExponent(final HestonModelData data); @Override Function1D<ComplexNumber, ComplexNumber> getFunction(final double t); @Override ComplexNumber getValue(ComplexNumber u, double t); @Override Function1D<ComplexNumber, ComplexNumber[]> getAdjointFunction(final double t); ComplexNumber[] getCharacteristicExponentAdjointDebug(final ComplexNumber u, final double t); @Override ComplexNumber[] getCharacteristicExponentAdjoint(final ComplexNumber u, final double t); @Override double getLargestAlpha(); @Override double getSmallestAlpha(); double getKappa(); double getTheta(); double getVol0(); double getOmega(); double getRho(); HestonCharacteristicExponent withKappa(final double kappa); HestonCharacteristicExponent withTheta(final double theta); HestonCharacteristicExponent withVol0(final double vol0); HestonCharacteristicExponent withOmega(final double omega); HestonCharacteristicExponent withRho(final double rho); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testSensitivities2() { double t = 2.5; ComplexNumber z = new ComplexNumber(2.3, -0.6); ComplexNumber[] fdSense = finiteDifferenceSensitivity(EXPONENT, z, t); ComplexNumber[] sense = EXPONENT.getCharacteristicExponentAdjointDebug(z, t); ComplexNumber[] senseConj = EXPONENT.getCharacteristicExponentAdjointDebug(multiply(-1.0, conjugate(z)), t); for (int i = 0; i < 6; i++) { assertEquals("real: " + i, fdSense[i].getReal(), sense[i].getReal(), 1e-9); assertEquals("im: " + i, fdSense[i].getImaginary(), sense[i].getImaginary(), 1e-9); assertEquals("symmetry property (real)", sense[i].getReal(), senseConj[i].getReal(), 1e-9); assertEquals("symmetry property (img)", sense[i].getImaginary(), -1.0 * senseConj[i].getImaginary(), 1e-9); } }