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 Aug 19, 2024
1 parent c627b3c commit af365f0
Show file tree
Hide file tree
Showing 24 changed files with 92 additions and 83 deletions.
18 changes: 9 additions & 9 deletions ql/experimental/basismodels/swaptioncfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ namespace QuantLib {
std::vector<Real> floatWeights_;

public:
inline const Leg& floatLeg() const { return floatLeg_; }
inline const std::vector<Real>& floatTimes() const { return floatTimes_; }
inline const std::vector<Real>& floatWeights() const { return floatWeights_; }
const Leg& floatLeg() const { return floatLeg_; }
const std::vector<Real>& floatTimes() const { return floatTimes_; }
const std::vector<Real>& floatWeights() const { return floatWeights_; }
IborLegCashFlows(const Leg& iborLeg,
const Handle<YieldTermStructure>& discountCurve,
bool contTenorSpread = true);
Expand All @@ -65,10 +65,10 @@ namespace QuantLib {
SwapCashFlows() = default;
; // allow default constructor which does nothing
// inspectors
inline const Leg& fixedLeg() const { return fixedLeg_; }
inline const std::vector<Real>& fixedTimes() const { return fixedTimes_; }
inline const std::vector<Real>& fixedWeights() const { return fixedWeights_; }
inline const std::vector<Real>& annuityWeights() const { return annuityWeights_; }
const Leg& fixedLeg() const { return fixedLeg_; }
const std::vector<Real>& fixedTimes() const { return fixedTimes_; }
const std::vector<Real>& fixedWeights() const { return fixedWeights_; }
const std::vector<Real>& annuityWeights() const { return annuityWeights_; }
};


Expand All @@ -84,8 +84,8 @@ namespace QuantLib {
SwaptionCashFlows() = default;
; // allow default constructor which does nothing
// inspectors
inline ext::shared_ptr<Swaption> swaption() const { return swaption_; }
inline const std::vector<Real>& exerciseTimes() const { return exerciseTimes_; }
ext::shared_ptr<Swaption> swaption() const { return swaption_; }
const std::vector<Real>& exerciseTimes() const { return exerciseTimes_; }
};


Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/math/fireflyalgorithm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace QuantLib {
std::vector<Array> *xI_;

virtual Real intensityImpl(Real valueX, Real valueY, Real distance) = 0;
inline Real distance(const Array& x, const Array& y) const {
Real distance(const Array& x, const Array& y) const {
Real d = 0.0;
for (Size i = 0; i < N_; i++) {
Real diff = x[i] - y[i];
Expand Down
3 changes: 2 additions & 1 deletion ql/experimental/math/hybridsimulatedannealing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Mathl. Comput. Modelling, 967-973, 1989
#include <ql/math/optimization/constraint.hpp>
#include <ql/math/optimization/levenbergmarquardt.hpp>
#include <ql/math/optimization/problem.hpp>
#include <ql/shared_ptr.hpp>
#include <utility>

namespace QuantLib {
Expand Down Expand Up @@ -97,7 +98,7 @@ namespace QuantLib {
localOptimizer_(localOptimizer),
optimizeScheme_(localOptimizer != nullptr ? optimizeScheme : NoLocalOptimize) {
if (!localOptimizer)
localOptimizer.reset(new LevenbergMarquardt);
localOptimizer = ext::make_shared<LevenbergMarquardt>();
}

EndCriteria::Type minimize(Problem& P, const EndCriteria& endCriteria) override;
Expand Down
36 changes: 18 additions & 18 deletions ql/experimental/math/hybridsimulatedannealingfunctors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace QuantLib
explicit SamplerLogNormal(unsigned long seed = SeedGenerator::instance().get()) :
generator_(seed), distribution_(0.0, 1.0) {};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
for (Size i = 0; i < currentPoint.size(); i++)
Expand All @@ -67,7 +67,7 @@ namespace QuantLib
explicit SamplerGaussian(unsigned long seed = SeedGenerator::instance().get()) :
generator_(seed), distribution_(0.0, 1.0) {};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
for (Size i = 0; i < currentPoint.size(); i++)
Expand All @@ -92,7 +92,7 @@ namespace QuantLib
: generator_(seed), distribution_(0.0, 1.0),
lower_(std::move(lower)), upper_(std::move(upper)){};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
for (Size i = 0; i < currentPoint.size(); i++){
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace QuantLib
: generator_(seed), distribution_(0.0, 1.0),
lower_(std::move(lower)), upper_(std::move(upper)){};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
for (Size i = 0; i < currentPoint.size(); i++){
Expand Down Expand Up @@ -158,7 +158,7 @@ namespace QuantLib
explicit SamplerCauchy(unsigned long seed = SeedGenerator::instance().get()) :
generator_(seed), distribution_(0.0, 1.0) {};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
for (Size i = 0; i < currentPoint.size(); i++)
Expand All @@ -183,7 +183,7 @@ namespace QuantLib
QL_REQUIRE(lower_.size() == upper_.size(), "Incompatible input");
};

inline void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
void operator()(Array &newPoint, const Array &currentPoint, const Array &temp) {
QL_REQUIRE(newPoint.size() == currentPoint.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == lower_.size(), "Incompatible input");
QL_REQUIRE(newPoint.size() == temp.size(), "Incompatible input");
Expand All @@ -210,7 +210,7 @@ namespace QuantLib
optimizer will be able to escape a local optimum.
*/
struct ProbabilityAlwaysDownhill {
inline bool operator()(Real currentValue, Real newValue, const Array &temp) {
bool operator()(Real currentValue, Real newValue, const Array &temp) {
return currentValue > newValue; //return true if new value is lower than old value
}
};
Expand All @@ -224,7 +224,7 @@ namespace QuantLib
public:
explicit ProbabilityBoltzmann(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed) {};

inline bool operator()(Real currentValue, Real newValue, const Array &temp) {
bool operator()(Real currentValue, Real newValue, const Array &temp) {
Real temperature = *std::max_element(temp.begin(), temp.end());
return (1.0 / (1.0 + exp((newValue - currentValue) / temperature))) > distribution_(generator_);
}
Expand All @@ -241,7 +241,7 @@ namespace QuantLib
public:
explicit ProbabilityBoltzmannDownhill(unsigned long seed = SeedGenerator::instance().get()) : generator_(seed) {};

inline bool operator()(Real currentValue, Real newValue, const Array &temp) {
bool operator()(Real currentValue, Real newValue, const Array &temp) {
if (newValue < currentValue)
return true;
Real mTemperature = *std::max_element(temp.begin(), temp.end());
Expand All @@ -258,7 +258,7 @@ namespace QuantLib
public:
TemperatureBoltzmann(Real initialTemp, Size dimension)
: initialTemp_(dimension, initialTemp) {}
inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input");
QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input");
for (Size i = 0; i < initialTemp_.size(); i++)
Expand All @@ -274,7 +274,7 @@ namespace QuantLib
public:
TemperatureCauchy(Real initialTemp, Size dimension)
: initialTemp_(dimension, initialTemp) {}
inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input");
QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input");
for (Size i = 0; i < initialTemp_.size(); i++)
Expand All @@ -289,7 +289,7 @@ namespace QuantLib
TemperatureCauchy1D(Real initialTemp, Size dimension) :
inverseN_(1.0 / dimension),
initialTemp_(dimension, initialTemp) {}
inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input");
QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input");
for (Size i = 0; i < initialTemp_.size(); i++)
Expand All @@ -304,7 +304,7 @@ namespace QuantLib
public:
TemperatureExponential(Real initialTemp, Size dimension, Real power = 0.95)
: initialTemp_(dimension, initialTemp), power_(power) {}
inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input");
QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input");
for (Size i = 0; i < initialTemp_.size(); i++)
Expand All @@ -326,7 +326,7 @@ namespace QuantLib
for (Size i = 0; i < initialTemp_.size(); i++)
exponent_[i] = -std::log(finalTemp_[i] / initialTemp_[i])*coeff;
}
inline void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
void operator()(Array &newTemp, const Array &currTemp, const Array &steps) {
QL_REQUIRE(currTemp.size() == initialTemp_.size(), "Incompatible input");
QL_REQUIRE(currTemp.size() == newTemp.size(), "Incompatible input");
for (Size i = 0; i < initialTemp_.size(); i++)
Expand All @@ -342,8 +342,8 @@ namespace QuantLib
struct ReannealingTrivial {
ReannealingTrivial() = default;
;
inline void setProblem(Problem &P) {};
inline void operator()(Array & steps, const Array &currentPoint,
void setProblem(Problem &P) {};
void operator()(Array & steps, const Array &currentPoint,
Real aCurrentValue, const Array & currTemp) {};
};
//! Reannealing Finite Difference
Expand Down Expand Up @@ -375,8 +375,8 @@ namespace QuantLib
}
}
}
inline void setProblem(Problem &P) { problem_ = &P; };
inline void operator()(Array & steps, const Array &currentPoint,
void setProblem(Problem &P) { problem_ = &P; };
void operator()(Array & steps, const Array &currentPoint,
Real currentValue, const Array & currTemp) {
QL_REQUIRE(currTemp.size() == N_, "Incompatible input");
QL_REQUIRE(steps.size() == N_, "Incompatible input");
Expand Down
8 changes: 4 additions & 4 deletions ql/experimental/math/isotropicrandomwalk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace QuantLib {
QL_REQUIRE(dim_ == weights_.size(), "Invalid weights");
}
template <class InputIterator>
inline void nextReal(InputIterator first) {
void nextReal(InputIterator first) {
Real radius = distribution_(engine_);
Array::const_iterator weight = weights_.begin();
if (dim_ > 1) {
Expand All @@ -76,11 +76,11 @@ namespace QuantLib {
*first = radius*(*weight);
}
}
inline void setDimension(Size dim) {
void setDimension(Size dim) {
dim_ = dim;
weights_ = Array(dim, 1.0);
}
inline void setDimension(Size dim, const Array& weights) {
void setDimension(Size dim, const Array& weights) {
QL_REQUIRE(dim == weights.size(), "Invalid weights");
dim_ = dim;
weights_ = weights;
Expand All @@ -90,7 +90,7 @@ namespace QuantLib {
but if the limits are provided, they are used to rescale the sphere so as to make it to an
ellipsoid, with different radius in different dimensions.
*/
inline void setDimension(Size dim,
void setDimension(Size dim,
const Array& lowerBound, const Array& upperBound) {
QL_REQUIRE(dim == lowerBound.size(),
"Incompatible dimension and lower bound");
Expand Down
24 changes: 12 additions & 12 deletions ql/experimental/math/particleswarmoptimization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ namespace QuantLib {
*/
class TrivialInertia : public ParticleSwarmOptimization::Inertia {
public:
inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
c0_ = c0;
M_ = M;
}
inline void setValues() override {
void setValues() override {
for (Size i = 0; i < M_; i++) {
(*V_)[i] *= c0_;
}
Expand All @@ -181,11 +181,11 @@ namespace QuantLib {
: threshold_(threshold), rng_(seed) {
QL_REQUIRE(threshold_ >= 0.0 && threshold_ < 1.0, "Threshold must be a Real in [0, 1)");
}
inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
M_ = M;
c0_ = c0;
}
inline void setValues() override {
void setValues() override {
for (Size i = 0; i < M_; i++) {
Real val = c0_*(threshold_ + (1.0 - threshold_)*rng_.nextReal());
(*V_)[i] *= val;
Expand All @@ -208,13 +208,13 @@ namespace QuantLib {
: threshold_(threshold) {
QL_REQUIRE(threshold_ >= 0.0 && threshold_ < 1.0, "Threshold must be a Real in [0, 1)");
}
inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
N_ = N;
c0_ = c0;
iteration_ = 0;
maxIterations_ = endCriteria.maxIterations();
}
inline void setValues() override {
void setValues() override {
Real c0 = c0_*(threshold_ + (1.0 - threshold_)*(maxIterations_ - iteration_) / maxIterations_);
for (Size i = 0; i < M_; i++) {
(*V_)[i] *= c0;
Expand All @@ -235,7 +235,7 @@ namespace QuantLib {
AdaptiveInertia(Real minInertia, Real maxInertia, Size sh = 5, Size sl = 2)
:minInertia_(minInertia), maxInertia_(maxInertia),
sh_(sh), sl_(sl) {};
inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
M_ = M;
c0_ = c0;
adaptiveCounter = 0;
Expand Down Expand Up @@ -266,13 +266,13 @@ namespace QuantLib {
:rng_(seed), generator_(seed), flight_(generator_, LevyFlightDistribution(1.0, alpha),
1, Array(1, 1.0), seed),
threshold_(threshold) {};
inline void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
void setSize(Size M, Size N, Real c0, const EndCriteria& endCriteria) override {
M_ = M;
N_ = N;
c0_ = c0;
adaptiveCounter_ = std::vector<Size>(M_, 0);
}
inline void setValues() override {
void setValues() override {
for (Size i = 0; i < M_; i++) {
if ((*pBF_)[i] < personalBestF_[i]) {
personalBestF_[i] = (*pBF_)[i];
Expand Down Expand Up @@ -345,8 +345,8 @@ namespace QuantLib {
*/
class GlobalTopology : public ParticleSwarmOptimization::Topology {
public:
inline void setSize(Size M) override { M_ = M; }
inline void findSocialBest() override {
void setSize(Size M) override { M_ = M; }
void findSocialBest() override {
Real bestF = (*pBF_)[0];
Size bestP = 0;
for (Size i = 1; i < M_; i++) {
Expand Down Expand Up @@ -378,7 +378,7 @@ namespace QuantLib {
KNeighbors(Size K = 1) :K_(K) {
QL_REQUIRE(K > 0, "Neighbors need to be larger than 0");
}
inline void setSize(Size M) override {
void setSize(Size M) override {
M_ = M;
QL_ENSURE(K_ < M, "Number of neighbors need to be smaller than total particles in swarm");
}
Expand Down
5 changes: 3 additions & 2 deletions ql/experimental/variancegamma/variancegammamodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ FOR A PARTICULAR PURPOSE. See the license for more details.

#include <ql/experimental/variancegamma/variancegammamodel.hpp>
#include <ql/quotes/simplequote.hpp>
#include <ql/shared_ptr.hpp>

namespace QuantLib {

Expand All @@ -40,10 +41,10 @@ namespace QuantLib {
}

void VarianceGammaModel::generateArguments() {
process_.reset(new VarianceGammaProcess(process_->s0(),
process_ = ext::make_shared<VarianceGammaProcess>(process_->s0(),
process_->dividendYield(),
process_->riskFreeRate(),
sigma(), nu(), theta()));
sigma(), nu(), theta());
}

}
Expand Down
7 changes: 4 additions & 3 deletions ql/instruments/bond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <ql/math/solvers1d/brent.hpp>
#include <ql/pricingengines/bond/bondfunctions.hpp>
#include <ql/pricingengines/bond/discountingbondengine.hpp>
#include <ql/shared_ptr.hpp>
#include <utility>

namespace QuantLib {
Expand Down Expand Up @@ -326,10 +327,10 @@ namespace QuantLib {
Real amount = (R/100.0)*(notionals_[i-1]-notionals_[i]);
ext::shared_ptr<CashFlow> payment;
if (i < notionalSchedule_.size()-1)
payment.reset(new AmortizingPayment(amount,
notionalSchedule_[i]));
payment = ext::make_shared<AmortizingPayment>(amount,
notionalSchedule_[i]);
else
payment.reset(new Redemption(amount, notionalSchedule_[i]));
payment = ext::make_shared<Redemption>(amount, notionalSchedule_[i]);
cashflows_.push_back(payment);
redemptions_.push_back(payment);
}
Expand Down
Loading

0 comments on commit af365f0

Please sign in to comment.