Examples of Interpolator1DDataBundle


Examples of com.opengamma.analytics.math.interpolation.data.Interpolator1DDataBundle

            4.7007909964955576, 4.5560983095534917, 4.5558857802921331, 3.886702136938859, 3.8309544446032437, 2.3465700101454354, 2.3057759170296173, 1.0734291352697389, 1.0436689951231841, } };
    final Interpolator1D interpWrap = Interpolator1DFactory.getInterpolator(Interpolator1DFactory.LOG_NATURAL_CUBIC_MONOTONE);

    final int yDim = yValues.length;
    for (int k = 0; k < yDim; ++k) {
      final Interpolator1DDataBundle bundle = interpWrap.getDataBundle(xValues, yValues[k]);
      for (int i = 0; i < nKeys; ++i) {
        final double res = interpWrap.interpolate(bundle, xKeys[i]);
        assertEquals(res, expected[k][i], expected[k][i] * 1.e-15);
      }

      /*
       * Test sensitivity
       */
      final int nData = 10;
      final double[] yValues1Up = new double[nData];
      final double[] yValues1Dw = new double[nData];
      for (int i = 0; i < nData; ++i) {
        yValues1Up[i] = yValues[k][i];
        yValues1Dw[i] = yValues[k][i];
      }
      for (int j = 0; j < nData; ++j) {
        yValues1Up[j] = yValues[k][j] * (1. + EPS);
        yValues1Dw[j] = yValues[k][j] * (1. - EPS);
        Interpolator1DDataBundle dataBund1Up = interpWrap.getDataBundleFromSortedArrays(xValues, yValues1Up);
        Interpolator1DDataBundle dataBund1Dw = interpWrap.getDataBundleFromSortedArrays(xValues, yValues1Dw);
        for (int i = 0; i < nKeys; ++i) {
          double res1 = 0.5 * (interpWrap.interpolate(dataBund1Up, xKeys[i]) - interpWrap.interpolate(dataBund1Dw, xKeys[i])) / EPS / yValues[k][j];
          assertEquals(res1, interpWrap.getNodeSensitivitiesForValue(bundle, xKeys[i])[j], Math.max(Math.abs(yValues[k][j]) * EPS, EPS));
        }
        yValues1Up[j] = yValues[k][j];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.