Package com.opengamma.analytics.math.matrix

Examples of com.opengamma.analytics.math.matrix.DoubleMatrix2D


          for (i = 0; i < m; i++) {
            res[i][j] = (up.getEntry(i) + down.getEntry(i) - 2 * y.getEntry(i)) / _epsSqr;
          }
          xData[j] = oldValue;
        }
        return new DoubleMatrix2D(res);
      }
    };
  }
View Full Code Here


        final DoubleMatrix2D[] res = new DoubleMatrix2D[n];
        final double[] xData = x.getData();
        for (int i = 0; i < n; i++) {
          final double oldValue = xData[i];
          xData[i] += _eps;
          final DoubleMatrix2D up = function.evaluate(x);
          xData[i] -= _twoEps;
          final DoubleMatrix2D down = function.evaluate(x);
          res[i] = (DoubleMatrix2D) MA.scale(MA.subtract(up, down), _oneOverTwpEps); //TODO have this in one operation
          xData[i] = oldValue;
        }
        return res;
      }
View Full Code Here

            y[2] = function.evaluate(x);
            xData[i] = oldValue - _eps;
            y[1] = function.evaluate(x);
            w = wBack;
          } else {
            final DoubleMatrix2D temp = function.evaluate(x);
            xData[i] = oldValue - _eps;
            if (!domain.evaluate(x)) {
              y[1] = temp;
              xData[i] = oldValue;
              y[0] = function.evaluate(x);
View Full Code Here

          res[i][0] = temp[i][0];
          res[i][1] = temp[i][2];
          res[i][2] = temp[i][3];
        }

        return new DoubleMatrix2D(res);
      }
    };
  }
View Full Code Here

      if (_freeParameters[i]) {
        jac[j][i] = _transforms[i].transformGradient(functionParameters.getEntry(i));
        j++;
      }
    }
    return new DoubleMatrix2D(jac);
  }
View Full Code Here

          res[i][0] = temp[i][0];
          res[i][1] = temp[i][1];
          res[i][2] = temp[i][3];
        }

        return new DoubleMatrix2D(res);
      }
    };
  }
View Full Code Here

        for (int i = 0; i < m; i++) {
          res[3 + i] = temp[i];
        }
        //now transpose
        //TODO a transpose that works on double[][]?
        return MA.getTranspose(new DoubleMatrix2D(res)).getData();
      }
    };
  }
View Full Code Here

    double[] xValuesSrt = Arrays.copyOf(xValues, nDataPts);
    double[] yValuesSrt = Arrays.copyOf(yValues, nDataPts);
    ParallelArrayBinarySort.parallelBinarySort(xValuesSrt, yValuesSrt);

    final DoubleMatrix2D coefMatrix = solve(xValuesSrt, yValuesSrt);

    for (int i = 0; i < coefMatrix.getNumberOfRows(); ++i) {
      for (int j = 0; j < coefMatrix.getNumberOfColumns(); ++j) {
        ArgumentChecker.isFalse(Double.isNaN(coefMatrix.getData()[i][j]), "Too large input");
        ArgumentChecker.isFalse(Double.isInfinite(coefMatrix.getData()[i][j]), "Too large input");
      }
      double ref = 0.;
      final double interval = xValuesSrt[i + 1] - xValuesSrt[i];
      for (int j = 0; j < 2; ++j) {
        ref += coefMatrix.getData()[i][j] * Math.pow(interval, 1 - j);
        ArgumentChecker.isFalse(Double.isNaN(coefMatrix.getData()[i][j]), "Too large input");
        ArgumentChecker.isFalse(Double.isInfinite(coefMatrix.getData()[i][j]), "Too large input");
      }
      final double bound = Math.max(Math.abs(ref) + Math.abs(yValuesSrt[i + 1]), 1.e-1);
      ArgumentChecker.isTrue(Math.abs(ref - yValuesSrt[i + 1]) < ERROR * bound, "Input is too large/small or data are not distinct enough");
    }

    return new PiecewisePolynomialResult(new DoubleMatrix1D(xValuesSrt), coefMatrix, coefMatrix.getNumberOfColumns(), 1);
  }
View Full Code Here

      for (int j = 0; j < dim; ++j) {
        resMatrix[dim * i + j] = coefMatrix[j].getRowVector(i).getData();
      }
    }

    return new PiecewisePolynomialResult(new DoubleMatrix1D(xValuesSrt), new DoubleMatrix2D(resMatrix), nCoefs, dim);
  }
View Full Code Here

    for (int i = 0; i < nDataPts - 1; ++i) {
      res[i][1] = yValues[i];
      res[i][0] = (yValues[i + 1] - yValues[i]) / (xValues[i + 1] - xValues[i]);
    }

    return new DoubleMatrix2D(res);
  }
View Full Code Here

TOP

Related Classes of com.opengamma.analytics.math.matrix.DoubleMatrix2D

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.