Package org.jquantlib.math.matrixutilities

Examples of org.jquantlib.math.matrixutilities.Array


    @Override
    public List</* @Time */Double> mandatoryTimes() {
        final List</* @Time */Double> times = underlying.mandatoryTimes();

        // discard negative times...
        final Array array = new FindIf(exerciseTimes, new Bind2ndPredicate(new GreaterEqualPredicate(), 0.0)).op();
        // and add the positive ones
        for (int i=0; i< array.size(); i++) {
            times.add(array.get(i));
        }
        return times;
    }
View Full Code Here


        super(t);
        this.n = n;
        if (n <= 0)
            throw new IllegalStateException("there is no zeronomial lattice!");
        statePrices = new Vector<Array>();
        statePrices.add(new Array().fill(1.0));
        statePricesLimit = 0;
    }
View Full Code Here

    // protected methods
    //

    protected void computeStatePrices(final int until) {
        for (int i = statePricesLimit; i < until; i++) {
            statePrices.add(new Array(size(i + 1)));
            for (int j = 0; j < size(i); j++) {
                final double disc = discount(i, j);
                final double statePrice = statePrices.get(i).get(j);
                final Array array = statePrices.get(i + 1);
                for (int l = 0; l < n; l++) {
                    final int index = descendant(i, j, l);
                    final double oldValue = array.get(index);
                    array.set(index, oldValue + (statePrice * disc * probability(i, j, l)));
                }
            }
        }
        statePricesLimit = until;
    }
View Full Code Here

        final int iFrom = t.index(from);
        final int iTo = t.index(to);

        for (int i = iFrom - 1; i >= iTo; --i) {
            final Array newValues = new Array(size(i));
            stepback(i, asset.values(), newValues);
            asset.setTime(t.get(i));
            asset.setValues(newValues);
            // skip the very last adjustment
            if (i != iTo)
View Full Code Here

        this.dayCounter = dayCounter;
        this.dates = dates.clone();
        this.maxDate = dates[dates.length-1];

        variances = /*@Variance*/ new Array(this.dates.length+1);
        times     = /*@Time*/     new Array(this.dates.length+1);
        variances.set(0, 0.0);
        times.set(0, 0.0);
        for (int j=1; j<=blackVolCurve.length; j++) {
            times.set(j, timeFromReference(this.dates[j-1]));
            QL.require(times.get(j)>times.get(j-1) , "times must be sorted unique"); // QA:[RG]::verified // TODO: message
View Full Code Here

        // Partial derivatives calculated from various points in the binomial tree (Odegaard)

        // Rollback to third-last step, and get underlying price (s2) & option values (p2) at this point
        option.rollback(grid.at(2));
        final Array va2 = option.values();
        QL.require(va2.size() == 3 , "expect 3 nodes in grid at second step"); // QA:[RG]::verified // TODO: message
        final double p2h = va2.get(2); // high-price
        final double s2 = lattice.underlying(2, 2); // high price

        // Rollback to second-last step, and get option value (p1) at this point
        option.rollback(grid.at(1));
        final Array va = option.values();
        QL.require(va.size() == 2, "expect 2 nodes in grid at first step"); // QA:[RG]::verified // TODO: message
        final double p1 = va.get(1);

        // Finally, rollback to t=0
        option.rollback(0.0);
        final double p0 = option.presentValue();
        final double s1 = lattice.underlying(1, 1);
View Full Code Here

    //
    // private methods
    //

    private void applySpecificCondition() {
        final Array grid = method().grid(time());
        for (int j = 0; j < values.size(); j++) {
            values.set(j, Math.max(values.get(j), a.payoff.get(grid.get(j))));
        }
    }
View Full Code Here

    // overrides DiscretizedAsset
    //

    @Override
    public void reset(final int size) {
        values = new Array(size);
        adjustValues();
    }
View Full Code Here

  protected Array diagonal;
  protected Array upperDiagonal;

  public TridiagonalOperator(final int size) {
    if (size >= 3) {
      this.lowerDiagonal = new Array(size - 1);
      this.diagonal = new Array(size);
      this.upperDiagonal = new Array(size - 1);
    } else if (size == 0) {
      this.lowerDiagonal = new Array(0);
      this.diagonal = new Array(0);
      this.upperDiagonal = new Array(0);
    } else
            throw new IllegalStateException("Invalid size for Tridiagonal Operator"); // TODO: message

  }
View Full Code Here

  }

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

TOP

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

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.