Skip to content

Commit

Permalink
Merge a6b4715 into d1b43b8
Browse files Browse the repository at this point in the history
  • Loading branch information
sweemer committed Aug 7, 2023
2 parents d1b43b8 + a6b4715 commit 519170a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 28 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Expand Up @@ -48,7 +48,6 @@ Checks: >
-modernize-avoid-c-arrays,
-modernize-macro-to-enum,
-modernize-return-braced-init-list,
-modernize-use-emplace,
-modernize-use-trailing-return-type,
-modernize-use-using,
performance-*,
Expand Down
2 changes: 1 addition & 1 deletion ql/currencies/exchangeratemanager.cpp
Expand Up @@ -46,7 +46,7 @@ namespace QuantLib {
const Date& startDate,
const Date& endDate) {
Key k = hash(rate.source(), rate.target());
data_[k].push_front(Entry(rate,startDate,endDate));
data_[k].emplace_front(rate,startDate,endDate);
}

ExchangeRate ExchangeRateManager::lookup(const Currency& source,
Expand Down
2 changes: 1 addition & 1 deletion ql/experimental/commodities/commodity.cpp
Expand Up @@ -37,7 +37,7 @@ namespace QuantLib {
void Commodity::addPricingError(PricingError::Level errorLevel,
const std::string& error,
const std::string& detail) const {
pricingErrors_.push_back(PricingError(errorLevel, error, detail));
pricingErrors_.emplace_back(errorLevel, error, detail);
}


Expand Down
4 changes: 2 additions & 2 deletions ql/methods/montecarlo/lsmbasissystem.cpp
Expand Up @@ -164,7 +164,7 @@ namespace QuantLib {
VF_A ret;
// 0-th order term
VF_R term(dim, pathBasis[0]);
ret.push_back(MultiDimFct(term));
ret.emplace_back(MultiDimFct(term));
// start with all 0 tuple
VV tuples(1, std::vector<Size>(dim));
// add multi-factor terms
Expand All @@ -175,7 +175,7 @@ namespace QuantLib {
for (auto& tuple : tuples) {
for(Size k=0; k<dim; ++k)
term[k] = pathBasis[tuple[k]];
ret.push_back(MultiDimFct(term));
ret.emplace_back(MultiDimFct(term));
}
}
return ret;
Expand Down
5 changes: 2 additions & 3 deletions ql/pricingengines/forward/replicatingvarianceswapengine.hpp
Expand Up @@ -135,10 +135,9 @@ namespace QuantLib {
ext::shared_ptr<StrikedTypePayoff> payoff(
new PlainVanillaPayoff(type, *k));
if ( k == strikes.begin() )
optionWeights.push_back(std::make_pair(payoff,slope));
optionWeights.emplace_back(payoff,slope);
else
optionWeights.push_back(
std::make_pair(payoff, slope - prevSlope));
optionWeights.emplace_back(payoff, slope - prevSlope);
prevSlope = slope;
}
}
Expand Down
Expand Up @@ -247,8 +247,7 @@ namespace QuantLib {
const Real strike = payoff->strike();
strikes.insert(strike);

calibrationSet_.push_back(
std::make_pair(ext::make_shared<VanillaOption>(payoff, exercise), i.second));
calibrationSet_.emplace_back(ext::make_shared<VanillaOption>(payoff, exercise), i.second);

registerWith(i.second);
}
Expand Down
Expand Up @@ -69,7 +69,7 @@ namespace QuantLib {
checkInputs();

for (Size i = 0; i < nOptionletDates_; ++i)
optionletVolatilities_.push_back(vector<Volatility>(strikes[i].size()));
optionletVolatilities_.emplace_back(strikes[i].size());

registerWith(Settings::instance().evaluationDate());
registerWithMarketData();
Expand Down
26 changes: 13 additions & 13 deletions test-suite/andreasenhugevolatilityinterpl.cpp
Expand Up @@ -131,14 +131,14 @@ namespace andreasen_huge_volatility_interpl_test {

const Volatility impliedVol = i[j];

calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(
(strike < spot->value())? Option::Put
: Option::Call,
strike),
ext::make_shared<EuropeanExercise>(maturity)),
ext::make_shared<SimpleQuote>(impliedVol))
ext::make_shared<SimpleQuote>(impliedVol)
);
}
}
Expand Down Expand Up @@ -295,12 +295,12 @@ namespace andreasen_huge_volatility_interpl_test {

if (std::fabs(mn) < 3.71*vol) {

calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(
Option::Call, strike),
ext::make_shared<EuropeanExercise>(maturityDate)),
ext::make_shared<SimpleQuote>(vol)));
ext::make_shared<SimpleQuote>(vol));
}
}
}
Expand Down Expand Up @@ -331,12 +331,12 @@ namespace andreasen_huge_volatility_interpl_test {
const Date maturityDate = today + Period(maturities[i], Months);
const Volatility vol = vols[i];

calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(
Option::Call, strike),
ext::make_shared<EuropeanExercise>(maturityDate)),
ext::make_shared<SimpleQuote>(vol)));
ext::make_shared<SimpleQuote>(vol));
}

return { spot, rTS, qTS, calibrationSet };
Expand Down Expand Up @@ -542,11 +542,11 @@ void AndreasenHugeVolatilityInterplTest::testSingleOptionCalibration() {
const Date maturity = today + Period(1, Years);
Handle<Quote> spot(ext::make_shared<SimpleQuote>(strike));

calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(Option::Call, strike),
ext::make_shared<EuropeanExercise>(maturity)),
ext::make_shared<SimpleQuote>(vol)));
ext::make_shared<SimpleQuote>(vol));

const AndreasenHugeVolatilityInterpl::InterpolationType interpl[] = {
AndreasenHugeVolatilityInterpl::Linear,
Expand Down Expand Up @@ -713,12 +713,12 @@ void AndreasenHugeVolatilityInterplTest::testBarrierOptionPricing() {
const Real mn = std::log(spot->value()/strike)/std::sqrt(t);

if (std::fabs(mn) < 3.07*vol) {
calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(
Option::Call, strike),
ext::make_shared<EuropeanExercise>(maturityDate)),
ext::make_shared<SimpleQuote>(vol)));
ext::make_shared<SimpleQuote>(vol));
}
}
}
Expand Down Expand Up @@ -799,12 +799,12 @@ namespace andreasen_huge_volatility_interpl_test {
for (Real strike : strikes) {
const Volatility vol = sabrVolatility(strike, forward, maturity, alpha, beta, nu, rho);

calibrationSet.push_back(std::make_pair(
calibrationSet.emplace_back(
ext::make_shared<VanillaOption>(
ext::make_shared<PlainVanillaPayoff>(
Option::Call, strike),
ext::make_shared<EuropeanExercise>(maturityDate)),
ext::make_shared<SimpleQuote>(vol)));
ext::make_shared<SimpleQuote>(vol));
}

const Handle<YieldTermStructure> rTS(flatRate(today, forward, dc));
Expand Down Expand Up @@ -1019,7 +1019,7 @@ void AndreasenHugeVolatilityInterplTest::testFlatVolCalibration() {
(strike>fwd)? Option::Call : Option::Put, strike),
exercise);

calibrationSet.push_back(std::make_pair(option, vol));
calibrationSet.emplace_back(option, vol);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test-suite/catbonds.cpp
Expand Up @@ -406,7 +406,7 @@ void CatBondTest::testCatBondInDoomScenario() {
DateGeneration::Backward, false);

ext::shared_ptr<std::vector<std::pair<Date, Real> > > events(new std::vector<std::pair<Date, Real> >());
events->push_back(std::pair<Date, Real>(Date(30,November,2004), 1000));
events->emplace_back(Date(30,November,2004), 1000);
ext::shared_ptr<CatRisk> doomCatRisk(new EventSet(
events,
Date(30,November,2004), Date(30,November,2008)));
Expand Down Expand Up @@ -471,7 +471,7 @@ void CatBondTest::testCatBondWithDoomOnceInTenYears() {
DateGeneration::Backward, false);

ext::shared_ptr<std::vector<std::pair<Date, Real> > > events(new std::vector<std::pair<Date, Real> >());
events->push_back(std::pair<Date, Real>(Date(30,November,2008), 1000));
events->emplace_back(Date(30,November,2008), 1000);
ext::shared_ptr<CatRisk> doomCatRisk(new EventSet(
events,
Date(30,November,2004), Date(30,November,2044)));
Expand Down Expand Up @@ -554,7 +554,7 @@ void CatBondTest::testCatBondWithDoomOnceInTenYearsProportional() {
DateGeneration::Backward, false);

ext::shared_ptr<std::vector<std::pair<Date, Real> > > events(new std::vector<std::pair<Date, Real> >());
events->push_back(std::pair<Date, Real>(Date(30,November,2008), 1000));
events->emplace_back(Date(30,November,2008), 1000);
ext::shared_ptr<CatRisk> doomCatRisk(new EventSet(
events,
Date(30,November,2004), Date(30,November,2044)));
Expand Down
2 changes: 1 addition & 1 deletion test-suite/swingoption.cpp
Expand Up @@ -512,7 +512,7 @@ void SwingOptionTest::testKlugeChFVanillaPricing() {
- sig*sig/(4*alpha)*(1-std::exp(-2*alpha*t))
- lambda/beta*std::log((eta-std::exp(-beta*t))/(eta-1.0));

shape->push_back(Shape::value_type(t, ps));
shape->emplace_back(t, ps);

const Real expected =
RichardsonExtrapolation(
Expand Down

0 comments on commit 519170a

Please sign in to comment.