Skip to content

Commit

Permalink
Copied code from ConvertUnits. Refs #4178.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Nov 23, 2011
1 parent 5ed21f7 commit 2a5c41b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Expand Up @@ -668,6 +668,13 @@ namespace Mantid
return xmax;
}

namespace {
bool isANumber(const double d)
{
return d == d && fabs(d) != std::numeric_limits<double>::infinity();
}
}

void MatrixWorkspace::getXMinMax(double &xmin, double &xmax) const
{
// set to crazy values to start
Expand All @@ -676,16 +683,20 @@ namespace Mantid
size_t numberOfSpectra = this->getNumberHistograms();

// determine the data range
double temp;
double xfront;
double xback;
for (size_t workspaceIndex = 0; workspaceIndex < numberOfSpectra; workspaceIndex++)
{
const MantidVec& dataX = this->readX(workspaceIndex); // force using const version
temp = dataX.front();
if (temp < xmin)
xmin = temp;
temp = dataX.back();
if (temp > xmax)
xmax = temp;
xfront = dataX.front();
xback = dataX.back();
if (isANumber(xfront) && isANumber(xback))
{
if (xfront < xmin)
xmin = xfront;
if (xback > xmax)
xmax = xback;
}
}
}

Expand Down

0 comments on commit 2a5c41b

Please sign in to comment.