Skip to content

Commit 56fa1a6

Browse files
authored
Real usage consistency and warning fixes (lballabio#1625)
2 parents 617c043 + 4642500 commit 56fa1a6

16 files changed

Lines changed: 25 additions & 25 deletions

ql/experimental/credit/homogeneouspooldef.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace QuantLib {
5151
Size nBuckets,
5252
Real max = 5.,
5353
Real min = -5.,
54-
Real nSteps = 50)
54+
Size nSteps = 50)
5555
: copula_(copula),
5656
nBuckets_(nBuckets),
5757
max_(max), min_(min), nSteps_(nSteps), delta_((max - min)/nSteps)
@@ -92,7 +92,7 @@ namespace QuantLib {
9292
// multifactor version
9393
const Real max_;// redundant?
9494
const Real min_;
95-
const Real nSteps_;
95+
const Size nSteps_;
9696
const Real delta_;
9797
};
9898
// \todo Add other loss distribution statistics

ql/experimental/credit/inhomogeneouspooldef.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace QuantLib {
5858
Size nBuckets,
5959
Real max = 5.,
6060
Real min = -5.,
61-
Real nSteps = 50)
61+
Size nSteps = 50)
6262
: copula_(copula),
6363
nBuckets_(nBuckets),
6464
max_(max), min_(min), nSteps_(nSteps), delta_((max - min)/nSteps)
@@ -100,7 +100,7 @@ namespace QuantLib {
100100
// multifactor version
101101
const Real max_;// redundant?
102102
const Real min_;
103-
const Real nSteps_;
103+
const Size nSteps_;
104104
const Real delta_;
105105
};
106106
// \todo Add other loss distribution statistics

ql/experimental/math/convolvedstudentt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ namespace QuantLib {
172172
// (q is very close to 1.), in a bad combination fails around 1.-1.e-7
173173
Real xMax = 1.e6;
174174
return sign *
175-
Brent().solve([&](Real x){ return distrib_(x) - effectiveq; },
175+
Brent().solve([&](Real x) -> Real { return distrib_(x) - effectiveq; },
176176
accuracy_, (xMin+xMax)/2., xMin, xMax);
177177
}
178178

ql/experimental/math/gaussiancopulapolicy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ namespace QuantLib {
8484
*/
8585
Probability density(const std::vector<Real>& m) const {
8686
return std::accumulate(m.begin(), m.end(), Real(1.),
87-
[&](Real x, Real y){ return x*density_(y); });
87+
[&](Real x, Real y) -> Real { return x*density_(y); });
8888
}
8989
/*! Returns the inverse of the cumulative distribution of the (modelled)
9090
latent variable (as indexed by iVariable). The normal stability avoids

ql/experimental/math/multidimquadrature.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ namespace QuantLib {
6060
Integer i = order()-1;
6161
std::vector<Real> term = f(x_[i]);// potential copy! @#$%^!!!
6262
std::for_each(term.begin(), term.end(),
63-
[&](Real x){ return x * w_[i]; });
63+
[&](Real x) -> Real { return x * w_[i]; });
6464
std::vector<Real> sum = term;
6565

6666
for (i--; i >= 0; --i) {
6767
term = f(x_[i]);// potential copy! @#$%^!!!
6868
// sum[j] += term[j] * w_[i];
6969
std::transform(term.begin(), term.end(), sum.begin(),
7070
sum.begin(),
71-
[&](Real x, Real y){ return w_[i]*x + y; });
71+
[&](Real x, Real y) -> Real { return w_[i]*x + y; });
7272
}
7373
return sum;
7474
}

ql/legacy/libormarketmodels/lfmcovarproxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ namespace QuantLib {
5151
for (Size i=0; i<size_; ++i) {
5252
std::transform(pca.row_begin(i), pca.row_end(i),
5353
pca.row_begin(i),
54-
[&](Real x){ return x * vol[i]; });
54+
[&](Real x) -> Real { return x * vol[i]; });
5555
}
5656

5757
return pca;

ql/methods/finitedifferences/meshers/concentrating1dmesher.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace QuantLib {
162162

163163
OdeIntegrationFct fct(points, betas, tol);
164164
const Real a = Brent().solve(
165-
[&](Real x) { return fct.solve(x, start, 0.0, 1.0) - end; },
165+
[&](Real x) -> Real { return fct.solve(x, start, 0.0, 1.0) - end; },
166166
tol, aInit, 0.1*aInit);
167167

168168
// solve ODE for all grid points
@@ -192,7 +192,7 @@ namespace QuantLib {
192192
std::lower_bound(y.begin(), y.end(), points[i]));
193193

194194
const Real e = Brent().solve(
195-
[&](Real x){ return odeSolution(x, true) - points[i]; },
195+
[&](Real x) -> Real { return odeSolution(x, true) - points[i]; },
196196
QL_EPSILON, x[j], 0.5/size);
197197

198198
w.emplace_back(std::min(x[size - 2], x[j]), e);

ql/methods/finitedifferences/utilities/gbsmrndcalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ namespace QuantLib {
9696
<< cdf(lower, t) << ", " << cdf(upper, t) << ")");
9797

9898
return Brent().solve(
99-
[&](Real _k){ return cdf(_k, t) - q; },
99+
[&](Real _k) -> Real { return cdf(_k, t) - q; },
100100
1e-10, 0.5*(lower+upper), lower, upper);
101101
}
102102
}

ql/methods/finitedifferences/utilities/riskneutraldensitycalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace QuantLib {
3636
Real RiskNeutralDensityCalculator::InvCDFHelper::inverseCDF(Real p, Time t) const {
3737
Brent solver;
3838
solver.setMaxEvaluations(maxEvaluations_);
39-
return solver.solve([&](Real _x){ return calculator_->cdf(_x, t) - p; },
39+
return solver.solve([&](Real _x) -> Real { return calculator_->cdf(_x, t) - p; },
4040
accuracy_, guess_, stepSize_);
4141
}
4242

ql/models/volatility/garch.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ namespace QuantLib {
7171
Real retval(0.0);
7272
Real sigma2 = 0;
7373
Real u2 = 0;
74-
for (const auto r2 : r2_) {
74+
for (auto r2 : r2_) {
7575
sigma2 = x[0] + x[1] * u2 + x[2] * sigma2;
7676
u2 = r2;
7777
retval += std::log(sigma2) + u2 / sigma2;
@@ -84,7 +84,7 @@ namespace QuantLib {
8484
Real sigma2 = 0;
8585
Real u2 = 0;
8686
Size i = 0;
87-
for (const auto r2 : r2_) {
87+
for (auto r2 : r2_) {
8888
sigma2 = x[0] + x[1] * u2 + x[2] * sigma2;
8989
u2 = r2;
9090
retval[i++] = (std::log(sigma2) + u2 / sigma2)/(2.0*r2_.size());
@@ -99,7 +99,7 @@ namespace QuantLib {
9999
Real sigma2prev = sigma2;
100100
Real u2prev = u2;
101101
Real norm = 2.0 * r2_.size();
102-
for (const auto r2 : r2_) {
102+
for (auto r2 : r2_) {
103103
sigma2 = x[0] + x[1] * u2 + x[2] * sigma2;
104104
u2 = r2;
105105
Real w = (sigma2 - u2) / (sigma2*sigma2);
@@ -122,7 +122,7 @@ namespace QuantLib {
122122
Real sigma2prev = sigma2;
123123
Real u2prev = u2;
124124
Real norm = 2.0 * r2_.size();
125-
for (const auto r2 : r2_) {
125+
for (auto r2 : r2_) {
126126
sigma2 = x[0] + x[1] * u2 + x[2] * sigma2;
127127
u2 = r2;
128128
retval += std::log(sigma2) + u2 / sigma2;

0 commit comments

Comments
 (0)