Skip to content

Commit

Permalink
Merge 003d083 into 3f21536
Browse files Browse the repository at this point in the history
  • Loading branch information
lballabio committed Aug 11, 2020
2 parents 3f21536 + 003d083 commit 3b938bd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
12 changes: 6 additions & 6 deletions ql/math/interpolations/xabrinterpolation.hpp
Expand Up @@ -137,8 +137,8 @@ class XABRInterpolationImpl : public Interpolation::templateImpl<I1, I2>,

// we must update weights if it is vegaWeighted
if (vegaWeighted_) {
std::vector<Real>::const_iterator x = this->xBegin_;
std::vector<Real>::const_iterator y = this->yBegin_;
I1 x = this->xBegin_;
I2 y = this->yBegin_;
// std::vector<Real>::iterator w = weights_.begin();
this->weights_.clear();
Real weightsSum = 0.0;
Expand Down Expand Up @@ -244,8 +244,8 @@ class XABRInterpolationImpl : public Interpolation::templateImpl<I1, I2>,
// calculate total squared weighted difference (L2 norm)
Real interpolationSquaredError() const {
Real error, totalError = 0.0;
std::vector<Real>::const_iterator x = this->xBegin_;
std::vector<Real>::const_iterator y = this->yBegin_;
I1 x = this->xBegin_;
I2 y = this->yBegin_;
std::vector<Real>::const_iterator w = this->weights_.begin();
for (; x != this->xEnd_; ++x, ++y, ++w) {
error = (value(*x) - *y);
Expand All @@ -257,9 +257,9 @@ class XABRInterpolationImpl : public Interpolation::templateImpl<I1, I2>,
// calculate weighted differences
Disposable<Array> interpolationErrors() const {
Array results(this->xEnd_ - this->xBegin_);
std::vector<Real>::const_iterator x = this->xBegin_;
I1 x = this->xBegin_;
Array::iterator r = results.begin();
std::vector<Real>::const_iterator y = this->yBegin_;
I2 y = this->yBegin_;
std::vector<Real>::const_iterator w = this->weights_.begin();
for (; x != this->xEnd_; ++x, ++r, ++w, ++y) {
*r = (value(*x) - *y) * std::sqrt(*w);
Expand Down
2 changes: 2 additions & 0 deletions ql/math/optimization/simplex.hpp
Expand Up @@ -61,6 +61,8 @@ namespace QuantLib {
Simplex(Real lambda) : lambda_(lambda) {}
virtual EndCriteria::Type minimize(Problem& P,
const EndCriteria& endCriteria);
Real lambda() const { return lambda_; }

private:
Real extrapolate(Problem& P,
Size iHighest,
Expand Down
1 change: 1 addition & 0 deletions ql/pricingengines/inflation/inflationcapfloorengines.hpp
Expand Up @@ -49,6 +49,7 @@ namespace QuantLib {

ext::shared_ptr<YoYInflationIndex> index() const { return index_;}
Handle<YoYOptionletVolatilitySurface> volatility() const { return volatility_; }
Handle<YieldTermStructure> nominalTermStructure() const { return nominalTermStructure_; }

void setVolatility(const Handle<YoYOptionletVolatilitySurface>& vol);

Expand Down
1 change: 1 addition & 0 deletions ql/termstructures/iterativebootstrap.hpp
Expand Up @@ -215,6 +215,7 @@ namespace detail {
// because, e.g., of interpolation's early checks
ts_->data_ = std::vector<Real>(alive_+1, Traits::initialValue(ts_));
previousData_.resize(alive_+1);
validCurve_ = false;
}
initialized_ = true;
}
Expand Down
7 changes: 2 additions & 5 deletions ql/timegrid.hpp
Expand Up @@ -120,12 +120,9 @@ namespace QuantLib {
++t) {
Time periodEnd = *t;
if (periodEnd != 0.0) {
// the nearest integer
Size nSteps = Size((periodEnd - periodBegin)/dtMax+0.5);
// at least one time step!
nSteps = (nSteps!=0 ? nSteps : 1);
// the nearest integer, at least 1
Size nSteps = std::max(Size((periodEnd - periodBegin)/dtMax+0.5), Size(1));
Time dt = (periodEnd - periodBegin)/nSteps;
times_.reserve(nSteps);
for (Size n=1; n<=nSteps; ++n)
times_.push_back(periodBegin + n*dt);
}
Expand Down

0 comments on commit 3b938bd

Please sign in to comment.