// Implementation note: nbNewParameters - number of new parameters in the curve, parameters not from an underlying curve which is another curve of the bundle.
final int[][] indexOther = new int[nbCurve][];
// Implementation note: indexOther - the index of the underlying curves, if any.
loopname = 0;
for (final String name : curveNamesSet) { // loop over all curves (by name)
final YieldAndDiscountCurve curve = bundle.getCurve(name);
final List<String> underlyingCurveNames = curve.getUnderlyingCurvesNames();
nbNewParameters[loopname] = curve.getNumberOfParameters();
final IntArrayList indexOtherList = new IntArrayList();
for (final String u : underlyingCurveNames) {
final Integer i = curveNum.get(u);
if (i != null) {
indexOtherList.add(i);
nbNewParameters[loopname] -= nbNewParameters[i];
}
}
indexOther[loopname] = indexOtherList.toIntArray();
loopname++;
}
int nbSensiCurve = 0;
for (final String name : bundle.getAllNames()) { // loop over all curves (by name)
if (!fixedCurves.contains(name)) {
nbSensiCurve++;
}
}
final int[] nbNewParamSensiCurve = new int[nbSensiCurve];
// Implementation note: nbNewParamSensiCurve
final int[][] indexOtherSensiCurve = new int[nbSensiCurve][];
// Implementation note: indexOtherSensiCurve -
final int[] startCleanParameter = new int[nbSensiCurve];
// Implementation note: startCleanParameter - for each curve for which the sensitivity should be computed, the index in the total sensitivity vector at which that curve start.
final int[][] startDirtyParameter = new int[nbSensiCurve][];
// Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
int nbSensitivityCurve = 0;
int nbCleanParameters = 0;
int currentDirtyStart = 0;
for (final String name : curveNamesSet) { // loop over all curves (by name)
if (!fixedCurves.contains(name)) {
final int num = curveNum.get(name);
final YieldAndDiscountCurve curve = bundle.getCurve(name);
final IntArrayList startDirtyParameterList = new IntArrayList();
final List<String> underlyingCurveNames = curve.getUnderlyingCurvesNames();
for (final String u : underlyingCurveNames) {
final Integer i = curveNum.get(u);
if (i != null) {
startDirtyParameterList.add(currentDirtyStart);
currentDirtyStart += nbNewParameters[i];
}
}
startDirtyParameterList.add(currentDirtyStart);
currentDirtyStart += nbNewParameters[nbSensitivityCurve];
startDirtyParameter[nbSensitivityCurve] = startDirtyParameterList.toIntArray();
nbNewParamSensiCurve[nbSensitivityCurve] = nbNewParameters[num];
indexOtherSensiCurve[nbSensitivityCurve] = indexOther[num];
startCleanParameter[nbSensitivityCurve] = nbCleanParameters;
nbCleanParameters += nbNewParamSensiCurve[nbSensitivityCurve];
nbSensitivityCurve++;
}
}
final DoubleArrayList sensiDirtyList = new DoubleArrayList();
for (final String name : curveNamesSet) { // loop over all curves (by name)
if (!fixedCurves.contains(name)) {
final YieldAndDiscountCurve curve = bundle.getCurve(name);
final List<Double> oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivities().get(name), curve);
sensiDirtyList.addAll(oneCurveSensitivity);
}
}
final double[] sensiDirty = sensiDirtyList.toDoubleArray();