From 532cd3400b39704e74a805f0bb9651216ad7d55b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 21 May 2020 21:31:26 +0200 Subject: [PATCH] Apply fixes by clang-tidy --- Examples/GlobalOptimizer/GlobalOptimizer.cpp | 6 +- ql/cashflow.cpp | 3 +- ql/cashflows/averagebmacoupon.cpp | 2 +- ql/cashflows/capflooredinflationcoupon.cpp | 22 +- ql/cashflows/cashflows.cpp | 28 +- ql/cashflows/conundrumpricer.hpp | 6 +- ql/cashflows/couponpricer.cpp | 6 +- ql/cashflows/cpicoupon.hpp | 2 +- ql/cashflows/digitalcoupon.hpp | 4 +- ql/cashflows/floatingratecoupon.cpp | 4 +- ql/cashflows/inflationcoupon.cpp | 4 +- ql/cashflows/inflationcouponpricer.cpp | 2 +- ql/cashflows/lineartsrpricer.hpp | 4 +- ql/event.cpp | 6 +- .../amortizingfixedratebond.hpp | 21 +- .../perturbativebarrieroptionengine.cpp | 8 +- .../barrieroption/vannavolgabarrierengine.cpp | 58 +- .../barrieroption/vannavolgabarrierengine.hpp | 18 +- ql/experimental/basismodels/swaptioncfs.cpp | 2 +- .../basismodels/tenoroptionletvts.hpp | 2 +- .../callablebonds/callablebond.cpp | 2 +- .../callablebonds/treecallablebondengine.cpp | 4 +- .../callablebonds/treecallablebondengine.hpp | 7 +- .../catbonds/montecarlocatbondengine.cpp | 7 +- .../catbonds/montecarlocatbondengine.hpp | 45 +- ql/experimental/commodities/commodity.cpp | 6 +- .../commodities/commoditycashflow.cpp | 2 +- .../commodities/energybasisswap.cpp | 4 +- .../commodities/energycommodity.cpp | 4 +- ql/experimental/commodities/energyswap.cpp | 2 +- .../commodities/energyvanillaswap.cpp | 2 +- .../unitofmeasureconversionmanager.cpp | 3 +- .../convertiblebonds/convertiblebond.cpp | 2 +- .../coupons/lognormalcmsspreadpricer.hpp | 18 +- ql/experimental/coupons/swapspreadindex.hpp | 4 +- ql/experimental/credit/basket.cpp | 8 +- ql/experimental/credit/basket.hpp | 16 +- ql/experimental/credit/defaultevent.cpp | 5 +- .../credit/defaultprobabilitykey.cpp | 5 +- .../credit/defaultprobabilitykey.hpp | 5 +- .../interpolatedaffinehazardratecurve.hpp | 44 +- ql/experimental/credit/onefactorcopula.cpp | 4 +- .../credit/randomdefaultlatentmodel.hpp | 32 +- ql/experimental/credit/recursivelossmodel.hpp | 57 +- ql/experimental/credit/riskyassetswap.cpp | 2 +- .../credit/spotlosslatentmodel.hpp | 4 +- ql/experimental/credit/syntheticcdo.cpp | 13 +- .../continuousarithmeticasianvecerengine.cpp | 4 +- .../fdmblackscholesfwdop.cpp | 2 +- .../fdmexpextouinnervaluecalculator.hpp | 2 +- .../fdmextoujumpmodelinnervalue.hpp | 2 +- .../finitedifferences/fdmhestonfwdop.cpp | 6 +- .../finitedifferences/fdmvppstepcondition.cpp | 2 +- .../finitedifferences/fdmzabrop.hpp | 19 +- .../futures/overnightindexfuture.hpp | 15 +- .../overnightindexfutureratehelper.hpp | 51 +- .../interpolatedyoyoptionletstripper.hpp | 7 +- ...erpolatedyoyoptionletvolatilitysurface.hpp | 20 +- .../inflation/yoycapfloortermpricesurface.hpp | 32 +- .../inflation/yoyoptionletstripper.hpp | 7 +- .../lattices/extendedbinomialtree.cpp | 28 +- ql/experimental/math/convolvedstudentt.hpp | 22 +- ql/experimental/math/fireflyalgorithm.cpp | 2 +- ...gaussiannoncentralchisquaredpolynomial.cpp | 2 +- .../math/hybridsimulatedannealing.hpp | 37 +- .../math/hybridsimulatedannealingfunctors.hpp | 4 +- ql/experimental/math/laplaceinterpolation.hpp | 2 - ql/experimental/math/latentmodel.hpp | 6 +- .../math/particleswarmoptimization.hpp | 12 +- ql/experimental/math/piecewiseintegral.hpp | 6 +- .../mcbasket/pathmultiassetoption.cpp | 4 +- ql/experimental/models/hestonslvfdmmodel.hpp | 13 +- ql/experimental/models/hestonslvmcmodel.cpp | 2 +- ql/experimental/risk/creditriskplus.hpp | 14 +- ql/experimental/risk/sensitivityanalysis.cpp | 2 - .../shortrate/generalizedhullwhite.hpp | 3 +- .../haganirregularswaptionengine.cpp | 8 +- ql/experimental/swaptions/irregularswap.cpp | 4 +- .../integralhestonvarianceoptionengine.cpp | 2 +- .../volatility/abcdatmvolcurve.cpp | 14 +- ql/experimental/volatility/noarbsabr.hpp | 38 +- .../volatility/noarbsabrsmilesection.hpp | 16 +- .../volatility/sviinterpolation.hpp | 1 - .../volatility/svismilesection.cpp | 1 - ql/experimental/volatility/zabr.cpp | 4 +- ql/experimental/volatility/zabr.hpp | 25 +- .../volatility/zabrsmilesection.hpp | 22 +- ql/instrument.hpp | 4 +- ql/instruments/assetswap.cpp | 6 +- ql/instruments/bond.cpp | 2 +- ql/instruments/bonds/btp.cpp | 2 - ql/instruments/bonds/cpibond.hpp | 2 +- ql/instruments/bonds/fixedratebond.hpp | 8 +- ql/instruments/bonds/floatingratebond.hpp | 27 +- ql/instruments/capfloor.cpp | 2 +- ql/instruments/capfloor.hpp | 2 +- ql/instruments/cpiswap.cpp | 9 +- ql/instruments/creditdefaultswap.hpp | 10 +- ql/instruments/floatfloatswap.cpp | 78 +- ql/instruments/floatfloatswap.hpp | 82 ++- ql/instruments/floatfloatswaption.hpp | 9 +- ql/instruments/inflationcapfloor.hpp | 2 +- ql/instruments/makecds.cpp | 2 +- ql/instruments/makecds.hpp | 4 +- ql/instruments/makecms.cpp | 2 +- ql/instruments/makeswaption.hpp | 2 +- ql/instruments/nonstandardswap.cpp | 10 +- ql/instruments/nonstandardswap.hpp | 51 +- ql/instruments/nonstandardswaption.hpp | 9 +- ql/instruments/swap.cpp | 2 +- ql/instruments/vanillaswap.cpp | 6 +- ql/instruments/yearonyearinflationswap.cpp | 4 +- .../libormarketmodels/liborforwardmodel.cpp | 2 +- .../libormarketmodels/lmfixedvolmodel.cpp | 5 +- ql/math/array.hpp | 11 +- ql/math/initializers.hpp | 6 +- ql/math/integrals/discreteintegrals.cpp | 2 +- .../gaussianorthogonalpolynomial.cpp | 4 +- ql/math/interpolations/multicubicspline.hpp | 13 +- ql/math/interpolations/sabrinterpolation.hpp | 25 +- ql/math/matrixutilities/bicgstab.cpp | 10 +- ql/math/matrixutilities/gmres.cpp | 4 +- .../sparseilupreconditioner.cpp | 2 +- ql/math/ode/adaptiverungekutta.hpp | 25 +- ql/math/optimization/armijo.hpp | 4 +- ql/math/optimization/endcriteria.hpp | 30 +- ql/math/optimization/goldstein.hpp | 4 +- ql/math/optimization/linesearch.hpp | 2 +- ql/math/optimization/lmdif.cpp | 675 +++++++++--------- ql/math/optimization/lmdif.hpp | 14 +- ql/math/optimization/projection.cpp | 2 +- ql/math/optimization/simulatedannealing.hpp | 1 - ql/math/primenumbers.cpp | 2 +- ql/math/randomnumbers/haltonrsg.cpp | 2 +- ql/math/randomnumbers/knuthuniformrng.cpp | 20 +- ql/math/randomnumbers/mt19937uniformrng.cpp | 4 +- ql/math/randomnumbers/sobolrsg.cpp | 106 +-- ql/math/statistics/sequencestatistics.hpp | 4 +- .../meshers/concentrating1dmesher.hpp | 11 +- .../meshers/fdmblackscholesmesher.cpp | 21 +- .../meshers/fdmhestonvariancemesher.cpp | 2 +- .../operators/fdm2dblackscholesop.cpp | 4 +- .../operators/fdmblackscholesop.cpp | 6 +- .../operators/fdmhestonop.cpp | 2 +- .../operators/fdmlocalvolfwdop.cpp | 27 +- .../schemes/methodoflinesscheme.hpp | 8 +- .../solvers/fdm2dblackscholessolver.hpp | 15 +- .../solvers/fdm2dimsolver.cpp | 4 +- .../solvers/fdm3dimsolver.cpp | 6 +- .../solvers/fdmbackwardsolver.cpp | 27 +- .../solvers/fdmbackwardsolver.hpp | 11 +- .../solvers/fdmndimsolver.hpp | 2 +- .../fdmsimplestoragecondition.cpp | 4 +- .../finitedifferences/tridiagonaloperator.hpp | 2 +- .../utilities/fdmtimedepdirichletboundary.cpp | 5 +- ql/methods/lattices/binomialtree.cpp | 20 +- ql/methods/montecarlo/brownianbridge.cpp | 4 +- ql/methods/montecarlo/lsmbasissystem.cpp | 2 +- ql/models/equity/hestonmodelhelper.hpp | 14 +- .../correlations/expcorrelations.cpp | 2 +- ql/models/marketmodels/curvestate.hpp | 19 +- .../driftcomputation/lmmdriftcalculator.cpp | 21 +- .../lmmnormaldriftcalculator.cpp | 18 +- .../evolvers/lognormalcmswapratepc.hpp | 2 +- ql/models/marketmodels/models/abcdvol.hpp | 21 +- .../capletcoterminalalphacalibration.hpp | 9 +- .../models/capletcoterminalmaxhomogeneity.hpp | 29 +- .../models/capletcoterminalperiodic.cpp | 4 +- .../models/capletcoterminalperiodic.hpp | 37 +- .../marketmodels/models/fwdperiodadapter.cpp | 2 +- .../marketmodels/models/pseudorootfacade.hpp | 3 +- ql/models/marketmodels/pathwisediscounter.cpp | 3 - .../marketmodels/swapforwardmappings.hpp | 18 +- ql/models/model.cpp | 2 +- .../calibrationhelpers/caphelper.hpp | 8 +- .../calibrationhelpers/swaptionhelper.hpp | 36 +- .../onefactormodels/gaussian1dmodel.hpp | 112 +-- ql/models/shortrate/onefactormodels/gsr.hpp | 44 +- .../onefactormodels/markovfunctional.cpp | 83 +-- .../onefactormodels/markovfunctional.hpp | 151 ++-- ql/patterns/observable.cpp | 5 +- ql/patterns/observable.hpp | 6 +- ql/prices.hpp | 8 +- ql/pricingengines/americanpayoffatexpiry.cpp | 4 +- ql/pricingengines/americanpayoffathit.cpp | 4 +- .../asian/fdblackscholesasianengine.cpp | 13 +- .../barrier/analyticbinarybarrierengine.cpp | 4 +- .../basket/mcamericanbasketengine.cpp | 2 +- ql/pricingengines/basket/stulzengine.cpp | 4 +- .../bond/discountingbondengine.cpp | 7 +- .../capfloor/analyticcapfloorengine.cpp | 4 +- .../capfloor/treecapfloorengine.cpp | 4 +- .../credit/integralcdsengine.cpp | 9 +- ql/pricingengines/credit/isdacdsengine.cpp | 10 +- ql/pricingengines/credit/isdacdsengine.hpp | 15 +- .../credit/midpointcdsengine.cpp | 9 +- .../forward/replicatingvarianceswapengine.hpp | 4 +- .../lookback/mclookbackengine.cpp | 2 +- .../mclongstaffschwartzengine.hpp | 69 +- ql/pricingengines/swap/cvaswapengine.hpp | 15 +- .../swap/discountingswapengine.cpp | 7 +- ql/pricingengines/swap/discretizedswap.cpp | 1 + ql/pricingengines/swap/treeswapengine.cpp | 4 +- .../swaption/basketgeneratingengine.hpp | 13 +- .../gaussian1dfloatfloatswaptionengine.cpp | 31 +- .../gaussian1dfloatfloatswaptionengine.hpp | 10 +- .../gaussian1dnonstandardswaptionengine.hpp | 2 +- .../swaption/jamshidianswaptionengine.cpp | 2 +- .../swaption/treeswaptionengine.cpp | 4 +- .../vanilla/analytichestonengine.cpp | 67 +- .../vanilla/analytichestonengine.hpp | 10 +- .../vanilla/fddividendengine.hpp | 8 +- .../fdhestonhullwhitevanillaengine.cpp | 4 +- .../vanilla/fdhestonvanillaengine.cpp | 4 +- ql/pricingengines/vanilla/fdvanillaengine.cpp | 2 +- .../vanilla/hestonexpansionengine.hpp | 27 +- .../vanilla/mcamericanengine.cpp | 3 +- ql/processes/blackscholesprocess.cpp | 4 +- ql/processes/gsrprocess.hpp | 11 +- ql/processes/gsrprocesscore.hpp | 21 +- ql/processes/jointstochasticprocess.cpp | 2 +- ql/processes/mfstateprocess.cpp | 2 +- ql/rebatedexercise.hpp | 21 +- .../credit/defaultprobabilityhelpers.hpp | 55 +- ql/termstructures/inflation/seasonality.cpp | 2 +- ql/termstructures/inflation/seasonality.hpp | 53 +- ql/termstructures/inflationtermstructure.cpp | 2 +- ql/termstructures/inflationtermstructure.hpp | 36 +- .../volatility/atmadjustedsmilesection.hpp | 5 +- .../volatility/atmsmilesection.hpp | 3 +- .../andreasenhugevolatilityinterpl.cpp | 20 +- .../equityfx/hestonblackvolsurface.hpp | 3 +- .../volatility/gaussian1dsmilesection.hpp | 22 +- .../inflation/constantcpivolatility.hpp | 4 +- ...yinflationoptionletvolatilitystructure.hpp | 42 +- .../volatility/interpolatedsmilesection.hpp | 72 +- .../volatility/kahalesmilesection.hpp | 17 +- .../optionlet/optionletstripper.hpp | 11 +- .../optionlet/optionletstripper1.cpp | 18 +- .../optionlet/optionletstripper1.hpp | 19 +- .../sabrinterpolatedsmilesection.hpp | 74 +- .../volatility/sabrsmilesection.hpp | 4 +- ql/termstructures/volatility/smilesection.hpp | 8 +- .../volatility/smilesectionutils.cpp | 8 +- .../volatility/smilesectionutils.hpp | 11 +- .../swaption/cmsmarketcalibration.cpp | 55 +- .../swaption/cmsmarketcalibration.hpp | 20 +- .../swaption/gaussian1dswaptionvolatility.hpp | 13 +- .../swaption/swaptionconstantvol.hpp | 16 +- .../volatility/swaption/swaptionvolcube1.hpp | 24 +- .../volatility/swaption/swaptionvolmatrix.cpp | 10 +- .../volatility/swaption/swaptionvolmatrix.hpp | 88 ++- ql/termstructures/yield/bondhelpers.hpp | 52 +- .../yield/fittedbonddiscountcurve.hpp | 9 +- .../yield/nonlinearfittingmethods.cpp | 17 +- .../yield/nonlinearfittingmethods.hpp | 54 +- ql/termstructures/yield/oisratehelper.hpp | 32 +- ql/termstructures/yield/ratehelpers.cpp | 4 +- ql/time/asx.cpp | 5 +- ql/time/imm.cpp | 5 +- ql/time/period.cpp | 6 +- ql/time/schedule.cpp | 21 +- ql/time/schedule.hpp | 8 +- ql/utilities/dataparsers.cpp | 3 +- test-suite/blackformula.cpp | 1 - test-suite/fdmlinearop.cpp | 2 +- test-suite/hestonmodel.cpp | 9 +- test-suite/hestonslvmodel.cpp | 4 +- test-suite/hybridhestonhullwhiteprocess.cpp | 2 +- test-suite/inflationcpiswap.cpp | 6 +- test-suite/libormarketmodel.cpp | 3 +- test-suite/marketmodel.cpp | 2 +- test-suite/matrices.cpp | 2 +- test-suite/noarbsabr.cpp | 2 - test-suite/schedule.cpp | 2 +- test-suite/tracing.cpp | 2 +- test-suite/vpp.cpp | 5 +- 277 files changed, 2177 insertions(+), 2369 deletions(-) diff --git a/Examples/GlobalOptimizer/GlobalOptimizer.cpp b/Examples/GlobalOptimizer/GlobalOptimizer.cpp index cdcf23be375..928f270a716 100644 --- a/Examples/GlobalOptimizer/GlobalOptimizer.cpp +++ b/Examples/GlobalOptimizer/GlobalOptimizer.cpp @@ -162,7 +162,7 @@ class TestFunction : public CostFunction { int test(OptimizationMethod& method, CostFunction& f, const EndCriteria& endCriteria, const Array& start, const Constraint& constraint = Constraint(), const Array& optimum = Array()) { - QL_REQUIRE(start.size() > 0, "Input size needs to be at least 1"); + QL_REQUIRE(!start.empty(), "Input size needs to be at least 1"); std::cout << "Starting point: "; Constraint c; if (!constraint.empty()) @@ -177,9 +177,9 @@ int test(OptimizationMethod& method, CostFunction& f, const EndCriteria& endCrit std::cout << "Global optimum: "; Real optimVal = printFunction(p, optimum); if(std::abs(optimVal) < 1e-13) - return std::abs(val-optimVal) < 1e-6; + return static_cast(std::abs(val - optimVal) < 1e-6); else - return std::abs((val-optimVal)/optimVal) < 1e-6; + return static_cast(std::abs((val - optimVal) / optimVal) < 1e-6); } return 1; } diff --git a/ql/cashflow.cpp b/ql/cashflow.cpp index c9066babb38..263fa537626 100644 --- a/ql/cashflow.cpp +++ b/ql/cashflow.cpp @@ -42,7 +42,7 @@ namespace QuantLib { // specified in the settings (if any) boost::optional includeToday = Settings::instance().includeTodaysCashFlows(); - if (includeToday) + if (includeToday) // NOLINT(readability-implicit-bool-conversion) includeRefDate = *includeToday; } return Event::hasOccurred(refDate, includeRefDate); @@ -69,4 +69,3 @@ namespace QuantLib { } } - diff --git a/ql/cashflows/averagebmacoupon.cpp b/ql/cashflows/averagebmacoupon.cpp index bc70e57e082..317011930f2 100644 --- a/ql/cashflows/averagebmacoupon.cpp +++ b/ql/cashflows/averagebmacoupon.cpp @@ -45,7 +45,7 @@ namespace QuantLib { d1 = startDate, d2 = startDate; - QL_REQUIRE (fixingDates.size() > 0, "fixing date list empty"); + QL_REQUIRE(!fixingDates.empty(), "fixing date list empty"); QL_REQUIRE (index->valueDate(fixingDates.front()) <= startDate, "first fixing date valid after period start"); QL_REQUIRE (index->valueDate(fixingDates.back()) >= endDate, diff --git a/ql/cashflows/capflooredinflationcoupon.cpp b/ql/cashflows/capflooredinflationcoupon.cpp index d6754ab6a52..298682bc15f 100644 --- a/ql/cashflows/capflooredinflationcoupon.cpp +++ b/ql/cashflows/capflooredinflationcoupon.cpp @@ -80,15 +80,16 @@ namespace QuantLib { const ext::shared_ptr& pricer) { YoYInflationCoupon::setPricer(pricer); - if (underlying_) underlying_->setPricer(pricer); + if (underlying_ != 0) + underlying_->setPricer(pricer); } Rate CappedFlooredYoYInflationCoupon::rate() const { - Rate swapletRate = underlying_ ? underlying_->rate() : YoYInflationCoupon::rate(); + Rate swapletRate = underlying_ != 0 ? underlying_->rate() : YoYInflationCoupon::rate(); if(isFloored_ || isCapped_) { - if (underlying_) { + if (underlying_ != 0) { QL_REQUIRE(underlying_->pricer(), "pricer not set"); } else { QL_REQUIRE(pricer_, "pricer not set"); @@ -97,19 +98,14 @@ namespace QuantLib { Rate floorletRate = 0.; if(isFloored_) { - floorletRate = - underlying_ ? - underlying_->pricer()->floorletRate(effectiveFloor()) : - pricer()->floorletRate(effectiveFloor()) - ; + floorletRate = underlying_ != 0 ? + underlying_->pricer()->floorletRate(effectiveFloor()) : + pricer()->floorletRate(effectiveFloor()); } Rate capletRate = 0.; if(isCapped_) { - capletRate = - underlying_ ? - underlying_->pricer()->capletRate(effectiveCap()) : - pricer()->capletRate(effectiveCap()) - ; + capletRate = underlying_ != 0 ? underlying_->pricer()->capletRate(effectiveCap()) : + pricer()->capletRate(effectiveCap()); } return swapletRate + floorletRate - capletRate; diff --git a/ql/cashflows/cashflows.cpp b/ql/cashflows/cashflows.cpp index 5aa0e2d96f2..b612b0815ab 100644 --- a/ql/cashflows/cashflows.cpp +++ b/ql/cashflows/cashflows.cpp @@ -40,7 +40,7 @@ namespace QuantLib { Date d = Date::maxDate(); for (Size i=0; i c = ext::dynamic_pointer_cast(leg[i]); - if (c) + if (c != 0) d = std::min(d, c->accrualStartDate()); else d = std::min(d, leg[i]->date()); @@ -54,7 +54,7 @@ namespace QuantLib { Date d = Date::minDate(); for (Size i=0; i c = ext::dynamic_pointer_cast(leg[i]); - if (c) + if (c != 0) d = std::max(d, c->accrualEndDate()); else d = std::max(d, leg[i]->date()); @@ -239,7 +239,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->nominal(); } return 0.0; @@ -256,7 +256,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accrualStartDate(); } return Date(); @@ -273,7 +273,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accrualEndDate(); } return Date(); @@ -290,7 +290,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->referencePeriodStart(); } return Date(); @@ -307,7 +307,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->referencePeriodEnd(); } return Date(); @@ -324,7 +324,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accrualPeriod(); } return 0; @@ -341,7 +341,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accrualDays(); } return 0; @@ -361,7 +361,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accruedPeriod(settlementDate); } return 0; @@ -381,7 +381,7 @@ namespace QuantLib { Date paymentDate = (*cf)->date(); for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) return cp->accruedDays(settlementDate); } return 0; @@ -402,7 +402,7 @@ namespace QuantLib { Real result = 0.0; for (; cfdate()==paymentDate; ++cf) { ext::shared_ptr cp = ext::dynamic_pointer_cast(*cf); - if (cp) + if (cp != 0) result += cp->accruedAmount(settlementDate); } return result; @@ -585,7 +585,7 @@ namespace QuantLib { Date refStartDate, refEndDate; ext::shared_ptr coupon = ext::dynamic_pointer_cast(cashFlow); - if (coupon) { + if (coupon != 0) { refStartDate = coupon->referencePeriodStart(); refEndDate = coupon->referencePeriodEnd(); } else { @@ -599,7 +599,7 @@ namespace QuantLib { refEndDate = cashFlowDate; } - if (coupon && lastDate!=coupon->accrualStartDate()) { + if ((coupon != 0) && lastDate != coupon->accrualStartDate()) { Time couponPeriod = dc.yearFraction(coupon->accrualStartDate(), cashFlowDate, refStartDate, refEndDate); Time accruedPeriod = dc.yearFraction(coupon->accrualStartDate(), diff --git a/ql/cashflows/conundrumpricer.hpp b/ql/cashflows/conundrumpricer.hpp index ee3a4114489..cfa3785479d 100644 --- a/ql/cashflows/conundrumpricer.hpp +++ b/ql/cashflows/conundrumpricer.hpp @@ -284,9 +284,9 @@ namespace QuantLib { Option::Type optionType); Real operator()(Real x) const; protected: - Real functionF(const Real x) const; - Real firstDerivativeOfF(const Real x) const; - Real secondDerivativeOfF(const Real x) const; + Real functionF(Real x) const; + Real firstDerivativeOfF(Real x) const; + Real secondDerivativeOfF(Real x) const; Real strike() const; Real annuity() const; diff --git a/ql/cashflows/couponpricer.cpp b/ql/cashflows/couponpricer.cpp index 94512162e74..a17388cfa0a 100644 --- a/ql/cashflows/couponpricer.cpp +++ b/ql/cashflows/couponpricer.cpp @@ -225,13 +225,13 @@ namespace QuantLib { // we might end up here because a CappedFlooredCoupon // was directly constructed; we should then check // the underlying for consistency with the pricer - if (ext::dynamic_pointer_cast(c.underlying())) { + if (ext::dynamic_pointer_cast(c.underlying()) != 0) { QL_REQUIRE(ext::dynamic_pointer_cast(pricer_), "pricer not compatible with Ibor Coupon"); - } else if (ext::dynamic_pointer_cast(c.underlying())) { + } else if (ext::dynamic_pointer_cast(c.underlying()) != 0) { QL_REQUIRE(ext::dynamic_pointer_cast(pricer_), "pricer not compatible with CMS Coupon"); - } else if (ext::dynamic_pointer_cast(c.underlying())) { + } else if (ext::dynamic_pointer_cast(c.underlying()) != 0) { QL_REQUIRE(ext::dynamic_pointer_cast(pricer_), "pricer not compatible with CMS spread Coupon"); } diff --git a/ql/cashflows/cpicoupon.hpp b/ql/cashflows/cpicoupon.hpp index 58c87a72084..b506b67f006 100644 --- a/ql/cashflows/cpicoupon.hpp +++ b/ql/cashflows/cpicoupon.hpp @@ -179,7 +179,7 @@ namespace QuantLib { public: CPILeg(const Schedule& schedule, const ext::shared_ptr& index, - const Real baseCPI, + Real baseCPI, const Period& observationLag); CPILeg& withNotionals(Real notional); CPILeg& withNotionals(const std::vector& notionals); diff --git a/ql/cashflows/digitalcoupon.hpp b/ql/cashflows/digitalcoupon.hpp index f57ee6949b7..616edea8a7e 100644 --- a/ql/cashflows/digitalcoupon.hpp +++ b/ql/cashflows/digitalcoupon.hpp @@ -132,10 +132,10 @@ namespace QuantLib { void setPricer( const ext::shared_ptr& pricer) { - if (pricer_) + if (pricer_ != 0) unregisterWith(pricer_); pricer_ = pricer; - if (pricer_) + if (pricer_ != 0) registerWith(pricer_); update(); underlying_->setPricer(pricer); diff --git a/ql/cashflows/floatingratecoupon.cpp b/ql/cashflows/floatingratecoupon.cpp index 75d0751c60e..e0245793072 100644 --- a/ql/cashflows/floatingratecoupon.cpp +++ b/ql/cashflows/floatingratecoupon.cpp @@ -60,10 +60,10 @@ namespace QuantLib { void FloatingRateCoupon::setPricer( const ext::shared_ptr& pricer) { - if (pricer_) + if (pricer_ != 0) unregisterWith(pricer_); pricer_ = pricer; - if (pricer_) + if (pricer_ != 0) registerWith(pricer_); update(); } diff --git a/ql/cashflows/inflationcoupon.cpp b/ql/cashflows/inflationcoupon.cpp index 34c94ebba32..1668cee3d73 100644 --- a/ql/cashflows/inflationcoupon.cpp +++ b/ql/cashflows/inflationcoupon.cpp @@ -49,10 +49,10 @@ namespace QuantLib { void InflationCoupon::setPricer(const ext::shared_ptr& pricer) { QL_REQUIRE(checkPricerImpl(pricer),"pricer given is wrong type"); - if (pricer_) + if (pricer_ != 0) unregisterWith(pricer_); pricer_ = pricer; - if (pricer_) + if (pricer_ != 0) registerWith(pricer_); update(); } diff --git a/ql/cashflows/inflationcouponpricer.cpp b/ql/cashflows/inflationcouponpricer.cpp index a9d5d3c306c..2b0264853dc 100644 --- a/ql/cashflows/inflationcouponpricer.cpp +++ b/ql/cashflows/inflationcouponpricer.cpp @@ -28,7 +28,7 @@ namespace QuantLib { for (Size i=0; i c = ext::dynamic_pointer_cast(leg[i]); - if (c) + if (c != 0) c->setPricer(p); } } diff --git a/ql/cashflows/lineartsrpricer.hpp b/ql/cashflows/lineartsrpricer.hpp index 601febe8fb3..fdf2f6b80ab 100644 --- a/ql/cashflows/lineartsrpricer.hpp +++ b/ql/cashflows/lineartsrpricer.hpp @@ -189,8 +189,8 @@ namespace QuantLib { private: Real GsrG(const Date &d) const; - Real singularTerms(const Option::Type type, const Real strike) const; - Real integrand(const Real strike) const; + Real singularTerms(Option::Type type, Real strike) const; + Real integrand(Real strike) const; Real a_, b_; class integrand_f; diff --git a/ql/event.cpp b/ql/event.cpp index 9b346afcf15..644cc108008 100644 --- a/ql/event.cpp +++ b/ql/event.cpp @@ -28,9 +28,9 @@ namespace QuantLib { boost::optional includeRefDate) const { Date refDate = d != Date() ? d : Settings::instance().evaluationDate(); - bool includeRefDateEvent = - includeRefDate ? *includeRefDate : - Settings::instance().includeReferenceDateEvents(); + bool includeRefDateEvent = includeRefDate ? // NOLINT(readability-implicit-bool-conversion) + *includeRefDate : + Settings::instance().includeReferenceDateEvents(); if (includeRefDateEvent) return date() < refDate; else diff --git a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp index 5ebc6d2fde5..dc11dba33fc 100644 --- a/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp +++ b/ql/experimental/amortizingbonds/amortizingfixedratebond.hpp @@ -47,17 +47,16 @@ namespace QuantLib { daycount is only used for quoting/settlement purposes - not for calculating the coupons. */ - AmortizingFixedRateBond( - Natural settlementDays, - const Calendar& calendar, - Real faceAmount, - const Date& startDate, - const Period& bondTenor, - const Frequency& sinkingFrequency, - const Rate coupon, - const DayCounter& accrualDayCounter, - BusinessDayConvention paymentConvention = Following, - const Date& issueDate = Date()); + AmortizingFixedRateBond(Natural settlementDays, + const Calendar& calendar, + Real faceAmount, + const Date& startDate, + const Period& bondTenor, + const Frequency& sinkingFrequency, + Rate coupon, + const DayCounter& accrualDayCounter, + BusinessDayConvention paymentConvention = Following, + const Date& issueDate = Date()); Frequency frequency() const { return frequency_; } const DayCounter& dayCounter() const { return dayCounter_; } protected: diff --git a/ql/experimental/barrieroption/perturbativebarrieroptionengine.cpp b/ql/experimental/barrieroption/perturbativebarrieroptionengine.cpp index f262a58392a..ea3ea9ace6a 100644 --- a/ql/experimental/barrieroption/perturbativebarrieroptionengine.cpp +++ b/ql/experimental/barrieroption/perturbativebarrieroptionengine.cpp @@ -64,7 +64,7 @@ namespace QuantLib { Real c, Real gm); Real dvv(Real s,Real p,Real tt,Real a,Real b,Real gm); Real dff(Real s, Real p,Real tt,Real a,Real b,Real gm); - Real tvtl(int jj,Real limit[4],Real sigmarho[4],Real epsi); + Real tvtl(int jj, const Real limit[4], const Real sigmarho[4], Real epsi); Real BarrierUPD(Real kprice, Real stock, Real hbarr, Real taumin, Real taumax, int iord, int igm, @@ -783,8 +783,7 @@ namespace QuantLib { Real RUB, Real AR, Real RUC, int NUC)); - Real tvtl(int NU, Real limit[], Real sigmarho[],Real epsi) - { + Real tvtl(int NU, const Real limit[], const Real sigmarho[], Real epsi) { /* A function for computing trivariate normal and t-probabilities. @@ -886,7 +885,7 @@ namespace QuantLib { RUB = asin( R13 ); AR = asin( R23); RUC = SIGN( PT, AR ) - AR; - TVT = TVT + ADONET( ZRO, ONE, EPS, *TVTMFN)/( 4.0*PT ); + TVT = TVT + ADONET(ZRO, ONE, EPS, TVTMFN) / (4.0 * PT); } result = max( ZRO, min( TVT, ONE ) ); @@ -941,7 +940,6 @@ namespace QuantLib { SX = sin(X); CS = 1 - SX*SX; } - return; } // diff --git a/ql/experimental/barrieroption/vannavolgabarrierengine.cpp b/ql/experimental/barrieroption/vannavolgabarrierengine.cpp index 48edfa9a243..a9c5ced4e24 100644 --- a/ql/experimental/barrieroption/vannavolgabarrierengine.cpp +++ b/ql/experimental/barrieroption/vannavolgabarrierengine.cpp @@ -33,37 +33,33 @@ using std::sqrt; namespace QuantLib { - VannaVolgaBarrierEngine::VannaVolgaBarrierEngine( - const Handle& atmVol, - const Handle& vol25Put, - const Handle& vol25Call, - const Handle& spotFX, - const Handle& domesticTS, - const Handle& foreignTS, - const bool adaptVanDelta, - const Real bsPriceWithSmile - ) - : GenericEngine(), - atmVol_(atmVol), vol25Put_(vol25Put), vol25Call_(vol25Call), T_(atmVol_->maturity()), + VannaVolgaBarrierEngine::VannaVolgaBarrierEngine(const Handle& atmVol, + const Handle& vol25Put, + const Handle& vol25Call, + const Handle& spotFX, + const Handle& domesticTS, + const Handle& foreignTS, + const bool adaptVanDelta, + const Real bsPriceWithSmile) + : atmVol_(atmVol), vol25Put_(vol25Put), vol25Call_(vol25Call), T_(atmVol_->maturity()), spotFX_(spotFX), domesticTS_(domesticTS), foreignTS_(foreignTS), - adaptVanDelta_(adaptVanDelta), bsPriceWithSmile_(bsPriceWithSmile) - { - QL_REQUIRE(vol25Put_->delta() == -0.25, "25 delta put is required by vanna volga method"); - QL_REQUIRE(vol25Call_->delta() == 0.25, "25 delta call is required by vanna volga method"); - - QL_REQUIRE(vol25Put_->maturity() == vol25Call_->maturity() && vol25Put_->maturity() == atmVol_->maturity(), - "Maturity of 3 vols are not the same"); - - QL_REQUIRE(!domesticTS_.empty(), "domestic yield curve is not defined"); - QL_REQUIRE(!foreignTS_.empty(), "foreign yield curve is not defined"); - - registerWith(atmVol_); - registerWith(vol25Put_); - registerWith(vol25Call_); - registerWith(spotFX_); - registerWith(domesticTS_); - registerWith(foreignTS_); + adaptVanDelta_(adaptVanDelta), bsPriceWithSmile_(bsPriceWithSmile) { + QL_REQUIRE(vol25Put_->delta() == -0.25, "25 delta put is required by vanna volga method"); + QL_REQUIRE(vol25Call_->delta() == 0.25, "25 delta call is required by vanna volga method"); + + QL_REQUIRE(vol25Put_->maturity() == vol25Call_->maturity() && + vol25Put_->maturity() == atmVol_->maturity(), + "Maturity of 3 vols are not the same"); + + QL_REQUIRE(!domesticTS_.empty(), "domestic yield curve is not defined"); + QL_REQUIRE(!foreignTS_.empty(), "foreign yield curve is not defined"); + + registerWith(atmVol_); + registerWith(vol25Put_); + registerWith(vol25Call_); + registerWith(spotFX_); + registerWith(domesticTS_); + registerWith(foreignTS_); } void VannaVolgaBarrierEngine::calculate() const { @@ -337,7 +333,7 @@ namespace QuantLib { Real inPrice; //adapt Vanilla delta - if(adaptVanDelta_ == true){ + if (adaptVanDelta_) { outPrice += lambda*(bsPriceWithSmile_ - vanillaOption); //capfloored by (0, vanilla) outPrice = std::max(0.0, std::min(bsPriceWithSmile_, outPrice)); diff --git a/ql/experimental/barrieroption/vannavolgabarrierengine.hpp b/ql/experimental/barrieroption/vannavolgabarrierengine.hpp index fac8c506da5..96401640c33 100644 --- a/ql/experimental/barrieroption/vannavolgabarrierengine.hpp +++ b/ql/experimental/barrieroption/vannavolgabarrierengine.hpp @@ -41,16 +41,14 @@ namespace QuantLib { public: // Constructor - VannaVolgaBarrierEngine( - const Handle& atmVol, - const Handle& vol25Put, - const Handle& vol25Call, - const Handle& spotFX, - const Handle& domesticTS, - const Handle& foreignTS, - const bool adaptVanDelta = false, - const Real bsPriceWithSmile = 0.0 - ); + VannaVolgaBarrierEngine(const Handle& atmVol, + const Handle& vol25Put, + const Handle& vol25Call, + const Handle& spotFX, + const Handle& domesticTS, + const Handle& foreignTS, + bool adaptVanDelta = false, + Real bsPriceWithSmile = 0.0); void calculate() const; diff --git a/ql/experimental/basismodels/swaptioncfs.cpp b/ql/experimental/basismodels/swaptioncfs.cpp index b8e27291be5..a677f69ebd3 100644 --- a/ql/experimental/basismodels/swaptioncfs.cpp +++ b/ql/experimental/basismodels/swaptioncfs.cpp @@ -109,7 +109,7 @@ namespace QuantLib { fixedWeights_.push_back(fixedLeg_[k]->amount()); for (Size k = 0; k < fixedLeg_.size(); ++k) { ext::shared_ptr coupon = ext::dynamic_pointer_cast(fixedLeg_[k]); - if (coupon) + if (coupon != 0) annuityWeights_.push_back(coupon->nominal() * coupon->accrualPeriod()); } } diff --git a/ql/experimental/basismodels/tenoroptionletvts.hpp b/ql/experimental/basismodels/tenoroptionletvts.hpp index 1a7e021636b..3a13628ef50 100644 --- a/ql/experimental/basismodels/tenoroptionletvts.hpp +++ b/ql/experimental/basismodels/tenoroptionletvts.hpp @@ -52,7 +52,7 @@ namespace QuantLib { public: // constructor includes actual transformation details - TenorOptionletSmileSection(const TenorOptionletVTS& volTS, const Time optionTime); + TenorOptionletSmileSection(const TenorOptionletVTS& volTS, Time optionTime); // further SmileSection interface methods virtual Real minStrike() const { diff --git a/ql/experimental/callablebonds/callablebond.cpp b/ql/experimental/callablebonds/callablebond.cpp index 64deeef8228..af9350808ab 100644 --- a/ql/experimental/callablebonds/callablebond.cpp +++ b/ql/experimental/callablebonds/callablebond.cpp @@ -411,7 +411,7 @@ namespace QuantLib { if (!cashflows_[i]->hasOccurred(settlement,IncludeToday)) { ext::shared_ptr coupon = ext::dynamic_pointer_cast(cashflows_[i]); - if (coupon) + if (coupon != 0) // !!! return coupon->accruedAmount(settlement) / notional(settlement) * 100.0; diff --git a/ql/experimental/callablebonds/treecallablebondengine.cpp b/ql/experimental/callablebonds/treecallablebondengine.cpp index 8b594a66194..ae17d68a187 100644 --- a/ql/experimental/callablebonds/treecallablebondengine.cpp +++ b/ql/experimental/callablebonds/treecallablebondengine.cpp @@ -55,7 +55,7 @@ namespace QuantLib { ext::shared_ptr tsmodel = ext::dynamic_pointer_cast(*model_); - if (tsmodel) { + if (tsmodel != 0) { referenceDate = tsmodel->termStructure()->referenceDate(); dayCounter = tsmodel->termStructure()->dayCounter(); } else { @@ -68,7 +68,7 @@ namespace QuantLib { dayCounter); ext::shared_ptr lattice; - if (lattice_) { + if (lattice_ != 0) { lattice = lattice_; } else { std::vector