Real Fdm2DimSolver::thetaAt(Real x, Real y) const { QL_REQUIRE(conditions_->stoppingTimes().front() > 0.0, "stopping time at zero-> can't calculate theta"); calculate(); Matrix thetaValues(resultValues_.rows(), resultValues_.columns()); const Array& rhs = thetaCondition_->getValues(); std::copy(rhs.begin(), rhs.end(), thetaValues.begin()); return (BicubicSpline(x_.begin(), x_.end(), y_.begin(), y_.end(), thetaValues)(x, y) - interpolateAt(x, y)) / thetaCondition_->getTime(); }
Real FdmHestonSolver::thetaAt(Real s, Real v) const { QL_REQUIRE(condition_->stoppingTimes().front() > 0.0, "stopping time at zero-> can't calculate theta"); calculate(); Matrix thetaValues(resultValues_.rows(), resultValues_.columns()); const Array& rhs = thetaCondition_->getValues(); std::copy(rhs.begin(), rhs.end(), thetaValues.begin()); return (BicubicSpline(x_.begin(), x_.end(), v_.begin(), v_.end(), thetaValues)(std::log(s), v) - valueAt(s, v)) / thetaCondition_->getTime(); }
Real Fdm3DimSolver::thetaAt(Real x, Real y, Rate z) const { QL_REQUIRE(conditions_->stoppingTimes().front() > 0.0, "stopping time at zero-> can't calculate theta"); calculate(); const Array& rhs = thetaCondition_->getValues(); std::vector<Matrix> thetaValues(z_.size(), Matrix(y_.size(),x_.size())); for (Size i=0; i < z_.size(); ++i) { std::copy(rhs.begin()+i *y_.size()*x_.size(), rhs.begin()+(i+1)*y_.size()*x_.size(), thetaValues[i].begin()); } Array zArray(z_.size()); for (Size i=0; i < z_.size(); ++i) { zArray[i] = BicubicSpline(x_.begin(),x_.end(), y_.begin(),y_.end(), thetaValues[i])(x,y); } return (MonotonicCubicNaturalSpline(z_.begin(), z_.end(), zArray.begin())(z) - interpolateAt(x, y, z)) / thetaCondition_->getTime(); }
Real FdmHestonHullWhiteSolver::thetaAt(Real s, Real v, Rate r) const { QL_REQUIRE(condition_->stoppingTimes().front() > 0.0, "stopping time at zero-> can't calculate theta"); calculate(); const Array& rhs = thetaCondition_->getValues(); std::vector<Matrix> thetaValues(r_.size(), Matrix(v_.size(),x_.size())); for (Size i=0; i < r_.size(); ++i) { std::copy(rhs.begin()+i *v_.size()*x_.size(), rhs.begin()+(i+1)*v_.size()*x_.size(), thetaValues[i].begin()); } Array y(r_.size()); const Real x = std::log(s); for (Size i=0; i < r_.size(); ++i) { y[i] = BicubicSpline(x_.begin(), x_.end(), v_.begin(), v_.end(), thetaValues[i])(x, v); } return (MonotonicCubicNaturalSpline(r_.begin(), r_.end(), y.begin())(r) - valueAt(s, v, r)) / thetaCondition_->getTime(); }