// 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++;
}
loopname = 0;
for (final String name : bundle.getAllNames()) { // loop over all curves (by name)
if (!fixedCurves.contains(name)) {
loopname++;
}
}
final int nbSensitivityCurve = loopname;
final int[] nbNewParamSensiCurve = new int[nbSensitivityCurve];
// Implementation note: nbNewParamSensiCurve
final int[][] indexOtherSensiCurve = new int[nbSensitivityCurve][];
// Implementation note: indexOtherSensiCurve -
// int[] startCleanParameter = new int[nbSensitivityCurve];
// 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[nbSensitivityCurve][];
// Implementation note: startDirtyParameter - for each curve for which the sensitivity should be computed, the indexes of the underlying curves.
//int nbCleanParameters = 0;
int currentDirtyStart = 0;
loopname = 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[loopname];
startDirtyParameter[loopname] = startDirtyParameterList.toIntArray();
nbNewParamSensiCurve[loopname] = nbNewParameters[num];
indexOtherSensiCurve[loopname] = indexOther[num];
// startCleanParameter[loopname] = nbCleanParameters;
//nbCleanParameters += nbNewParamSensiCurve[loopname];
loopname++;
}
}
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 Double[] oneCurveSensitivity = pointToParameterSensitivity(sensitivity.getSensitivities().get(name), curve);
sensiDirtyList.addAll(Arrays.asList(oneCurveSensitivity));
}
}
final double[] sensiDirty = sensiDirtyList.toDoubleArray();