Package com.opengamma.analytics.math.function

Examples of com.opengamma.analytics.math.function.PiecewisePolynomialFunction1D


   * @param x0Keys
   * @param x1Keys
   * @return Values of second derivative with respect to x1 at (x0Key_i, x1Keys_j)
   */
  public DoubleMatrix2D differentiateX1Twice(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double[] x0Keys, final double[] x1Keys) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[][] interpX1Diff = OG_ALGEBRA.getTranspose(func.differentiateTwice(_method[1].interpolate(x1Values, yValues), x1Keys)).getData();
    return OG_ALGEBRA.getTranspose(_method[0].interpolate(x0Values, interpX1Diff, x0Keys));
  }
View Full Code Here


   * @param x0Key
   * @param x1Key
   * @return Value of first derivative with respect to x0 at (x0Key, x1Key)
   */
  public double differentiateX0(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double x0Key, final double x1Key) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[] interpX0Diff = func.differentiate(_method[0].interpolate(x0Values, OG_ALGEBRA.getTranspose(new DoubleMatrix2D(yValues)).getData()), x0Key).getData();
    return _method[1].interpolate(x1Values, interpX0Diff, x1Key);
  }
View Full Code Here

   * @param x0Keys
   * @param x1Keys
   * @return Values of first derivative with respect to x0 at (x0Key_i, x1Keys_j)
   */
  public DoubleMatrix2D differentiateX0(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double[] x0Keys, final double[] x1Keys) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[][] interpX0Diff = OG_ALGEBRA.getTranspose(func.differentiate(_method[0].interpolate(x0Values, OG_ALGEBRA.getTranspose(new DoubleMatrix2D(yValues)).getData()), x0Keys)).getData();
    return _method[1].interpolate(x1Values, interpX0Diff, x1Keys);
  }
View Full Code Here

   * @param x0Key
   * @param x1Key
   * @return Value of second derivative with respect to x0 at (x0Key, x1Key)
   */
  public double differentiateX0Twice(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double x0Key, final double x1Key) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[] interpX0Diff = func.differentiateTwice(_method[0].interpolate(x0Values, OG_ALGEBRA.getTranspose(new DoubleMatrix2D(yValues)).getData()), x0Key).getData();
    return _method[1].interpolate(x1Values, interpX0Diff, x1Key);
  }
View Full Code Here

   * @param x0Keys
   * @param x1Keys
   * @return Values of second derivative with respect to x0 at (x0Key_i, x1Keys_j)
   */
  public DoubleMatrix2D differentiateX0Twice(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double[] x0Keys, final double[] x1Keys) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[][] interpX0Diff = OG_ALGEBRA.getTranspose(func.differentiateTwice(_method[0].interpolate(x0Values, OG_ALGEBRA.getTranspose(new DoubleMatrix2D(yValues)).getData()), x0Keys))
        .getData();
    return _method[1].interpolate(x1Values, interpX0Diff, x1Keys);
  }
View Full Code Here

   * @param x0Key
   * @param x1Key
   * @return Value of first derivative with respect to x1 at (x0Key, x1Key)
   */
  public double differentiateX1(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double x0Key, final double x1Key) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[] interpX1Diff = func.differentiate(_method[1].interpolate(x1Values, yValues), x1Key).getData();
    return _method[0].interpolate(x0Values, interpX1Diff, x0Key);
  }
View Full Code Here

   * @param x0Keys
   * @param x1Keys
   * @return Values of first derivative with respect to x1 at (x0Key_i, x1Keys_j)
   */
  public DoubleMatrix2D differentiateX1(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double[] x0Keys, final double[] x1Keys) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[][] interpX1Diff = OG_ALGEBRA.getTranspose(func.differentiate(_method[1].interpolate(x1Values, yValues), x1Keys)).getData();
    return OG_ALGEBRA.getTranspose(_method[0].interpolate(x0Values, interpX1Diff, x0Keys));
  }
View Full Code Here

   * @param x0Key
   * @param x1Key
   * @return Value of second derivative with respect to x1 at (x0Key, x1Key)
   */
  public double differentiateX1Twice(final double[] x0Values, final double[] x1Values, final double[][] yValues, final double x0Key, final double x1Key) {
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    final double[] interpX1Diff = func.differentiateTwice(_method[1].interpolate(x1Values, yValues), x1Key).getData();
    return _method[0].interpolate(x0Values, interpX1Diff, x0Key);
  }
View Full Code Here

    final int nData0 = x0Values.length;
    final int nData1 = x1Values.length;

    DoubleMatrix2D yValuesMatrix = new DoubleMatrix2D(yValues);
    final PiecewisePolynomialFunction1D func = new PiecewisePolynomialFunction1D();
    double[][] diff0 = new double[nData1][nData0];
    double[][] diff1 = new double[nData0][nData1];
    double[][] cross = new double[nData0][nData1];

    final PiecewisePolynomialResult result0 = _method[0].interpolate(x0Values, OG_ALGEBRA.getTranspose(yValuesMatrix).getData());
    diff0 = func.differentiate(result0, x0Values).getData();

    final PiecewisePolynomialResult result1 = _method[1].interpolate(x1Values, yValuesMatrix.getData());
    diff1 = func.differentiate(result1, x1Values).getData();

    final int order = 4;

    for (int i = 0; i < nData0; ++i) {
      for (int j = 0; j < nData1; ++j) {
View Full Code Here

    final double[] yValues = new double[] {0., 0.1, 0.05 };

    PiecewisePolynomialInterpolator interp = new LinearInterpolator();
    PiecewisePolynomialResult result = interp.interpolate(xValues, yValues);

    PiecewisePolynomialFunction1D function = new PiecewisePolynomialFunction1D();

    PiecewisePolynomialInterpolator interpPos = new NonnegativityPreservingCubicSplineInterpolator(interp);
    PiecewisePolynomialResult resultPos = interpPos.interpolate(xValues, yValues);

    final int nKeys = 101;
    for (int i = 0; i < nKeys; ++i) {
      final double key = 1. + 4. / (nKeys - 1) * i;
      System.out.println(key + "\t" + function.evaluate(result, key).getData()[0] + "\t" + function.evaluate(resultPos, key).getData()[0]);
    }
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.function.PiecewisePolynomialFunction1D

Copyright © 2018 www.massapicom. 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.