Andreas,
Thanks for the detailed bug report and patch. I think I won't make a new release quite yet given how gcc / g++ 3.3 are still the default -- and QuantLib may have a 0.3.8 release before we switch to 3.4. QuantLib crew, Haven't checked with CVS whether this is already in the sources; if it isn't this may make a nice addition. Cheers, Dirk On Wed, Aug 18, 2004 at 12:28:16AM +0200, Andreas Jochens wrote: > Package: quantlib > Severity: normal > Tags: patch > > With the attached patch 'quantlib' can be compiled using gcc-3.4. > > Regards > Andreas Jochens > > diff -urN ../tmp-orig/quantlib-0.3.7/ql/CashFlows/shortindexedcoupon.hpp ./ql/CashFlows/shortindexedcoupon.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/CashFlows/shortindexedcoupon.hpp 2004-05-12 11:46:10.000000000 +0200 > +++ ./ql/CashFlows/shortindexedcoupon.hpp 2004-08-18 00:06:02.164098553 +0200 > @@ -53,9 +53,9 @@ > Real amount() const { > QL_FAIL("short/long indexed coupons not supported yet" > " (start = " + > - DateFormatter::toString(accrualStartDate_) + > + DateFormatter::toString(this->accrualStartDate_) + > ", end = " + > - DateFormatter::toString(accrualEndDate_) + ")"); > + DateFormatter::toString(this->accrualEndDate_) + ")"); > } > }; > > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/bicubicsplineinterpolation.hpp ./ql/Math/bicubicsplineinterpolation.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/bicubicsplineinterpolation.hpp 2004-05-12 18:16:52.000000000 +0200 > +++ ./ql/Math/bicubicsplineinterpolation.hpp 2004-08-17 23:43:16.623692249 +0200 > @@ -42,16 +42,16 @@ > : Interpolation2D::templateImpl<I1,I2,M>(xBegin,xEnd, > yBegin,yEnd, > zData) { > - for (Size i=0; i<zData_.rows(); i++) > + for (Size i=0; i<this->zData_.rows(); i++) > splines_.push_back(NaturalCubicSpline( > - xBegin, xEnd, zData_.row_begin(i))); > + xBegin, xEnd, this->zData_.row_begin(i))); > } > Real value(Real x, Real y) const { > std::vector<Real> section(splines_.size()); > for (Size i=0; i<splines_.size(); i++) > section[i]=splines_[i](x,true); > > - NaturalCubicSpline spline(yBegin_, yEnd_, section.begin()); > + NaturalCubicSpline spline(this->yBegin_, this->yEnd_, section.begin()); > return spline(y,true); > } > private: > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/bilinearinterpolation.hpp ./ql/Math/bilinearinterpolation.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/bilinearinterpolation.hpp 2004-05-12 18:16:52.000000000 +0200 > +++ ./ql/Math/bilinearinterpolation.hpp 2004-08-17 23:54:17.673197449 +0200 > @@ -40,15 +40,15 @@ > yBegin,yEnd, > zData) {} > Real value(Real x, Real y) const { > - Size i = locateX(x), j = locateY(y); > + Size i = this->locateX(x), j = this->locateY(y); > > - Real z1=zData_[j][i]; > - Real z2=zData_[j][i+1]; > - Real z3=zData_[j+1][i]; > - Real z4=zData_[j+1][i+1]; > + Real z1=this->zData_[j][i]; > + Real z2=this->zData_[j][i+1]; > + Real z3=this->zData_[j+1][i]; > + Real z4=this->zData_[j+1][i+1]; > > - Real t=(x-xBegin_[i])/(xBegin_[i+1]-xBegin_[i]); > - Real u=(y-yBegin_[j])/(yBegin_[j+1]-yBegin_[j]); > + Real t=(x-this->xBegin_[i])/(this->xBegin_[i+1]-this->xBegin_[i]); > + Real u=(y-this->yBegin_[j])/(this->yBegin_[j+1]-this->yBegin_[j]); > > return (1.0-t)*(1.0-u)*z1 + t*(1.0-u)*z2 > + (1.0-t)*u*z3 + t*u*z4; > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/cubicspline.hpp ./ql/Math/cubicspline.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/cubicspline.hpp 2004-05-17 18:39:49.000000000 +0200 > +++ ./ql/Math/cubicspline.hpp 2004-08-17 21:56:04.049592153 +0200 > @@ -96,11 +96,11 @@ > std::vector<Real> dx(n_-1), S(n_-1); > > Size i=0; > - dx[i]= xBegin_[i+1] - xBegin_[i]; > - S[i] =(yBegin_[i+1] - yBegin_[i])/dx[i]; > + dx[i]= this->xBegin_[i+1] - this->xBegin_[i]; > + S[i] =(this->yBegin_[i+1] - this->yBegin_[i])/dx[i]; > for (i=1; i<n_-1; i++) { > - dx[i]= xBegin_[i+1] - xBegin_[i]; > - S[i] =(yBegin_[i+1] - yBegin_[i])/dx[i]; > + dx[i]= this->xBegin_[i+1] - this->xBegin_[i]; > + S[i] =(this->yBegin_[i+1] - this->yBegin_[i])/dx[i]; > > L.setMidRow(i, dx[i], 2.0*(dx[i]+dx[i-1]), dx[i-1]); > tmp[i] = 3.0*(dx[i]*S[i-1] + dx[i-1]*S[i]); > @@ -234,30 +234,30 @@ > for (i=1; i<n_-1; i++) { > primitiveConst_[i] = primitiveConst_[i-1] > + dx[i-1] * > - (yBegin_[i-1] + dx[i-1] * > + (this->yBegin_[i-1] + dx[i-1] * > (a_[i-1]/2.0 + dx[i-1] * > (b_[i-1]/3.0 + dx[i-1] * c_[i-1]/4.0))); > } > } > Real value(Real x) const { > - Size j = locate(x); > - Real dx = x-xBegin_[j]; > - return yBegin_[j] + dx*(a_[j] + dx*(b_[j] + dx*c_[j])); > + Size j = this->locate(x); > + Real dx = x-this->xBegin_[j]; > + return this->yBegin_[j] + dx*(a_[j] + dx*(b_[j] + dx*c_[j])); > } > Real primitive(Real x) const { > - Size j = locate(x); > - Real dx = x-xBegin_[j]; > - return primitiveConst_[j] + dx*(yBegin_[j] + dx*(a_[j]/2.0 > + Size j = this->locate(x); > + Real dx = x-this->xBegin_[j]; > + return primitiveConst_[j] + dx*(this->yBegin_[j] + dx*(a_[j]/2.0 > + dx*(b_[j]/3.0 + dx*c_[j]/4.0))); > } > Real derivative(Real x) const { > - Size j = locate(x); > - Real dx = x-xBegin_[j]; > + Size j = this->locate(x); > + Real dx = x-this->xBegin_[j]; > return a_[j] + (2.0*b_[j] + 3.0*c_[j]*dx)*dx; > } > Real secondDerivative(Real x) const { > - Size j = locate(x); > - Real dx = x-xBegin_[j]; > + Size j = this->locate(x); > + Real dx = x-this->xBegin_[j]; > return 2.0*b_[j] + 6.0*c_[j]*dx; > } > private: > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/gaussianstatistics.hpp ./ql/Math/gaussianstatistics.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/gaussianstatistics.hpp 2004-05-18 15:05:24.000000000 +0200 > +++ ./ql/Math/gaussianstatistics.hpp 2004-08-17 23:58:18.389602993 +0200 > @@ -120,8 +120,8 @@ > template<class Stat> > inline > Real GaussianStatistics<Stat>::gaussianRegret(Real target) const { > - Real m = mean(); > - Real std = standardDeviation(); > + Real m = this->mean(); > + Real std = this->standardDeviation(); > Real variance = std*std; > CumulativeNormalDistribution gIntegral(m, std); > NormalDistribution g(m, std); > @@ -197,8 +197,8 @@ > DecimalFormatter::toString(percentile) + > ") out of range [0.9, 1.0)"); > > - Real m = mean(); > - Real std = standardDeviation(); > + Real m = this->mean(); > + Real std = this->standardDeviation(); > InverseCumulativeNormal gInverse(m, std); > Real var = gInverse(1.0-percentile); > NormalDistribution g(m, std); > @@ -213,8 +213,8 @@ > template<class Stat> > inline Real GaussianStatistics<Stat>::gaussianShortfall( > Real target) const { > - CumulativeNormalDistribution gIntegral(mean(), > - standardDeviation()); > + CumulativeNormalDistribution gIntegral(this->mean(), > + this->standardDeviation()); > return gIntegral(target); > } > > @@ -222,8 +222,8 @@ > template<class Stat> > inline Real GaussianStatistics<Stat>::gaussianAverageShortfall( > Real target) const { > - Real m = mean(); > - Real std = standardDeviation(); > + Real m = this->mean(); > + Real std = this->standardDeviation(); > CumulativeNormalDistribution gIntegral(m, std); > NormalDistribution g(m, std); > return ( (target-m) + std*std*g(target)/gIntegral(target) ); > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/linearinterpolation.hpp ./ql/Math/linearinterpolation.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/linearinterpolation.hpp 2004-05-18 12:43:26.000000000 +0200 > +++ ./ql/Math/linearinterpolation.hpp 2004-08-17 23:42:27.772118817 +0200 > @@ -37,24 +37,24 @@ > primitiveConst_(xEnd-xBegin), s_(xEnd-xBegin) { > primitiveConst_[0] = 0.0; > for (Size i=1; i<Size(xEnd-xBegin); i++) { > - Real dx = xBegin_[i]-xBegin_[i-1]; > - s_[i-1] = (yBegin_[i]-yBegin_[i-1])/dx; > + Real dx = this->xBegin_[i]-this->xBegin_[i-1]; > + s_[i-1] = (this->yBegin_[i]-this->yBegin_[i-1])/dx; > primitiveConst_[i] = primitiveConst_[i-1] > - + dx*(yBegin_[i-1] +0.5*dx*s_[i-1]); > + + dx*(this->yBegin_[i-1] +0.5*dx*s_[i-1]); > } > } > Real value(Real x) const { > - Size i = locate(x); > - return yBegin_[i] + (x-xBegin_[i])*s_[i]; > + Size i = this->locate(x); > + return this->yBegin_[i] + (x-this->xBegin_[i])*s_[i]; > } > Real primitive(Real x) const { > - Size i = locate(x); > - Real dx = x-xBegin_[i]; > + Size i = this->locate(x); > + Real dx = x-this->xBegin_[i]; > return primitiveConst_[i] + > - dx*(yBegin_[i] + 0.5*dx*s_[i]); > + dx*(this->yBegin_[i] + 0.5*dx*s_[i]); > } > Real derivative(Real x) const { > - Size i = locate(x); > + Size i = this->locate(x); > return s_[i]; > } > Real secondDerivative(Real) const { > diff -urN ../tmp-orig/quantlib-0.3.7/ql/Math/riskstatistics.hpp ./ql/Math/riskstatistics.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/Math/riskstatistics.hpp 2004-05-18 15:05:24.000000000 +0200 > +++ ./ql/Math/riskstatistics.hpp 2004-08-18 00:03:28.948390881 +0200 > @@ -124,7 +124,7 @@ > > template <class S> > inline Real GenericRiskStatistics<S>::semiVariance() const { > - return regret(mean()); > + return regret(this->mean()); > } > > template <class S> > @@ -148,7 +148,7 @@ > Real GenericRiskStatistics<S>::regret(Real target) const { > // average over the range below the target > std::pair<Real,Size> result = > - expectationValue(compose(square<Real>(), > + this->expectationValue(compose(square<Real>(), > std::bind2nd(std::minus<Real>(), > target)), > std::bind2nd(std::less<Real>(), > @@ -170,7 +170,7 @@ > ") out of range [0.9, 1.0)"); > > // must be a gain, i.e., floored at 0.0 > - return QL_MAX<Real>(topPercentile(1.0-centile), 0.0); > + return QL_MAX<Real>(this->topPercentile(1.0-centile), 0.0); > } > > /*! \pre percentile must be in range [90%-100%) */ > @@ -183,7 +183,7 @@ > ") out of range [0.9, 1.0)"); > > // must be a loss, i.e., capped at 0.0 and negated > - return -QL_MIN<Real>(percentile(1.0-centile), 0.0); > + return -QL_MIN<Real>(this->percentile(1.0-centile), 0.0); > } > > /*! \pre percentile must be in range [90%-100%) */ > @@ -194,10 +194,10 @@ > DecimalFormatter::toString(centile) + > ") out of range [0.9, 1.0)"); > > - QL_ENSURE(samples() != 0, "empty sample set"); > + QL_ENSURE(this->samples() != 0, "empty sample set"); > Real target = -valueAtRisk(centile); > std::pair<Real,Size> result = > - expectationValue(identity<Real>(), > + this->expectationValue(identity<Real>(), > std::bind2nd(std::less<Real>(), > target)); > Real x = result.first; > @@ -209,8 +209,8 @@ > > template <class S> > Real GenericRiskStatistics<S>::shortfall(Real target) const { > - QL_ENSURE(samples() != 0, "empty sample set"); > - return expectationValue(clip(constant<Real,Real>(1.0), > + QL_ENSURE(this->samples() != 0, "empty sample set"); > + return this->expectationValue(clip(constant<Real,Real>(1.0), > std::bind2nd(std::less<Real>(), > target)), > everywhere()).first; > @@ -220,7 +220,7 @@ > Real GenericRiskStatistics<S>::averageShortfall(Real target) > const { > std::pair<Real,Size> result = > - expectationValue(std::bind1st(std::minus<Real>(), > + this->expectationValue(std::bind1st(std::minus<Real>(), > target), > std::bind2nd(std::less<Real>(), > target)); > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Barrier/mcbarrierengine.hpp ./ql/PricingEngines/Barrier/mcbarrierengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Barrier/mcbarrierengine.hpp 2004-05-17 18:40:06.000000000 +0200 > +++ ./ql/PricingEngines/Barrier/mcbarrierengine.hpp 2004-08-17 21:56:04.049592153 +0200 > @@ -174,7 +174,7 @@ > > // do this with template parameters? > if (isBiased_) { > - return boost::shared_ptr<MCBarrierEngine<RNG,S>::path_pricer_type>( > + return boost::shared_ptr<typename MCBarrierEngine<RNG,S>::path_pricer_type>( > new BiasedBarrierPathPricer( > arguments_.barrierType, > arguments_.barrier, > @@ -192,7 +192,7 @@ > RelinkableHandle<TermStructure> dividend(process->dividendYield()); > RelinkableHandle<BlackVolTermStructure> volatility( > process->blackVolatility()); > - return boost::shared_ptr<MCBarrierEngine<RNG,S>::path_pricer_type>( > + return boost::shared_ptr<typename MCBarrierEngine<RNG,S>::path_pricer_type>( > new BarrierPathPricer( > arguments_.barrierType, > arguments_.barrier, > @@ -231,16 +231,16 @@ > "not an European Option"); > > //! Initialize the one-factor Monte Carlo > - if (controlVariate_) { > + if (this->controlVariate_) { > > boost::shared_ptr<path_pricer_type> controlPP = > - controlPathPricer(); > + this->controlPathPricer(); > QL_REQUIRE(controlPP, > "engine does not provide " > "control variation path pricer"); > > boost::shared_ptr<PricingEngine> controlPE = > - controlPricingEngine(); > + this->controlPricingEngine(); > > QL_REQUIRE(controlPE, > "engine does not provide " > @@ -257,34 +257,34 @@ > controlPE->results()); > Real controlVariateValue = controlResults->value; > > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<SingleAsset<RNG>, S> >( > new MonteCarloModel<SingleAsset<RNG>, S>( > pathGenerator(), pathPricer(), stats_type(), > - antitheticVariate_, controlPP, > + this->antitheticVariate_, controlPP, > controlVariateValue)); > */ > } else { > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<SingleAsset<RNG>, S> >( > new MonteCarloModel<SingleAsset<RNG>, S>( > pathGenerator(), pathPricer(), S(), > - antitheticVariate_)); > + this->antitheticVariate_)); > } > > if (requiredTolerance_ != Null<Real>()) { > if (maxSamples_ != Null<Size>()) > - value(requiredTolerance_, maxSamples_); > + this->value(requiredTolerance_, maxSamples_); > else > - value(requiredTolerance_); > + this->value(requiredTolerance_); > } else { > - valueWithSamples(requiredSamples_); > + this->valueWithSamples(requiredSamples_); > } > > - results_.value = mcModel_->sampleAccumulator().mean(); > + results_.value = this->mcModel_->sampleAccumulator().mean(); > if (RNG::allowsErrorEstimate) > results_.errorEstimate = > - mcModel_->sampleAccumulator().errorEstimate(); > + this->mcModel_->sampleAccumulator().errorEstimate(); > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Basket/mcbasketengine.hpp ./ql/PricingEngines/Basket/mcbasketengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Basket/mcbasketengine.hpp 2004-05-13 18:30:08.000000000 +0200 > +++ ./ql/PricingEngines/Basket/mcbasketengine.hpp 2004-08-17 23:27:30.835473913 +0200 > @@ -144,7 +144,7 @@ > ->stateVariable()->value(); > } > > - return boost::shared_ptr<MCBasketEngine<RNG,S>::path_pricer_type>(new > + return boost::shared_ptr<typename MCBasketEngine<RNG,S>::path_pricer_type>(new > EuropeanMultiPathPricer( > arguments_.basketType, > payoff->optionType(), > @@ -179,16 +179,16 @@ > "not an European Option"); > */ > //! Initialize the multi-factor Monte Carlo > - if (controlVariate_) { > + if (this->controlVariate_) { > > boost::shared_ptr<path_pricer_type> controlPP = > - controlPathPricer(); > + this->controlPathPricer(); > QL_REQUIRE(controlPP, > "engine does not provide " > "control variation path pricer"); > > boost::shared_ptr<PricingEngine> controlPE = > - controlPricingEngine(); > + this->controlPricingEngine(); > > QL_REQUIRE(controlPE, > "engine does not provide " > @@ -205,34 +205,34 @@ > controlPE->results()); > Real controlVariateValue = controlResults->value; > > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<MultiAsset<RNG>, S> >( > new MonteCarloModel<MultiAsset<RNG>, S>( > pathGenerator(), pathPricer(), stats_type(), > - antitheticVariate_, controlPP, > + this->antitheticVariate_, controlPP, > controlVariateValue)); > > } else { > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<MultiAsset<RNG>, S> >( > new MonteCarloModel<MultiAsset<RNG>, S>( > pathGenerator(), pathPricer(), S(), > - antitheticVariate_)); > + this->antitheticVariate_)); > } > > if (requiredTolerance_ != Null<Real>()) { > if (maxSamples_ != Null<Size>()) > - value(requiredTolerance_, maxSamples_); > + this->value(requiredTolerance_, maxSamples_); > else > - value(requiredTolerance_); > + this->value(requiredTolerance_); > } else { > - valueWithSamples(requiredSamples_); > + this->valueWithSamples(requiredSamples_); > } > > - results_.value = mcModel_->sampleAccumulator().mean(); > + results_.value = this->mcModel_->sampleAccumulator().mean(); > if (RNG::allowsErrorEstimate) > results_.errorEstimate = > - mcModel_->sampleAccumulator().errorEstimate(); > + this->mcModel_->sampleAccumulator().errorEstimate(); > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Forward/forwardengine.hpp ./ql/PricingEngines/Forward/forwardengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Forward/forwardengine.hpp 2004-05-13 16:53:49.000000000 +0200 > +++ ./ql/PricingEngines/Forward/forwardengine.hpp 2004-08-17 21:57:49.015634889 +0200 > @@ -69,10 +69,10 @@ > QL_REQUIRE(moneyness > 0.0, "negative or zero moneyness given"); > > QL_REQUIRE(resetDate != Null<Date>(), "null reset date given"); > - QL_REQUIRE(resetDate >= blackScholesProcess->riskFreeRate() > + QL_REQUIRE(resetDate >= this->blackScholesProcess->riskFreeRate() > ->referenceDate(), > "reset date later than settlement"); > - QL_REQUIRE(exercise->lastDate() > resetDate, > + QL_REQUIRE(this->exercise->lastDate() > resetDate, > "reset date later or equal to maturity"); > } > > @@ -95,15 +95,15 @@ > const { > > boost::shared_ptr<StrikedTypePayoff> argumentsPayoff = > - boost::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff); > + boost::dynamic_pointer_cast<StrikedTypePayoff>(this->arguments_.payoff); > QL_REQUIRE(argumentsPayoff, "wrong payoff given"); > > const boost::shared_ptr<BlackScholesProcess>& process = > - arguments_.blackScholesProcess; > + this->arguments_.blackScholesProcess; > > boost::shared_ptr<StrikedTypePayoff> payoff( > new PlainVanillaPayoff(argumentsPayoff->optionType(), > - arguments_.moneyness * > + this->arguments_.moneyness * > process->stateVariable()->value())); > originalArguments_->payoff = payoff; > > @@ -115,14 +115,14 @@ > boost::shared_ptr<TermStructure>( > new ImpliedTermStructure( > RelinkableHandle<TermStructure>(process->dividendYield()), > - arguments_.resetDate, > - arguments_.resetDate))); > + this->arguments_.resetDate, > + this->arguments_.resetDate))); > RelinkableHandle<TermStructure> riskFreeRate( > boost::shared_ptr<TermStructure>( > new ImpliedTermStructure( > RelinkableHandle<TermStructure>(process->riskFreeRate()), > - arguments_.resetDate, > - arguments_.resetDate))); > + this->arguments_.resetDate, > + this->arguments_.resetDate))); > // The following approach is ok if the vol is at most > // time dependant. It is plain wrong if it is asset dependant. > // In the latter case the right solution would be stochastic > @@ -133,14 +133,14 @@ > new ImpliedVolTermStructure( > RelinkableHandle<BlackVolTermStructure>( > process->blackVolatility()), > - arguments_.resetDate))); > + this->arguments_.resetDate))); > > originalArguments_->blackScholesProcess = > boost::shared_ptr<BlackScholesProcess>( > new BlackScholesProcess(spot, dividendYield, > riskFreeRate, blackVolatility)); > > - originalArguments_->exercise = arguments_.exercise; > + originalArguments_->exercise = this->arguments_.exercise; > > originalArguments_->validate(); > } > @@ -158,25 +158,25 @@ > const { > > const boost::shared_ptr<BlackScholesProcess>& process = > - arguments_.blackScholesProcess; > + this->arguments_.blackScholesProcess; > > Time resetTime = process->riskFreeRate()->dayCounter().yearFraction( > process->riskFreeRate()->referenceDate(), > - arguments_.resetDate); > + this->arguments_.resetDate); > DiscountFactor discQ = process->dividendYield()->discount( > - arguments_.resetDate); > + this->arguments_.resetDate); > > - results_.value = discQ * originalResults_->value; > + this->results_.value = discQ * originalResults_->value; > // I need the strike derivative here ... > - results_.delta = discQ * (originalResults_->delta + > - arguments_.moneyness * originalResults_->strikeSensitivity); > - results_.gamma = 0.0; > - results_.theta = process->dividendYield()->zeroYield( > - arguments_.resetDate) > - * results_.value; > - results_.vega = discQ * originalResults_->vega; > - results_.rho = discQ * originalResults_->rho; > - results_.dividendRho = - resetTime * results_.value > + this->results_.delta = discQ * (originalResults_->delta + > + this->arguments_.moneyness * originalResults_->strikeSensitivity); > + this->results_.gamma = 0.0; > + this->results_.theta = process->dividendYield()->zeroYield( > + this->arguments_.resetDate) > + * this->results_.value; > + this->results_.vega = discQ * originalResults_->vega; > + this->results_.rho = discQ * originalResults_->rho; > + this->results_.dividendRho = - resetTime * this->results_.value > + discQ * originalResults_->dividendRho; > } > > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Forward/forwardperformanceengine.hpp ./ql/PricingEngines/Forward/forwardperformanceengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Forward/forwardperformanceengine.hpp 2004-05-13 16:53:49.000000000 +0200 > +++ ./ql/PricingEngines/Forward/forwardperformanceengine.hpp 2004-08-18 00:06:48.855000457 +0200 > @@ -52,8 +52,8 @@ > void ForwardPerformanceEngine<ArgumentsType, ResultsType>::calculate() > const { > > - setOriginalArguments(); > - originalEngine_->calculate(); > + this->setOriginalArguments(); > + this->originalEngine_->calculate(); > getOriginalResults(); > } > > @@ -62,27 +62,27 @@ > getOriginalResults() const { > > const boost::shared_ptr<BlackScholesProcess>& process = > - arguments_.blackScholesProcess; > + this->arguments_.blackScholesProcess; > > Time resetTime = process->riskFreeRate()->dayCounter().yearFraction( > process->riskFreeRate()->referenceDate(), > - arguments_.resetDate); > + this->arguments_.resetDate); > DiscountFactor discR = > - process->riskFreeRate()->discount(arguments_.resetDate); > + process->riskFreeRate()->discount(this->arguments_.resetDate); > // it's a performance option > discR /= process->stateVariable()->value(); > > - Real temp = originalResults_->value; > - results_.value = discR * temp; > - results_.delta = 0.0; > - results_.gamma = 0.0; > - results_.theta = process->riskFreeRate()->zeroYield( > - arguments_.resetDate) > - * results_.value; > - results_.vega = discR * originalResults_->vega; > - results_.rho = - resetTime * results_.value + > - discR * originalResults_->rho; > - results_.dividendRho = discR * originalResults_->dividendRho; > + Real temp = this->originalResults_->value; > + this->results_.value = discR * temp; > + this->results_.delta = 0.0; > + this->results_.gamma = 0.0; > + this->results_.theta = process->riskFreeRate()->zeroYield( > + this->arguments_.resetDate) > + * this->results_.value; > + this->results_.vega = discR * this->originalResults_->vega; > + this->results_.rho = - resetTime * this->results_.value + > + discR * this->originalResults_->rho; > + this->results_.dividendRho = discR * this->originalResults_->dividendRho; > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Quanto/quantoengine.hpp ./ql/PricingEngines/Quanto/quantoengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Quanto/quantoengine.hpp 2004-05-13 16:53:50.000000000 +0200 > +++ ./ql/PricingEngines/Quanto/quantoengine.hpp 2004-08-17 21:56:04.052591697 +0200 > @@ -117,14 +117,14 @@ > > // determine strike from payoff > boost::shared_ptr<StrikedTypePayoff> payoff = > - boost::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff); > + boost::dynamic_pointer_cast<StrikedTypePayoff>(this->arguments_.payoff); > QL_REQUIRE(payoff, "non-striked payoff given"); > Real strike = payoff->strike(); > > - originalArguments_->payoff = arguments_.payoff; > + originalArguments_->payoff = this->arguments_.payoff; > > const boost::shared_ptr<BlackScholesProcess>& process = > - arguments_.blackScholesProcess; > + this->arguments_.blackScholesProcess; > > RelinkableHandle<Quote> spot(process->stateVariable()); > RelinkableHandle<TermStructure> riskFreeRate(process->riskFreeRate()); > @@ -134,11 +134,11 @@ > new QuantoTermStructure( > RelinkableHandle<TermStructure>(process->dividendYield()), > RelinkableHandle<TermStructure>(process->riskFreeRate()), > - arguments_.foreignRiskFreeTS, > + this->arguments_.foreignRiskFreeTS, > RelinkableHandle<BlackVolTermStructure>( > process->blackVolatility()), > - strike, arguments_.exchRateVolTS, exchangeRateATMlevel, > - arguments_.correlation))); > + strike, this->arguments_.exchRateVolTS, exchangeRateATMlevel, > + this->arguments_.correlation))); > RelinkableHandle<BlackVolTermStructure> blackVol( > process->blackVolatility()); > originalArguments_->blackScholesProcess = > @@ -146,36 +146,36 @@ > new BlackScholesProcess(spot, dividendYield, > riskFreeRate, blackVol)); > > - originalArguments_->exercise = arguments_.exercise; > + originalArguments_->exercise = this->arguments_.exercise; > > originalArguments_->validate(); > originalEngine_->calculate(); > > - results_.value = originalResults_->value; > - results_.delta = originalResults_->delta; > - results_.gamma = originalResults_->gamma; > - results_.theta = originalResults_->theta; > - results_.rho = originalResults_->rho + > + this->results_.value = originalResults_->value; > + this->results_.delta = originalResults_->delta; > + this->results_.gamma = originalResults_->gamma; > + this->results_.theta = originalResults_->theta; > + this->results_.rho = originalResults_->rho + > originalResults_->dividendRho; > - results_.dividendRho = originalResults_->dividendRho; > - Volatility exchangeRateFlatVol = arguments_.exchRateVolTS->blackVol( > - arguments_.exercise->lastDate(), > + this->results_.dividendRho = originalResults_->dividendRho; > + Volatility exchangeRateFlatVol = this->arguments_.exchRateVolTS->blackVol( > + this->arguments_.exercise->lastDate(), > exchangeRateATMlevel); > - results_.vega = originalResults_->vega + > - arguments_.correlation * exchangeRateFlatVol * > + this->results_.vega = originalResults_->vega + > + this->arguments_.correlation * exchangeRateFlatVol * > originalResults_->dividendRho; > > > Volatility volatility = process->blackVolatility()->blackVol( > - arguments_.exercise->lastDate(), > + this->arguments_.exercise->lastDate(), > process->stateVariable()->value()); > - results_.qvega = + arguments_.correlation > + this->results_.qvega = + this->arguments_.correlation > * process->blackVolatility()->blackVol( > - arguments_.exercise->lastDate(), > + this->arguments_.exercise->lastDate(), > process->stateVariable()->value()) * > originalResults_->dividendRho; > - results_.qrho = - originalResults_->dividendRho; > - results_.qlambda = exchangeRateFlatVol * > + this->results_.qrho = - originalResults_->dividendRho; > + this->results_.qlambda = exchangeRateFlatVol * > volatility * originalResults_->dividendRho; > } > > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mcdigitalengine.hpp ./ql/PricingEngines/Vanilla/mcdigitalengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mcdigitalengine.hpp 2004-05-17 18:40:10.000000000 +0200 > +++ ./ql/PricingEngines/Vanilla/mcdigitalengine.hpp 2004-08-17 23:40:24.356880785 +0200 > @@ -154,25 +154,25 @@ > MCDigitalEngine<RNG,S>::pathPricer() const { > > boost::shared_ptr<CashOrNothingPayoff> payoff = > - boost::dynamic_pointer_cast<CashOrNothingPayoff>(arguments_.payoff); > + boost::dynamic_pointer_cast<CashOrNothingPayoff>(this->arguments_.payoff); > QL_REQUIRE(payoff, "wrong payoff given"); > > boost::shared_ptr<AmericanExercise> exercise = > - boost::dynamic_pointer_cast<AmericanExercise>(arguments_.exercise); > + boost::dynamic_pointer_cast<AmericanExercise>(this->arguments_.exercise); > QL_REQUIRE(exercise, "wrong exercise given"); > > TimeGrid grid = timeGrid(); > PseudoRandom::ursg_type sequenceGen(grid.size()-1, > PseudoRandom::urng_type(76)); > > - return boost::shared_ptr<MCDigitalEngine<RNG,S>::path_pricer_type>(new > + return boost::shared_ptr<typename MCDigitalEngine<RNG,S>::path_pricer_type>(new > DigitalPathPricer( > payoff, > exercise, > - arguments_.blackScholesProcess->stateVariable()->value(), > + this->arguments_.blackScholesProcess->stateVariable()->value(), > RelinkableHandle<TermStructure>( > - arguments_.blackScholesProcess->riskFreeRate()), > - arguments_.blackScholesProcess, > + this->arguments_.blackScholesProcess->riskFreeRate()), > + this->arguments_.blackScholesProcess, > sequenceGen)); > } > > @@ -180,55 +180,55 @@ > template <class RNG, class S> > inline > TimeGrid MCDigitalEngine<RNG,S>::timeGrid() const { > - Time t = arguments_.blackScholesProcess->riskFreeRate() > + Time t = this->arguments_.blackScholesProcess->riskFreeRate() > ->dayCounter().yearFraction( > - arguments_.blackScholesProcess->riskFreeRate()->referenceDate(), > - arguments_.exercise->lastDate()); > - return TimeGrid(t, Size(QL_MAX<Real>(t * maxTimeStepsPerYear_, 1.0))); > + this->arguments_.blackScholesProcess->riskFreeRate()->referenceDate(), > + this->arguments_.exercise->lastDate()); > + return TimeGrid(t, Size(QL_MAX<Real>(t * this->maxTimeStepsPerYear_, 1.0))); > } > > template<class RNG, class S> > void MCDigitalEngine<RNG,S>::calculate() const { > > - QL_REQUIRE(requiredTolerance_ != Null<Real>() || > - requiredSamples_ != Null<Size>(), > + QL_REQUIRE(this->requiredTolerance_ != Null<Real>() || > + this->requiredSamples_ != Null<Size>(), > "neither tolerance nor number of samples set"); > > //! Initialize the one-factor Monte Carlo > - if (controlVariate_) { > + if (this->controlVariate_) { > > boost::shared_ptr<path_pricer_type> controlPP = > - controlPathPricer(); > + this->controlPathPricer(); > QL_REQUIRE(controlPP, > "engine does not provide " > "control variation path pricer"); > > boost::shared_ptr<PricingEngine> controlPE = > - controlPricingEngine(); > + this->controlPricingEngine(); > QL_REQUIRE(controlPE, > "engine does not provide " > "control variation pricing engine"); > } else { > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<SingleAsset<RNG>, S> >( > new MonteCarloModel<SingleAsset<RNG>, S>( > - pathGenerator(), pathPricer(), S(), > - antitheticVariate_)); > + this->pathGenerator(), this->pathPricer(), S(), > + this->antitheticVariate_)); > } > > - if (requiredTolerance_ != Null<Real>()) { > - if (maxSamples_ != Null<Size>()) > - value(requiredTolerance_, maxSamples_); > + if (this->requiredTolerance_ != Null<Real>()) { > + if (this->maxSamples_ != Null<Size>()) > + this->value(this->requiredTolerance_, this->maxSamples_); > else > - value(requiredTolerance_); > + this->value(this->requiredTolerance_); > } else { > - valueWithSamples(requiredSamples_); > + this->valueWithSamples(this->requiredSamples_); > } > > - results_.value = mcModel_->sampleAccumulator().mean(); > + this->results_.value = this->mcModel_->sampleAccumulator().mean(); > if (RNG::allowsErrorEstimate) > - results_.errorEstimate = > - mcModel_->sampleAccumulator().errorEstimate(); > + this->results_.errorEstimate = > + this->mcModel_->sampleAccumulator().errorEstimate(); > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mceuropeanengine.hpp ./ql/PricingEngines/Vanilla/mceuropeanengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mceuropeanengine.hpp 2004-06-08 15:50:41.000000000 +0200 > +++ ./ql/PricingEngines/Vanilla/mceuropeanengine.hpp 2004-08-18 00:05:09.944037209 +0200 > @@ -113,16 +113,16 @@ > MCEuropeanEngine<RNG,S>::pathPricer() const { > > boost::shared_ptr<PlainVanillaPayoff> payoff = > - boost::dynamic_pointer_cast<PlainVanillaPayoff>(arguments_.payoff); > + boost::dynamic_pointer_cast<PlainVanillaPayoff>(this->arguments_.payoff); > QL_REQUIRE(payoff, "non-plain payoff given"); > > - return boost::shared_ptr<MCEuropeanEngine<RNG,S>::path_pricer_type>( > + return boost::shared_ptr<typename MCEuropeanEngine<RNG,S>::path_pricer_type>( > new EuropeanPathPricer( > payoff->optionType(), > - arguments_.blackScholesProcess->stateVariable()->value(), > + this->arguments_.blackScholesProcess->stateVariable()->value(), > payoff->strike(), > RelinkableHandle<TermStructure>( > - arguments_.blackScholesProcess->riskFreeRate()))); > + this->arguments_.blackScholesProcess->riskFreeRate()))); > } > > > @@ -159,13 +159,13 @@ > template <class RNG, class S> > inline TimeGrid MCEuropeanEngine<RNG,S>::timeGrid() const { > > - Time t = arguments_.blackScholesProcess->riskFreeRate() > + Time t = this->arguments_.blackScholesProcess->riskFreeRate() > ->dayCounter().yearFraction( > - arguments_.blackScholesProcess->riskFreeRate()->referenceDate(), > - arguments_.exercise->lastDate()); > + this->arguments_.blackScholesProcess->riskFreeRate()->referenceDate(), > + this->arguments_.exercise->lastDate()); > > - TimeGridCalculator calc(t, maxTimeStepsPerYear_); > - arguments_.blackScholesProcess->blackVolatility()->accept(calc); > + TimeGridCalculator calc(t, this->maxTimeStepsPerYear_); > + this->arguments_.blackScholesProcess->blackVolatility()->accept(calc); > return TimeGrid(t, calc.size()); > } > > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mcvanillaengine.hpp ./ql/PricingEngines/Vanilla/mcvanillaengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/Vanilla/mcvanillaengine.hpp 2004-05-13 18:30:09.000000000 +0200 > +++ ./ql/PricingEngines/Vanilla/mcvanillaengine.hpp 2004-08-17 23:35:40.933967617 +0200 > @@ -82,7 +82,7 @@ > boost::shared_ptr<QL_TYPENAME MCVanillaEngine<RNG,S>::path_generator_type> > MCVanillaEngine<RNG,S>::pathGenerator() const { > > - TimeGrid grid = timeGrid(); > + TimeGrid grid = this->timeGrid(); > typename RNG::rsg_type gen = > RNG::make_sequence_generator(grid.size()-1,seed_); > // BB here > @@ -103,16 +103,16 @@ > "not an European Option"); > > //! Initialize the one-factor Monte Carlo > - if (controlVariate_) { > + if (this->controlVariate_) { > > boost::shared_ptr<path_pricer_type> controlPP = > - controlPathPricer(); > + this->controlPathPricer(); > QL_REQUIRE(controlPP, > "engine does not provide " > "control variation path pricer"); > > boost::shared_ptr<PricingEngine> controlPE = > - controlPricingEngine(); > + this->controlPricingEngine(); > QL_REQUIRE(controlPE, > "engine does not provide " > "control variation pricing engine"); > @@ -128,34 +128,34 @@ > controlPE->results()); > Real controlVariateValue = controlResults->value; > > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<SingleAsset<RNG>, S> >( > new MonteCarloModel<SingleAsset<RNG>, S>( > - pathGenerator(), pathPricer(), stats_type(), > - antitheticVariate_, controlPP, > + pathGenerator(), this->pathPricer(), stats_type(), > + this->antitheticVariate_, controlPP, > controlVariateValue)); > > } else { > - mcModel_ = > + this->mcModel_ = > boost::shared_ptr<MonteCarloModel<SingleAsset<RNG>, S> >( > new MonteCarloModel<SingleAsset<RNG>, S>( > - pathGenerator(), pathPricer(), S(), > - antitheticVariate_)); > + pathGenerator(), this->pathPricer(), S(), > + this->antitheticVariate_)); > } > > if (requiredTolerance_ != Null<Real>()) { > if (maxSamples_ != Null<Size>()) > - value(requiredTolerance_, maxSamples_); > + this->value(requiredTolerance_, maxSamples_); > else > - value(requiredTolerance_); > + this->value(requiredTolerance_); > } else { > - valueWithSamples(requiredSamples_); > + this->valueWithSamples(requiredSamples_); > } > > - results_.value = mcModel_->sampleAccumulator().mean(); > + results_.value = this->mcModel_->sampleAccumulator().mean(); > if (RNG::allowsErrorEstimate) > results_.errorEstimate = > - mcModel_->sampleAccumulator().errorEstimate(); > + this->mcModel_->sampleAccumulator().errorEstimate(); > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/genericmodelengine.hpp ./ql/PricingEngines/genericmodelengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/genericmodelengine.hpp 2004-05-19 10:53:11.000000000 +0200 > +++ ./ql/PricingEngines/genericmodelengine.hpp 2004-08-17 21:53:38.708687329 +0200 > @@ -48,7 +48,7 @@ > update(); > } > virtual void update() { > - notifyObservers(); > + this->notifyObservers(); > } > protected: > boost::shared_ptr<ModelType> model_; > diff -urN ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/latticeshortratemodelengine.hpp ./ql/PricingEngines/latticeshortratemodelengine.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/PricingEngines/latticeshortratemodelengine.hpp 2004-03-25 17:52:28.000000000 +0100 > +++ ./ql/PricingEngines/latticeshortratemodelengine.hpp 2004-08-17 23:28:31.045320625 +0200 > @@ -62,15 +62,15 @@ > const TimeGrid& timeGrid) > : GenericModelEngine<ShortRateModel, Arguments, Results>(model), > timeGrid_(timeGrid), timeSteps_(0) { > - lattice_ = model_->tree(timeGrid); > + lattice_ = this->model_->tree(timeGrid); > } > > template <class Arguments, class Results> > void LatticeShortRateModelEngine<Arguments, Results>::update() > { > if (timeGrid_.size() > 0) > - lattice_ = model_->tree(timeGrid_); > - notifyObservers(); > + lattice_ = this->model_->tree(timeGrid_); > + this->notifyObservers(); > } > > } > diff -urN ../tmp-orig/quantlib-0.3.7/ql/solver1d.hpp ./ql/solver1d.hpp > --- ../tmp-orig/quantlib-0.3.7/ql/solver1d.hpp 2004-05-28 15:10:39.000000000 +0200 > +++ ./ql/solver1d.hpp 2004-08-17 21:54:32.632489665 +0200 > @@ -105,7 +105,7 @@ > if (fxMax_ == 0.0) return xMax_; > root_ = (xMax_+xMin_)/2.0; > // check whether we really want to pass epsilon > - return impl().solveImpl(f, QL_MAX(QL_FABS(accuracy), > + return this->impl().solveImpl(f, QL_MAX(QL_FABS(accuracy), > QL_EPSILON)); > } > if (QL_FABS(fxMin_) < QL_FABS(fxMax_)) { > @@ -197,7 +197,7 @@ > > root_ = guess; > > - return impl().solveImpl(f, QL_MAX(QL_FABS(accuracy), QL_EPSILON)); > + return this->impl().solveImpl(f, QL_MAX(QL_FABS(accuracy), QL_EPSILON)); > } > > /*! This method sets the maximum number of function > > -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx |
Andreas, Dirk,
thank you for the patch. This has been really a timely patch as I had few email exchanges yesterday with Luigi, about MS VC7 not compiling QuantLib with "Language extensions" disabled. Luigi replied that if gcc do compile QuantLib, then it was safe to assume that the code was standard-compliant. So gcc 3.4 is welcome :) Many (maybe all) the problems I had are solved with this patch. Luigi today is away, I will wait and synch with him to apply the patch. ciao -- Nando At 03:03 AM 8/18/2004, Dirk Eddelbuettel wrote: >Andreas, > > Thanks for the detailed bug report and patch. I think I won't make >a new release quite yet given how gcc / g++ 3.3 are still the default -- and >QuantLib may have a 0.3.8 release before we switch to 3.4. > >QuantLib crew, > > Haven't checked with CVS whether this is already in the sources; if >it isn't this may make a nice addition. > >Cheers, Dirk > >On Wed, Aug 18, 2004 at 12:28:16AM +0200, Andreas Jochens wrote: > > Package: quantlib > > Severity: normal > > Tags: patch > > > > With the attached patch 'quantlib' can be compiled using gcc-3.4. > > > > Regards > > Andreas Jochens |
On Thu, Aug 19, 2004 at 01:21:48PM +0200, Ferdinando Ametrano wrote:
> Andreas, Dirk, > > thank you for the patch. > > This has been really a timely patch as I had few email exchanges yesterday > with Luigi, about MS VC7 not compiling QuantLib with "Language extensions" > disabled. Luigi replied that if gcc do compile QuantLib, then it was safe > to assume that the code was standard-compliant. So gcc 3.4 is welcome :) > > Many (maybe all) the problems I had are solved with this patch. > > Luigi today is away, I will wait and synch with him to apply the patch. QuantLib 0.3.8 has been released, and uploaded to Debian, earlier today, so we can finally close this bug. Thanks again to Andreas for the report, and patch. Dirk > > ciao -- Nando > > At 03:03 AM 8/18/2004, Dirk Eddelbuettel wrote: > > >Andreas, > > > > Thanks for the detailed bug report and patch. I think I won't make > >a new release quite yet given how gcc / g++ 3.3 are still the default -- > >and > >QuantLib may have a 0.3.8 release before we switch to 3.4. > > > >QuantLib crew, > > > > Haven't checked with CVS whether this is already in the sources; if > >it isn't this may make a nice addition. > > > >Cheers, Dirk > > > >On Wed, Aug 18, 2004 at 12:28:16AM +0200, Andreas Jochens wrote: > >> Package: quantlib > >> Severity: normal > >> Tags: patch > >> > >> With the attached patch 'quantlib' can be compiled using gcc-3.4. > >> > >> Regards > >> Andreas Jochens > > -- If you don't go with R now, you will someday. -- David Kane on r-sig-finance, 30 Nov 2004 |
Free forum by Nabble | Edit this page |