/**
  * Calculate the instrument sensitivity from the yield sensitivity, the jacobian matrix and the
  * coupon sensitivity.
  *
  * @param curveSensitivities The sensitivity to points of the yield curve.
  * @param curves The curve bundle.
  * @param couponSensitivity The sensitivity
  * @param jacobian The present value coupon sensitivity.
  * @return The instrument quote/rate sensitivity.
  */
 public DoubleMatrix1D calculateFromPresentValue(
     final Map<String, List<DoublesPair>> curveSensitivities,
     final YieldCurveBundle curves,
     final DoubleMatrix1D couponSensitivity,
     final DoubleMatrix2D jacobian) {
   final DoubleArrayList resultList = new DoubleArrayList();
   for (final String curveName : curves.getAllNames()) {
     final DoubleMatrix1D nodeSensitivity =
         new DoubleMatrix1D(
             (_parameterSensitivityCalculator.pointToParameterSensitivity(
                     curveSensitivities.get(curveName), curves.getCurve(curveName)))
                 .toArray(new Double[0]));
     final int n = nodeSensitivity.getNumberOfElements();
     final DoubleMatrix2D inverseJacobian = MATRIX_ALGEBRA.getInverse(jacobian);
     for (int i = 0; i < n; i++) {
       double sum = 0;
       for (int j = 0; j < n; j++) {
         sum +=
             -couponSensitivity.getEntry(i)
                 * inverseJacobian.getEntry(j, i)
                 * nodeSensitivity.getEntry(j);
       }
       resultList.add(sum);
     }
   }
   return new DoubleMatrix1D(resultList.toDoubleArray());
 }
 /**
  * Compute the market quote sensitivity from an instrument and the Jacobian matrix.
  *
  * @param instrument The instrument. Not null.
  * @param fixedCurves The fixed curves names (for which the parameter sensitivity are not computed
  *     even if they are necessary for the instrument pricing). The curve in the list may or may
  *     not be in the bundle. Not null.
  * @param bundle The curve bundle with all the curves with respect to which the sensitivity should
  *     be computed. Not null.
  * @param inverseJacobian The inverse Jacobian matrix (derivative of the curve parameters with
  *     respect to the market quotes).
  * @return The market quote sensitivity.
  */
 public DoubleMatrix1D fromInstrumentInverseJacobian(
     final InstrumentDerivative instrument,
     final Set<String> fixedCurves,
     final YieldCurveBundle bundle,
     final DoubleMatrix2D inverseJacobian) {
   final DoubleMatrix1D parameterSensitivity =
       _parameterSensitivityCalculator.calculateSensitivity(instrument, fixedCurves, bundle);
   return fromParameterSensitivityInverseJacobian(parameterSensitivity, inverseJacobian);
 }
 public DoubleMatrix1D calculateFromSimpleInterpolatedCurve(
     final Map<String, List<DoublesPair>> curveSensitivities,
     final YieldCurveBundle interpolatedCurves) {
   final DoubleArrayList resultList = new DoubleArrayList();
   for (final String curveName : interpolatedCurves.getAllNames()) {
     final DoubleMatrix1D nodeSensitivity =
         new DoubleMatrix1D(
             (_parameterSensitivityCalculator.pointToParameterSensitivity(
                     curveSensitivities.get(curveName), interpolatedCurves.getCurve(curveName)))
                 .toArray(new Double[0]));
     final int n = nodeSensitivity.getNumberOfElements();
     for (int i = 0; i < n; i++) {
       double sum = 0;
       for (int j = 0; j < n; j++) {
         sum += nodeSensitivity.getEntry(j);
       }
       resultList.add(sum);
     }
   }
   return new DoubleMatrix1D(resultList.toDoubleArray());
 }