Skip to content
Snippets Groups Projects
Commit e36e12e7 authored by Alex Buts's avatar Alex Buts
Browse files

Re #13566 Downgraded C++11 to C++ std as the former does not work

on RHEL-6
parent a537a240
No related merge requests found
......@@ -61,6 +61,12 @@ private:
Kernel::Property *getPLogForProperty(const API::MatrixWorkspace_sptr &inputWS,
const std::string &name);
void setFilterLog(const API::MatrixWorkspace_sptr &inputWS);
// former lambda function exposed as not evry compiler support this yet
bool peakGuess(const API::MatrixWorkspace_sptr &inputWS,
size_t index, double Ei,
const std::vector<size_t> &monsRangeMin,
const std::vector<size_t> &monsRangeMax,
double &peakPos, double &peakHeight, double &peakTwoSigma);
protected: // for testing, private otherwise.
// prepare working workspace with appropriate monitor spectra for fitting
......
This diff is collapsed.
......@@ -119,7 +119,7 @@ public:
//
/// Return time series property, containing time derivative of current
/// property
std::unique_ptr<TimeSeriesProperty<double>> getDerivative() const;
std::unique_ptr<TimeSeriesProperty<double> > getDerivative() const;
/// "Virtual" copy constructor with a time shift in seconds
virtual Property *cloneWithTimeShift(const double timeShift) const;
......
......@@ -87,9 +87,9 @@ MANTID_KERNEL_DLL void linearlyInterpolateY(const std::vector<double> &x,
MANTID_KERNEL_DLL void
smoothInRange(const std::vector<double> &input, std::vector<double> &output,
double avrgInterval,
std::vector<double> const *const binBoundaris = nullptr,
std::vector<double> const *const binBoundaris = NULL,
size_t startIndex = 0, size_t endIndex = 0,
std::vector<double> *const outputBinBoundaries = nullptr);
std::vector<double> *const outputBinBoundaries = NULL);
//-------------------------------------------------------------------------------------
/** Return the length of the vector (in the physical sense),
......
......@@ -59,13 +59,14 @@ TimeSeriesProperty<TYPE>::cloneWithTimeShift(const double timeShift) const {
/** Return time series property, containing time derivative of current property.
* The property itself and the returned time derivative become sorted by time and
* the derivative is calculated in seconds.
* (dValue/dT where dT is time difference in seconds
for subsequent property readings and dValue is difference in subsequent values)
* the derivative is calculated in seconds^-1.
* (e.g. dValue/dT where dT=t2-t1 is time difference in seconds
* for subsequent time readings and dValue=Val1-Val2 is difference in
* subsequent values)
*
*/
template <typename TYPE>
std::unique_ptr<TimeSeriesProperty<double>>
std::unique_ptr<TimeSeriesProperty<double> >
TimeSeriesProperty<TYPE>::getDerivative() const {
if (this->m_values.size() < 2) {
......
......@@ -534,6 +534,74 @@ void linearlyInterpolateY(const std::vector<double> &x, std::vector<double> &y,
step++;
}
}
namespace {
// internal function converted from Lambda to identify interval around specified point and
// run average around this point
double runAverage(size_t index,size_t startIndex,size_t endIndex,
const double halfWidth,
const std::vector<double> &input,
std::vector<double> const *const binBndrs) {
size_t iStart, iEnd;
double bin0(0), weight0(0), weight1(0), start, end;
//
if (binBndrs) {
// identify initial and final bins to
// integrate over. Notice the difference
// between start and end bin and shift of
// the interpolating function into the center
// of each bin
bin0 = binBndrs->operator[](index + 1) - binBndrs->operator[](index);
double binC =
0.5 * (binBndrs->operator[](index + 1) + binBndrs->operator[](index));
start = binC - halfWidth;
end = binC + halfWidth;
if (start <= binBndrs->operator[](startIndex)) {
iStart = startIndex;
start = binBndrs->operator[](iStart);
} else {
iStart = getBinIndex(*binBndrs, start);
weight0 =
(binBndrs->operator[](iStart + 1) - start) /
(binBndrs->operator[](iStart + 1) - binBndrs->operator[](iStart));
iStart++;
}
if (end >= binBndrs->operator[](endIndex)) {
iEnd = endIndex; // the signal defined up to i<iEnd
end = binBndrs->operator[](endIndex);
} else {
iEnd = getBinIndex(*binBndrs, end);
weight1 = (end - binBndrs->operator[](iEnd)) /
(binBndrs->operator[](iEnd + 1) - binBndrs->operator[](iEnd));
}
} else { // integer indexes and functions defined in the bin centers
iStart = index - static_cast<size_t>(halfWidth);
if (startIndex + static_cast<size_t>(halfWidth) > index)
iStart = startIndex;
iEnd = index + static_cast<size_t>(halfWidth);
if (iEnd > endIndex)
iEnd = endIndex;
}
double avrg = 0;
size_t ic = 0;
for (size_t j = iStart; j < iEnd; j++) {
avrg += input[j];
ic++;
}
if (binBndrs) { // add values at edges
if (iStart != startIndex)
avrg += input[iStart - 1] * weight0;
if (iEnd != endIndex)
avrg += input[iEnd] * weight1;
return avrg * bin0 / (end - start);
} else {
return avrg / double(ic);
}
};
}
/** Basic running average of input vector within specified range, considering
*variable bin-boundaries
* if such boundaries are provided.
......@@ -597,74 +665,14 @@ void smoothInRange(const std::vector<double> &input,
halfWidth = static_cast<double>(static_cast<size_t>(halfWidth) + 1);
}
}
// Lambda to identify interval around specified point and
// average around this point
auto runAverage = [&](size_t index) {
size_t iStart, iEnd;
double bin0(0), weight0(0), weight1(0), start, end;
//
if (binBndrs) {
// identify initial and final bins to
// integrate over. Notice the difference
// between start and end bin and shift of
// the interpolating function into the center
// of each bin
bin0 = binBndrs->operator[](index + 1) - binBndrs->operator[](index);
double binC =
0.5 * (binBndrs->operator[](index + 1) + binBndrs->operator[](index));
start = binC - halfWidth;
end = binC + halfWidth;
if (start <= binBndrs->operator[](startIndex)) {
iStart = startIndex;
start = binBndrs->operator[](iStart);
} else {
iStart = getBinIndex(*binBndrs, start);
weight0 =
(binBndrs->operator[](iStart + 1) - start) /
(binBndrs->operator[](iStart + 1) - binBndrs->operator[](iStart));
iStart++;
}
if (end >= binBndrs->operator[](endIndex)) {
iEnd = endIndex; // the signal defined up to i<iEnd
end = binBndrs->operator[](endIndex);
} else {
iEnd = getBinIndex(*binBndrs, end);
weight1 = (end - binBndrs->operator[](iEnd)) /
(binBndrs->operator[](iEnd + 1) - binBndrs->operator[](iEnd));
}
} else { // integer indexes and functions defined in the bin centers
iStart = index - static_cast<size_t>(halfWidth);
if (startIndex + static_cast<size_t>(halfWidth) > index)
iStart = startIndex;
iEnd = index + static_cast<size_t>(halfWidth);
if (iEnd > endIndex)
iEnd = endIndex;
}
double avrg = 0;
size_t ic = 0;
for (size_t j = iStart; j < iEnd; j++) {
avrg += input[j];
ic++;
}
if (binBndrs) { // add values at edges
if (iStart != startIndex)
avrg += input[iStart - 1] * weight0;
if (iEnd != endIndex)
avrg += input[iEnd] * weight1;
if (outBins) outBins->resize(length + 1);
return avrg * bin0 / (end - start);
} else {
return avrg / double(ic);
}
};
// Run averaging
if (outBins) {
outBins->resize(length + 1);
}
for (size_t i = startIndex; i < endIndex; i++) {
output[i - startIndex] = runAverage(i);
output[i - startIndex] = runAverage(i,startIndex,endIndex,halfWidth,
input,binBndrs);
if (outBins) {
outBins->operator[](i - startIndex) = binBndrs->operator[](i);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment