Skip to content

Commit

Permalink
Re #11131. Forgot that lambdas aren't allowed :(
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed Mar 6, 2015
1 parent f2d34fb commit 12267d9
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Code/Mantid/Framework/CurveFitting/src/ChebfunBase.cpp
Expand Up @@ -10,6 +10,7 @@
#include <cmath>
#include <algorithm>
#include <numeric>
#include <limits>
#include <functional>
#include <assert.h>
#include <sstream>
Expand Down Expand Up @@ -157,9 +158,12 @@ bool ChebfunBase::hasConverged(const std::vector<double> &a, double maxA,
if (a.empty())
return true;
if (maxA == 0.0) {
maxA = fabs(*std::max_element(a.begin(), a.end(),
[](double a, double b)
-> bool { return fabs(a) < fabs(b); }));
for (auto it = a.begin(); it != a.end(); ++it) {
double tmp = fabs(*it);
if (tmp > maxA) {
maxA = tmp;
}
}
}
if (maxA < tolerance || a.size() < 3) {
return true;
Expand Down Expand Up @@ -374,10 +378,13 @@ ChebfunBase::bestFitTempl(double start, double end, FunctionType f,
}
a = base.calcA(p2);
if (calcMaxA) {
maxA =
fabs(*std::max_element(a.begin(), a.end(), [](double a1, double a2) {
return fabs(a1) < fabs(a2);
}));
maxA = 0.0;
for (auto it = a.begin(); it != a.end(); ++it) {
double tmp = fabs(*it);
if (tmp > maxA) {
maxA = tmp;
}
}
}
if (ChebfunBase::hasConverged(a, maxA, tolerance)) {
// cut off the trailing a-values that are below the tolerance
Expand Down

0 comments on commit 12267d9

Please sign in to comment.