public double thetaAt(double x, double y) { Utils.QL_REQUIRE(conditions_.stoppingTimes().First() > 0.0, () => "stopping time at zero-> can't calculate theta"); calculate(); Matrix thetaValues = new Matrix(resultValues_.rows(), resultValues_.columns()); Vector rhs = thetaCondition_.getValues(); int row = 0, col = 0; for (int i = 0; i < rhs.size(); i++) { if (col == thetaValues.columns()) { row++; col = 0; } thetaValues[row, col] = rhs[i]; } double temp = new BicubicSpline( x_, x_.Count, y_, y_.Count, thetaValues).value(x, y); return((temp - interpolateAt(x, y)) / thetaCondition_.getTime()); }
protected override void performCalculations() { object rhs = new Vector(initialValues_.Count); for (int i = 0; i < initialValues_.Count; i++) { (rhs as Vector)[i] = initialValues_[i]; } new FdmBackwardSolver(op_, solverDesc_.bcSet, conditions_, schemeDesc_) .rollback(ref rhs, solverDesc_.maturity, 0.0, solverDesc_.timeSteps, solverDesc_.dampingSteps); int row = 0, col = 0; for (int i = 0; i < (rhs as Vector).size(); i++) { if (col == resultValues_.columns()) { row++; col = 0; } resultValues_[row, col] = (rhs as Vector)[i]; col++; } interpolation_ = new BicubicSpline(x_, x_.Count, y_, y_.Count, resultValues_); }
private void interpolate() { interpolation_ = new BicubicSpline(strikes_, strikes_.Count, optionTimes_, optionTimes_.Count, vols_); }