@Override public CurveUnitParameterSensitivity yValueParameterSensitivity(double x) { DoubleArray array = DoubleArray.copyOf( underlyingInterpolator.getNodeSensitivitiesForValue(underlyingDataBundle, x)); return CurveUnitParameterSensitivity.of(metadata, array); }
// ------------------------------------------------------------------------- // restricted constructor @ImmutableConstructor private InterpolatedNodalCurve( CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, CurveExtrapolator extrapolatorLeft, CurveInterpolator interpolator, CurveExtrapolator extrapolatorRight) { JodaBeanUtils.notNull(metadata, "metadata"); JodaBeanUtils.notNull(xValues, "times"); JodaBeanUtils.notNull(yValues, "values"); JodaBeanUtils.notNull(extrapolatorLeft, "extrapolatorLeft"); JodaBeanUtils.notNull(interpolator, "interpolator"); JodaBeanUtils.notNull(extrapolatorRight, "extrapolatorRight"); if (xValues.size() < 2) { throw new IllegalArgumentException("Length of x-values must be at least 2"); } if (xValues.size() != yValues.size()) { throw new IllegalArgumentException("Length of x-values and y-values must match"); } metadata .getParameterMetadata() .ifPresent( params -> { if (xValues.size() != params.size()) { throw new IllegalArgumentException( "Length of x-values and parameter metadata must match when metadata present"); } }); if (!xValues.sorted().equals(xValues)) { throw new IllegalArgumentException("Array of x-values must be sorted"); } this.metadata = metadata; this.xValues = xValues; this.yValues = yValues; this.extrapolatorLeft = extrapolatorLeft; this.interpolator = interpolator; this.extrapolatorRight = extrapolatorRight; underlyingInterpolator = CombinedInterpolatorExtrapolator.of(interpolator, extrapolatorLeft, extrapolatorRight); underlyingDataBundle = underlyingInterpolator.getDataBundleFromSortedArrays(xValues.toArray(), yValues.toArray()); }
@Override public double firstDerivative(double x) { return underlyingInterpolator.firstDerivative(underlyingDataBundle, x); }
// ------------------------------------------------------------------------- @Override public double yValue(double x) { return underlyingInterpolator.interpolate(underlyingDataBundle, x); }