Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Array$Range


  }

    @Override
  public Operator subtract(final Operator op) {
        final TridiagonalOperator D = (TridiagonalOperator)op;
        final Array low  = lowerDiagonal.sub(D.lowerDiagonal);
        final Array mid  = diagonal.sub(D.diagonal);
        final Array high = upperDiagonal.sub(D.upperDiagonal);
        return new TridiagonalOperator(low, mid, high);
  }
View Full Code Here


        return new TridiagonalOperator(low, mid, high);
  }

    @Override
    public Operator multiply(final double a) {
        final Array low  = lowerDiagonal.mul(a);
        final Array mid  = diagonal.mul(a);
        final Array high = upperDiagonal.mul(a);
        return new TridiagonalOperator(low, mid, high);
    }
View Full Code Here

   * Identity instance
   */
    @Override
  public TridiagonalOperator identity(final int size) {
    final TridiagonalOperator I = new TridiagonalOperator(
        new Array(size-1),         // lower diagonal
        new Array(size).fill(1.0), // diagonal
        new Array(size-1));        // upper diagonal
    return I;
  }
View Full Code Here

  public Array applyTo(final Array v) /*@ReadOnly*/ {
    if (v.size() != size())
      throw new IllegalStateException("vector of the wrong size (" + v.size() + "instead of " + size() + ")");

    // result = diagonal * v
    final Array result = this.diagonal.mul(v);

    // matricial product
    double d = result.get(0) + (this.upperDiagonal.get(0) * v.get(1));
    result.set(0, d);
    for (int j=1; j<=size()-2; j++) {
        d = result.get(j) + (lowerDiagonal.get(j-1) * v.get(j-1)) + (upperDiagonal.get(j) * v.get(j+1));
      result.set(j, d);
    }
    d = result.get(size()-1) + (lowerDiagonal.get(size()-2) * v.get(size()-2));
    result.set(size()-1, d);

    return result;
  }
View Full Code Here

  /**
   * Solve linear system for a given right-hand side
   */
    @Override
  public final Array solveFor(final Array rhs) {
    final Array result = new Array(size());
    final Array tmp = new Array(size());

    double bet = diagonal.first();
    if (bet == 0.0) throw new IllegalStateException("division by zero");

    result.set(0, rhs.first() / bet);
    int j;
    for (j = 1; j <= size() - 1; j++) {
      tmp.set(j, upperDiagonal.get(j - 1) / bet);
      bet = diagonal.get(j) - lowerDiagonal.get(j - 1) * tmp.get(j);
      if (bet == 0.0) throw new IllegalStateException("division by zero");
      result.set(j, (rhs.get(j) - lowerDiagonal.get(j - 1) * result.get(j - 1)) / bet);
    }

    // cannot be j>=0 with Size j
    for (j = size() - 2; j > 0; --j) {
            result.set(j, result.get(j) - (tmp.get(j + 1) * result.get(j + 1)));
        }

    result.set(0, result.first() - (tmp.get(1) * result.get(1)));
    return result;
  }
View Full Code Here

        inArrears_ = (false);
        zeroPayments_ = (false);
    }

    public CmsLeg withNotionals(/* Real */final double notional) {
        notionals_ = new Array(1).fill(notional);
        return this;
    }
View Full Code Here

        fixingDays_ = fixingDays; // TODO: clone() ?
        return this;
    }

    public CmsLeg withGearings(/* Real */final double gearing) {
        gearings_ = new Array(1).fill(gearing);
        return this;
    }
View Full Code Here

        gearings_ = gearings;
        return this;
    }

    public CmsLeg withSpreads(/* Spread */final double spread) {
        spreads_ = new Array(1).fill(spread);
        return this;
    }
View Full Code Here

        spreads_ = spreads;
        return this;
    }

    public CmsLeg withCaps(/* @Rate */final double cap) {
        caps_ = new Array(1).fill(cap);
        return this;
    }
View Full Code Here

        caps_ = caps;
        return this;
    }

    public CmsLeg withFloors(/* @Rate */final double floor) {
        floors_ = new Array(1).fill(floor);
        return this;
    }
View Full Code Here

TOP

Related Classes of org.jquantlib.math.matrixutilities.Array$Range

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.