Package com.opengamma.analytics.math.matrix

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


   * @return The total sensitivity.
   */
  public SimpleParameterSensitivity plus(final String name, final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(name, "Name");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    if (result.containsKey(name)) {
      result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), sensitivity));
    } else {
      result.put(name, sensitivity);
    }
    return new SimpleParameterSensitivity(result);
  }
View Full Code Here


   * @param other The sensitivity to add.
   * @return The total sensitivity.
   */
  public SimpleParameterSensitivity plus(final SimpleParameterSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity to add");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    for (final Map.Entry<String, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) {
      final String name = entry.getKey();
      if (result.containsKey(name)) {
        result.put(name, (DoubleMatrix1D) algebra.add(result.get(name), entry.getValue()));
      } else {
        result.put(name, entry.getValue());
      }
    }
    return new SimpleParameterSensitivity(result);
View Full Code Here

   * Create a copy of the object with all the sensitivities multiplied by a common factor.
   * @param factor The factor.
   * @return The multiplied sensitivity.
   */
  public SimpleParameterSensitivity multipliedBy(final double factor) {
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<String, DoubleMatrix1D> result = new LinkedHashMap<>();
    for (final String nameCcy : _sensitivity.keySet()) {
      result.put(nameCcy, (DoubleMatrix1D) algebra.scale(_sensitivity.get(nameCcy), factor));
    }
    return new SimpleParameterSensitivity(result);
  }
View Full Code Here

   * @return The total sensitivity.
   */
  public MultipleCurrencyParameterSensitivity plus(final Pair<String, Currency> nameCcy, final DoubleMatrix1D sensitivity) {
    ArgumentChecker.notNull(nameCcy, "Name/currency");
    ArgumentChecker.notNull(sensitivity, "Matrix");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    if (result.containsKey(nameCcy)) {
      result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), sensitivity));
    } else {
      result.put(nameCcy, sensitivity);
    }
    return new MultipleCurrencyParameterSensitivity(result);
  }
View Full Code Here

   * @param other The sensitivity to add.
   * @return The total sensitivity.
   */
  public MultipleCurrencyParameterSensitivity plus(final MultipleCurrencyParameterSensitivity other) {
    ArgumentChecker.notNull(other, "Sensitivity to add");
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    result.putAll(_sensitivity);
    for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : other.getSensitivities().entrySet()) {
      final Pair<String, Currency> nameCcy = entry.getKey();
      if (result.containsKey(nameCcy)) {
        result.put(nameCcy, (DoubleMatrix1D) algebra.add(result.get(nameCcy), entry.getValue()));
      } else {
        result.put(nameCcy, entry.getValue());
      }
    }
    return new MultipleCurrencyParameterSensitivity(result);
View Full Code Here

   * Create a copy of the object with all the sensitivities multiplied by a common factor.
   * @param factor The factor.
   * @return The multiplied sensitivity.
   */
  public MultipleCurrencyParameterSensitivity multipliedBy(final double factor) {
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final LinkedHashMap<Pair<String, Currency>, DoubleMatrix1D> result = new LinkedHashMap<>();
    for (final Pair<String, Currency> nameCcy : _sensitivity.keySet()) {
      result.put(nameCcy, (DoubleMatrix1D) algebra.scale(_sensitivity.get(nameCcy), factor));
    }
    return new MultipleCurrencyParameterSensitivity(result);
  }
View Full Code Here

   */
  public MultipleCurrencyParameterSensitivity converted(final FXMatrix fxMatrix, final Currency ccy) {
    ArgumentChecker.notNull(ccy, "Currency");
    ArgumentChecker.notNull(fxMatrix, "FX Matrix");
    MultipleCurrencyParameterSensitivity result = new MultipleCurrencyParameterSensitivity();
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : _sensitivity.entrySet()) {
      final Pair<String, Currency> nameCcy = entry.getKey();
      final double fxRate = fxMatrix.getFxRate(nameCcy.getSecond(), ccy);
      final Pair<String, Currency> nameCcyNew = Pair.of(nameCcy.getFirst(), ccy);
      final DoubleMatrix1D sensitivityNew = (DoubleMatrix1D) algebra.scale(entry.getValue(), fxRate);
      result = result.plus(nameCcyNew, sensitivityNew);
    }
    return result;
  }
View Full Code Here

    final double amr = lmm.getMeanReversion();
    final double[] iborTime = lmm.getIborTime();
    final double[] almm = lmm.getDisplacement();
    final double[] deltalmm = lmm.getAccrualFactor();
    final DoubleMatrix2D gammaLMM = new DoubleMatrix2D(lmm.getVolatility());
    final MatrixAlgebra algebra = new CommonsMatrixAlgebra();
    final DoubleMatrix2D s = (DoubleMatrix2D) algebra.multiply(gammaLMM, algebra.getTranspose(gammaLMM));
    final int nbJump = jumpTime.length - 1;
    final int nbPath = initIbor[0].length;
    final int nbPeriodLMM = lmm.getNbPeriod();
    final int nbFactorLMM = lmm.getNbFactor();
    final double[] dt = new double[nbJump];
View Full Code Here

    final double amr = lmm.getMeanReversion();
    final double[] iborTime = lmm.getIborTime();
    final double[] almm = lmm.getDisplacement();
    final double[] deltalmm = lmm.getAccrualFactor();
    final DoubleMatrix2D gammaLMM = new DoubleMatrix2D(lmm.getVolatility());
    final MatrixAlgebra algebra = new CommonsMatrixAlgebra();
    final DoubleMatrix2D s = (DoubleMatrix2D) algebra.multiply(gammaLMM, algebra.getTranspose(gammaLMM));
    final int nbJump = jumpTime.length - 1;
    final int nbPath = initIbor[0].length;
    final int nbPeriodLMM = lmm.getNbPeriod();
    final int nbFactorLMM = lmm.getNbFactor();
    final double[] dt = new double[nbJump];
View Full Code Here

      final boolean opposite) {
    ArgumentChecker.notNull(sensitivity1, "sensitivity1");
    ArgumentChecker.notNull(sensitivity2, "sensitivity2");
    ArgumentChecker.isTrue(tolerance > 0, "tolerance must be greater than 0; have {}", tolerance);
    boolean cmp = true;
    final MatrixAlgebra algebra = MatrixAlgebraFactory.COMMONS_ALGEBRA;
    final Map<Pair<String, Currency>, DoubleMatrix1D> map1 = sensitivity1.getSensitivities();
    final Map<Pair<String, Currency>, DoubleMatrix1D> map2 = sensitivity2.getSensitivities();
    for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : map1.entrySet()) {
      final Pair<String, Currency> nameCcy = entry.getKey();
      if (map2.get(nameCcy) == null) {
        if (algebra.getNormInfinity(entry.getValue()) > tolerance) {
          cmp = false;
        }
      } else {
        if (algebra.getNormInfinity(algebra.add(entry.getValue(), algebra.scale(map2.get(nameCcy), -1.0))) > tolerance) {
          cmp = false;
        }
      }
    }
    for (final Map.Entry<Pair<String, Currency>, DoubleMatrix1D> entry : map2.entrySet()) {
      final Pair<String, Currency> nameCcy = entry.getKey();
      if (map1.get(nameCcy) == null) {
        if (algebra.getNormInfinity(entry.getValue()) > tolerance) {
          cmp = false;
        }
      } else {
        if (algebra.getNormInfinity(algebra.add(entry.getValue(), algebra.scale(map1.get(nameCcy), -1.0))) > tolerance) {
          cmp = false;
        }
      }
    }
    if (opposite) {
View Full Code Here

TOP

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

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.