Commit 3cf82614 authored by Dimitar Tasev's avatar Dimitar Tasev
Browse files

Re #16959 changed for loop to std funcs

parent aff08006
......@@ -381,12 +381,12 @@ void GetAllEi::exec() {
std::transform(peaks.cbegin(), peaks.cend(), peaks_positions.begin(),
[](peakKeeper peak) { return peak.position; });
auto &Signal =
result_ws->mutableY(0); // Signal[i] = peaks[i].height; to transform
result_ws->mutableY(0);
std::transform(peaks.cbegin(), peaks.cend(), Signal.begin(),
[](peakKeeper peak) { return peak.height; });
auto &Error =
result_ws->mutableE(0); // Error[i] = peaks[i].sigma; to transform
result_ws->mutableE(0);
std::transform(peaks.cbegin(), peaks.cend(), Error.begin(),
[](peakKeeper peak) { return peak.sigma; });
......@@ -746,7 +746,7 @@ namespace { // for lambda extracted from findBinRanges
void getBinRange(const HistogramData::HistogramX &eBins, double eMin,
double eMax, size_t &index_min, size_t &index_max) {
auto bins = eBins.rawData();
auto &bins = eBins.rawData();
size_t nBins = bins.size();
if (eMin <= bins[0]) {
index_min = 0;
......@@ -891,7 +891,7 @@ GetAllEi::buildWorkspaceToFit(const API::MatrixWorkspace_sptr &inputWS,
// auto bins = inputWS->dataX(wsIndex0);
auto bins = pSpectr1.ptrX();
size_t XLength = bins->size();
size_t YLength = inputWS->mutableY(wsIndex0).size();
size_t YLength = inputWS->y(wsIndex0).size();
auto working_ws =
API::WorkspaceFactory::Instance().create(inputWS, 2, XLength, YLength);
// copy data --> very bad as implicitly assigns pointer
......
......@@ -10,6 +10,7 @@
#include <boost/lexical_cast.hpp>
#include <cmath>
#include <numeric>
namespace Mantid {
namespace Algorithms {
......@@ -377,14 +378,9 @@ void GetEi::getPeakEstimates(double &height, int64_t &centreInd,
centreInd = 0;
// then loop through all the Y values and find the tallest peak
for (size_t i = 1; i < Y.size() - 1; ++i) {
background += Y[i];
if (Y[i] > height) {
centreInd = i;
height = Y[centreInd];
}
}
std::accumulate(Y.begin(), Y.end(), background);
std::max(Y.begin(), Y.end(), height);
background = background / static_cast<double>(Y.size());
if (height < PEAK_THRESH_H * background) {
throw std::invalid_argument(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment