Skip to content

Commit

Permalink
Style warnings in kernel. Refs #3868
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiSavici committed Dec 31, 2011
1 parent 57fd372 commit fa344e2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
10 changes: 2 additions & 8 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "MantidAPI/NumericAxis.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidNexusCPP/NeXusFile.hpp"
#include <boost/math/special_functions/fpclassify.hpp>

using Mantid::Kernel::DateAndTime;
using Mantid::Kernel::TimeSeriesProperty;
Expand Down Expand Up @@ -686,13 +687,6 @@ 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 @@ -708,7 +702,7 @@ namespace Mantid
const MantidVec& dataX = this->readX(workspaceIndex); // force using const version
xfront = dataX.front();
xback = dataX.back();
if (isANumber(xfront) && isANumber(xback))
if (boost::math::isfinite(xfront) && boost::math::isfinite(xback))
{
if (xfront < xmin)
xmin = xfront;
Expand Down
8 changes: 3 additions & 5 deletions Code/Mantid/Framework/Kernel/src/ANN/kd_dump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,13 +372,10 @@ static ANNkd_ptr annReadTree(
int &next_idx) // next index (modified)
{
char tag[STRING_LEN]; // tag (leaf, split, shrink)
int n_pts; // number of points in leaf
int cd; // cut dimension
ANNcoord cv; // cut value
ANNcoord lb; // low bound
ANNcoord hb; // high bound
int n_bnds; // number of bounding sides
int sd; // which side

in >> tag; // input node tag

Expand All @@ -389,7 +386,7 @@ static ANNkd_ptr annReadTree(
// Read a leaf
//------------------------------------------------------------------
if (strcmp(tag, "leaf") == 0) { // leaf node

int n_pts; // number of points in leaf
in >> n_pts; // input number of points
int old_idx = next_idx; // save next_idx
if (n_pts == 0) { // trivial leaf
Expand Down Expand Up @@ -422,11 +419,12 @@ static ANNkd_ptr annReadTree(
if (tree_type != BD_TREE) {
annError("Shrinking node not allowed in kd-tree", ANNabort);
}

int n_bnds; // number of bounding sides
in >> n_bnds; // number of bounding sides
// allocate bounds array
ANNorthHSArray bds = new ANNorthHalfSpace[n_bnds];
for (int i = 0; i < n_bnds; i++) {
int sd; // which side
in >> cd >> cv >> sd; // input bounding halfspace
// copy to array
bds[i] = ANNorthHalfSpace(cd, cv, sd);
Expand Down
18 changes: 7 additions & 11 deletions Code/Mantid/Framework/Kernel/src/Atom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdexcept>
#include "MantidKernel/Atom.h"
#include "MantidKernel/PhysicalConstants.h"
#include <boost/math/special_functions/fpclassify.hpp>

namespace Mantid
{
Expand All @@ -13,15 +14,15 @@ namespace PhysicalConstants

using std::string;

/// constant to use for garbage numbers
static const double NAN = std::numeric_limits<double>::quiet_NaN();

/// Get the corresponding neutronic atom
const NeutronAtom getNeutronNoExceptions(const uint16_t z, const uint16_t a)
{
try {
try
{
return getNeutronAtom(z, a);
} catch (std::runtime_error & ) {
}
catch (std::runtime_error & )
{
return NeutronAtom(z, a,
NAN, NAN, NAN, NAN,
NAN, NAN, NAN, NAN); // set to junk value
Expand Down Expand Up @@ -3186,18 +3187,13 @@ static const size_t NUM_ATOMS = 2845;

// ---------- END DO NOT EDIT AREA----------

/// Check to see if we have non-valid atom
inline bool AtomIsNaN(const double number)
{
return (number != number);
}

/// Check if two atoms are not valid.
bool AtomEqualsWithNaN(const double left, const double right)
{
if (left == right)
return true;
if (AtomIsNaN(left) && AtomIsNaN(right))
if ((boost::math::isnan)(left) && (boost::math::isnan)(right))
return true;
return false;
}
Expand Down
10 changes: 2 additions & 8 deletions Code/Mantid/Framework/Kernel/src/NeutronAtom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <limits>
#include <sstream>
#include <stdexcept>
#include <boost/math/special_functions/fpclassify.hpp>

namespace Mantid
{
Expand Down Expand Up @@ -93,7 +94,6 @@ NeutronAtom::NeutronAtom(const NeutronAtom& other):
abs_scatt_xs(other.abs_scatt_xs)
{}

static const double NAN = std::numeric_limits<double>::quiet_NaN();

/**
* DO NOT USE THIS! This constructor generates a complete garbage NeutronAtom
Expand Down Expand Up @@ -523,17 +523,11 @@ static NeutronAtom ATOMS[] = {H, H1, H2, H3, He, He3, He4, Li, Li6, Li7, Be, B,
/** The total number of atoms in the array. */
static const size_t NUM_ATOMS = 371;


inline bool NeutronAtomIsNaN(const double number)
{
return (number != number);
}

bool NeutronAtomEqualsWithNaN(const double left, const double right)
{
if (left == right)
return true;
if (NeutronAtomIsNaN(left) && NeutronAtomIsNaN(right))
if ((boost::math::isnan)(left) && (boost::math::isnan)(right))
return true;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/Kernel/src/Strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ float getVAXnum(const float A)
{
union
{
char a[4];
//char a[4];
float f;
int ival;
} Bd;
Expand Down

0 comments on commit fa344e2

Please sign in to comment.