Skip to content

Commit

Permalink
Automated fixes by clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and lballabio committed Feb 8, 2021
1 parent 20bf82e commit 129d85d
Show file tree
Hide file tree
Showing 51 changed files with 142 additions and 190 deletions.
16 changes: 6 additions & 10 deletions ql/cashflows/lineartsrpricer.hpp
Expand Up @@ -70,11 +70,7 @@ namespace QuantLib {

struct Settings {

Settings()
: strategy_(RateBound), vegaRatio_(0.01),
priceThreshold_(1.0E-8), stdDevs_(3.0),
lowerRateBound_(defaultLowerBound), upperRateBound_(defaultUpperBound),
defaultBounds_(true) {}
Settings() : lowerRateBound_(defaultLowerBound), upperRateBound_(defaultUpperBound) {}

Settings &withRateBound(const Real lowerRateBound = defaultLowerBound,
const Real upperRateBound = defaultUpperBound) {
Expand Down Expand Up @@ -152,12 +148,12 @@ namespace QuantLib {
BSStdDevs
};

Strategy strategy_;
Real vegaRatio_;
Real priceThreshold_;
Real stdDevs_;
Strategy strategy_ = RateBound;
Real vegaRatio_ = 0.01;
Real priceThreshold_ = 1.0E-8;
Real stdDevs_ = 3.0;
Real lowerRateBound_, upperRateBound_;
bool defaultBounds_;
bool defaultBounds_ = true;
};


Expand Down
3 changes: 1 addition & 2 deletions ql/experimental/commodities/energycommodity.cpp
Expand Up @@ -26,8 +26,7 @@
namespace QuantLib {


EnergyDailyPosition::EnergyDailyPosition()
: payLegPrice(0), receiveLegPrice(0), unrealized(false) {}
EnergyDailyPosition::EnergyDailyPosition() {}

EnergyDailyPosition::EnergyDailyPosition(const Date& date,
Real payLegPrice,
Expand Down
6 changes: 3 additions & 3 deletions ql/experimental/commodities/energycommodity.hpp
Expand Up @@ -37,10 +37,10 @@ namespace QuantLib {
struct EnergyDailyPosition {
Date date;
Real quantityAmount;
Real payLegPrice;
Real receiveLegPrice;
Real payLegPrice = 0;
Real receiveLegPrice = 0;
Real riskDelta;
bool unrealized;
bool unrealized = false;

EnergyDailyPosition();
EnergyDailyPosition(const Date& date,
Expand Down
5 changes: 2 additions & 3 deletions ql/experimental/commodities/quantity.hpp
Expand Up @@ -82,7 +82,7 @@ namespace QuantLib {
private:
CommodityType commodityType_;
UnitOfMeasure unitOfMeasure_;
Real amount_;
Real amount_ = 0.0;
};


Expand Down Expand Up @@ -122,8 +122,7 @@ namespace QuantLib {

// inline definitions

inline Quantity::Quantity()
: amount_(0.0) {}
inline Quantity::Quantity() {}

inline Quantity::Quantity(const CommodityType& commodityType,
const UnitOfMeasure& unitOfMeasure,
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/credit/defaultprobabilitykey.cpp
Expand Up @@ -55,7 +55,7 @@ namespace QuantLib {
return true;
}

DefaultProbKey::DefaultProbKey() : obligationCurrency_(Currency()), seniority_(NoSeniority) {}
DefaultProbKey::DefaultProbKey() : obligationCurrency_(Currency()) {}

DefaultProbKey::DefaultProbKey(const std::vector<ext::shared_ptr<DefaultType> >& eventTypes,
const Currency& cur,
Expand Down
3 changes: 2 additions & 1 deletion ql/experimental/credit/defaultprobabilitykey.hpp
Expand Up @@ -45,7 +45,8 @@ namespace QuantLib {
//! Currency of the bond and protection leg payment.
Currency obligationCurrency_;
//! Reference bonds seniority.
Seniority seniority_;
Seniority seniority_ = NoSeniority;

public:
DefaultProbKey();

Expand Down
11 changes: 4 additions & 7 deletions ql/experimental/math/convolvedstudentt.cpp
Expand Up @@ -36,13 +36,10 @@

namespace QuantLib {

CumulativeBehrensFisher::CumulativeBehrensFisher(
const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors
)
: degreesFreedom_(degreesFreedom), factors_(factors),
polyConvolved_(std::vector<Real>(1, 1.)), // value to start convolution
a_(0.)
CumulativeBehrensFisher::CumulativeBehrensFisher(const std::vector<Integer>& degreesFreedom,
const std::vector<Real>& factors)
: degreesFreedom_(degreesFreedom), factors_(factors), polyConvolved_(std::vector<Real>(1, 1.))

{
QL_REQUIRE(degreesFreedom.size() == factors.size(),
"Incompatible sizes in convolution.");
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/math/convolvedstudentt.hpp
Expand Up @@ -145,7 +145,7 @@ namespace QuantLib {
mutable std::vector<Real> polyConvolved_;

// cached factor in the exponential of the characteristic function
mutable Real a_, a2_;
mutable Real a_ = 0., a2_;
};


Expand Down
6 changes: 3 additions & 3 deletions ql/experimental/swaptions/irregularswap.hpp
Expand Up @@ -84,9 +84,9 @@ namespace QuantLib {
//! %Arguments for irregular-swap calculation
class IrregularSwap::arguments : public Swap::arguments {
public:
arguments() : type(Receiver){}
Type type;
arguments() {}
Type type = Receiver;


std::vector<Date> fixedResetDates;
std::vector<Date> fixedPayDates;
Expand Down
4 changes: 2 additions & 2 deletions ql/experimental/swaptions/irregularswaption.hpp
Expand Up @@ -83,9 +83,9 @@ namespace QuantLib {
class IrregularSwaption::arguments : public IrregularSwap::arguments,
public Option::arguments {
public:
arguments() : settlementType(IrregularSettlement::Physical) {}
arguments() {}
ext::shared_ptr<IrregularSwap> swap;
IrregularSettlement::Type settlementType;
IrregularSettlement::Type settlementType = IrregularSettlement::Physical;
void validate() const override;
};

Expand Down
9 changes: 4 additions & 5 deletions ql/instruments/cpiswap.hpp
Expand Up @@ -167,12 +167,11 @@ namespace QuantLib {
//! %Arguments for swap calculation
class CPISwap::arguments : public Swap::arguments {
public:
arguments() : type(Receiver),
nominal(Null<Real>()) {}
Type type;
Real nominal;
arguments() : nominal(Null<Real>()) {}
Type type = Receiver;
Real nominal;

void validate() const override;
void validate() const override;
};

//! %Results from swap calculation
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/floatfloatswap.hpp
Expand Up @@ -151,8 +151,8 @@ namespace QuantLib {
//! %Arguments for float float swap calculation
class FloatFloatSwap::arguments : public Swap::arguments {
public:
arguments() : type(VanillaSwap::Receiver) {}
VanillaSwap::Type type;
arguments() {}
VanillaSwap::Type type = VanillaSwap::Receiver;
std::vector<Real> nominal1, nominal2;

std::vector<Date> leg1ResetDates, leg1FixingDates, leg1PayDates;
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/nonstandardswap.hpp
Expand Up @@ -125,8 +125,8 @@ namespace QuantLib {
//! %Arguments for nonstandard swap calculation
class NonstandardSwap::arguments : public Swap::arguments {
public:
arguments() : type(VanillaSwap::Receiver) {}
VanillaSwap::Type type;
arguments() {}
VanillaSwap::Type type = VanillaSwap::Receiver;
std::vector<Real> fixedNominal, floatingNominal;

std::vector<Date> fixedResetDates;
Expand Down
4 changes: 2 additions & 2 deletions ql/instruments/swaption.hpp
Expand Up @@ -125,9 +125,9 @@ namespace QuantLib {
class Swaption::arguments : public VanillaSwap::arguments,
public Option::arguments {
public:
arguments() : settlementType(Settlement::Physical) {}
arguments() {}
ext::shared_ptr<VanillaSwap> swap;
Settlement::Type settlementType;
Settlement::Type settlementType = Settlement::Physical;
Settlement::Method settlementMethod;
void validate() const override;
};
Expand Down
5 changes: 2 additions & 3 deletions ql/instruments/vanillaswap.hpp
Expand Up @@ -135,9 +135,8 @@ namespace QuantLib {
//! %Arguments for simple swap calculation
class VanillaSwap::arguments : public Swap::arguments {
public:
arguments() : type(Receiver),
nominal(Null<Real>()) {}
Type type;
arguments() : nominal(Null<Real>()) {}
Type type = Receiver;
Real nominal;

std::vector<Date> fixedResetDates;
Expand Down
31 changes: 15 additions & 16 deletions ql/instruments/yearonyearinflationswap.hpp
Expand Up @@ -123,22 +123,21 @@ namespace QuantLib {
//! %Arguments for YoY swap calculation
class YearOnYearInflationSwap::arguments : public Swap::arguments {
public:
arguments() : type(Receiver),
nominal(Null<Real>()) {}
Type type;
Real nominal;

std::vector<Date> fixedResetDates;
std::vector<Date> fixedPayDates;
std::vector<Time> yoyAccrualTimes;
std::vector<Date> yoyResetDates;
std::vector<Date> yoyFixingDates;
std::vector<Date> yoyPayDates;

std::vector<Real> fixedCoupons;
std::vector<Spread> yoySpreads;
std::vector<Real> yoyCoupons;
void validate() const override;
arguments() : nominal(Null<Real>()) {}
Type type = Receiver;
Real nominal;

std::vector<Date> fixedResetDates;
std::vector<Date> fixedPayDates;
std::vector<Time> yoyAccrualTimes;
std::vector<Date> yoyResetDates;
std::vector<Date> yoyFixingDates;
std::vector<Date> yoyPayDates;

std::vector<Real> fixedCoupons;
std::vector<Spread> yoySpreads;
std::vector<Real> yoyCoupons;
void validate() const override;
};

//! %Results from YoY swap calculation
Expand Down
4 changes: 2 additions & 2 deletions ql/math/interpolations/extrapolation.hpp
Expand Up @@ -31,7 +31,7 @@ namespace QuantLib {
//! base class for classes possibly allowing extrapolation
class Extrapolator {
public:
Extrapolator() : extrapolate_(false) {}
Extrapolator() {}
virtual ~Extrapolator() {}
//! \name modifiers
//@{
Expand All @@ -46,7 +46,7 @@ namespace QuantLib {
bool allowsExtrapolation() const { return extrapolate_; }
//@}
private:
bool extrapolate_;
bool extrapolate_ = false;
};

}
Expand Down
4 changes: 2 additions & 2 deletions ql/math/matrix.hpp
Expand Up @@ -144,7 +144,7 @@ namespace QuantLib {
//@}
private:
boost::scoped_array<Real> data_;
Size rows_, columns_;
Size rows_ = 0, columns_ = 0;
};

// algebraic operators
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace QuantLib {

// inline definitions

inline Matrix::Matrix() : data_((Real*)nullptr), rows_(0), columns_(0) {}
inline Matrix::Matrix() : data_((Real*)nullptr) {}

inline Matrix::Matrix(Size rows, Size columns)
: data_(rows * columns > 0 ? new Real[rows * columns] : (Real*)nullptr), rows_(rows),
Expand Down
33 changes: 13 additions & 20 deletions ql/math/ode/adaptiverungekutta.hpp
Expand Up @@ -50,21 +50,13 @@ namespace QuantLib {
- hmin smallest step size allowed
*/

AdaptiveRungeKutta(const Real eps=1.0e-6,
const Real h1=1.0e-4,
const Real hmin=0.0)
: eps_(eps), h1_(h1), hmin_(hmin),
a2(0.2), a3(0.3), a4(0.6), a5(1.0), a6(0.875),
b21(0.2), b31(3.0/40.0), b32(9.0/40.0), b41(0.3), b42(-0.9), b43(1.2),
b51(-11.0/54.0), b52(2.5), b53(-70.0/27.0), b54(35.0/27.0),
b61(1631.0/55296.0), b62(175.0/512.0), b63(575.0/13824.0),
b64(44275.0/110592.0), b65(253.0/4096.0),
c1(37.0/378.0), c3(250.0/621.0), c4(125.0/594.0), c6(512.0/1771.0),
dc1(c1-2825.0/27648.0), dc3(c3-18575.0/48384.0),
dc4(c4-13525.0/55296.0), dc5(-277.0/14336.0), dc6(c6-0.25),
ADAPTIVERK_MAXSTP(10000), ADAPTIVERK_TINY(1.0E-30),
ADAPTIVERK_SAFETY(0.9), ADAPTIVERK_PGROW(-0.2),
ADAPTIVERK_PSHRINK(-0.25), ADAPTIVERK_ERRCON(1.89E-4) {}
AdaptiveRungeKutta(const Real eps = 1.0e-6, const Real h1 = 1.0e-4, const Real hmin = 0.0)
: eps_(eps), h1_(h1), hmin_(hmin), b31(3.0 / 40.0), b32(9.0 / 40.0), b51(-11.0 / 54.0),
b53(-70.0 / 27.0), b54(35.0 / 27.0), b61(1631.0 / 55296.0), b62(175.0 / 512.0),
b63(575.0 / 13824.0), b64(44275.0 / 110592.0), b65(253.0 / 4096.0), c1(37.0 / 378.0),
c3(250.0 / 621.0), c4(125.0 / 594.0), c6(512.0 / 1771.0), dc1(c1 - 2825.0 / 27648.0),
dc3(c3 - 18575.0 / 48384.0), dc4(c4 - 13525.0 / 55296.0), dc5(-277.0 / 14336.0),
dc6(c6 - 0.25) {}

/*! Integrate the ode from \f$ x1 \f$ to \f$ x2 \f$ with
initial value condition \f$ f(x1)=y1 \f$.
Expand Down Expand Up @@ -96,11 +88,12 @@ namespace QuantLib {

const std::vector<T> yStart_;
const Real eps_, h1_, hmin_;
const Real a2,a3,a4,a5,a6,
b21,b31,b32,b41,b42,b43,b51,b52,b53,b54,b61,b62,b63,b64,b65,
c1,c3,c4,c6,dc1,dc3,dc4,dc5,dc6;
const double ADAPTIVERK_MAXSTP, ADAPTIVERK_TINY, ADAPTIVERK_SAFETY,
ADAPTIVERK_PGROW, ADAPTIVERK_PSHRINK, ADAPTIVERK_ERRCON;
const Real a2 = 0.2, a3 = 0.3, a4 = 0.6, a5 = 1.0, a6 = 0.875, b21 = 0.2, b31, b32,
b41 = 0.3, b42 = -0.9, b43 = 1.2, b51, b52 = 2.5, b53, b54, b61, b62, b63, b64,
b65, c1, c3, c4, c6, dc1, dc3, dc4, dc5, dc6;
const double ADAPTIVERK_MAXSTP = 10000, ADAPTIVERK_TINY = 1.0E-30, ADAPTIVERK_SAFETY = 0.9,
ADAPTIVERK_PGROW = -0.2, ADAPTIVERK_PSHRINK = -0.25,
ADAPTIVERK_ERRCON = 1.89E-4;
};


Expand Down
26 changes: 10 additions & 16 deletions ql/math/optimization/differentialevolution.hpp
Expand Up @@ -75,30 +75,24 @@ namespace QuantLib {

struct Candidate {
Array values;
Real cost;
Candidate(Size size = 0) : values(size, 0.0), cost(0.0) {}
Real cost = 0.0;
Candidate(Size size = 0) : values(size, 0.0) {}
};

class Configuration {
public:
Strategy strategy;
CrossoverType crossoverType;
Size populationMembers;
Real stepsizeWeight, crossoverProbability;
unsigned long seed;
bool applyBounds, crossoverIsAdaptive;
Strategy strategy = BestMemberWithJitter;
CrossoverType crossoverType = Normal;
Size populationMembers = 100;
Real stepsizeWeight = 0.2, crossoverProbability = 0.9;
unsigned long seed = 0;
bool applyBounds = true, crossoverIsAdaptive = false;
std::vector<Array> initialPopulation;
Array upperBound, lowerBound;

Configuration()
: strategy(BestMemberWithJitter),
crossoverType(Normal),
populationMembers(100),
stepsizeWeight(0.2),
crossoverProbability(0.9),
seed(0),
applyBounds(true),
crossoverIsAdaptive(false) {}

{}

Configuration& withBounds(bool b = true) {
applyBounds = b;
Expand Down
4 changes: 2 additions & 2 deletions ql/math/optimization/levenbergmarquardt.cpp
Expand Up @@ -29,8 +29,8 @@ namespace QuantLib {
Real xtol,
Real gtol,
bool useCostFunctionsJacobian)
: info_(0), epsfcn_(epsfcn), xtol_(xtol), gtol_(gtol),
useCostFunctionsJacobian_(useCostFunctionsJacobian) {}
: epsfcn_(epsfcn), xtol_(xtol), gtol_(gtol),
useCostFunctionsJacobian_(useCostFunctionsJacobian) {}

Integer LevenbergMarquardt::getInfo() const {
return info_;
Expand Down
2 changes: 1 addition & 1 deletion ql/math/optimization/levenbergmarquardt.hpp
Expand Up @@ -72,7 +72,7 @@ namespace QuantLib {
Problem* currentProblem_;
Array initCostValues_;
Matrix initJacobian_;
mutable Integer info_;
mutable Integer info_ = 0;
const Real epsfcn_, xtol_, gtol_;
bool useCostFunctionsJacobian_;
};
Expand Down

0 comments on commit 129d85d

Please sign in to comment.