Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
297d9d0a
Commit
297d9d0a
authored
Oct 04, 2016
by
Savici, Andrei T
Browse files
Re #17695. Move from boost nans and infs
parent
e1e2fce1
Changes
56
Hide whitespace changes
Inline
Side-by-side
Framework/API/src/MatrixWorkspace.cpp
View file @
297d9d0a
...
...
@@ -16,7 +16,7 @@
#include
"MantidKernel/MDUnit.h"
#include
"MantidKernel/make_unique.h"
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
#include
<numeric>
...
...
@@ -699,7 +699,7 @@ void MatrixWorkspace::getXMinMax(double &xmin, double &xmax) const {
const
MantidVec
&
dataX
=
this
->
readX
(
workspaceIndex
);
const
double
xfront
=
dataX
.
front
();
const
double
xback
=
dataX
.
back
();
if
(
boost
::
math
::
isfinite
(
xfront
)
&&
boost
::
math
::
isfinite
(
xback
))
{
if
(
std
::
isfinite
(
xfront
)
&&
std
::
isfinite
(
xback
))
{
if
(
xfront
<
xmin
)
xmin
=
xfront
;
if
(
xback
>
xmax
)
...
...
@@ -1019,8 +1019,8 @@ bool MatrixWorkspace::isCommonBins() const {
}
// handle Nan's and inf's
if
((
boost
::
math
::
isinf
(
first
)
!=
boost
::
math
::
isinf
(
last
))
||
(
boost
::
math
::
isnan
(
first
)
!=
boost
::
math
::
isnan
(
last
)))
{
if
((
std
::
isinf
(
first
)
!=
std
::
isinf
(
last
))
||
(
std
::
isnan
(
first
)
!=
std
::
isnan
(
last
)))
{
m_isCommonBinsFlag
=
false
;
}
}
...
...
Framework/API/src/NumericAxis.cpp
View file @
297d9d0a
...
...
@@ -6,7 +6,7 @@
#include
"MantidKernel/VectorHelper.h"
#include
<boost/format.hpp>
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
#include
"MantidKernel/Logger.h"
namespace
{
...
...
@@ -16,9 +16,9 @@ class EqualWithinTolerance {
public:
explicit
EqualWithinTolerance
(
double
tolerance
)
:
m_tolerance
(
tolerance
){};
bool
operator
()(
double
a
,
double
b
)
{
if
(
boost
::
math
::
isnan
(
a
)
&&
boost
::
math
::
isnan
(
b
))
if
(
std
::
isnan
(
a
)
&&
std
::
isnan
(
b
))
return
true
;
if
(
boost
::
math
::
isinf
(
a
)
&&
boost
::
math
::
isinf
(
b
))
if
(
std
::
isinf
(
a
)
&&
std
::
isinf
(
b
))
return
true
;
return
std
::
abs
(
a
-
b
)
<=
m_tolerance
;
}
...
...
Framework/API/src/Run.cpp
View file @
297d9d0a
...
...
@@ -443,7 +443,7 @@ void Run::calculateGoniometerMatrix() {
getLogAsSingleValue
(
axisName
,
Kernel
::
Math
::
Maximum
);
const
double
angle
=
getLogAsSingleValue
(
axisName
,
Kernel
::
Math
::
Mean
);
if
(
minAngle
!=
maxAngle
&&
!
(
boost
::
math
::
isnan
(
minAngle
)
&&
boost
::
math
::
isnan
(
maxAngle
)))
{
!
(
std
::
isnan
(
minAngle
)
&&
std
::
isnan
(
maxAngle
)))
{
const
double
lastAngle
=
getLogAsSingleValue
(
axisName
,
Kernel
::
Math
::
LastValue
);
g_log
.
warning
(
"Goniometer angle changed in "
+
axisName
+
" log from "
+
...
...
Framework/Algorithms/src/MedianDetectorTest.cpp
View file @
297d9d0a
...
...
@@ -2,7 +2,7 @@
#include
"MantidAPI/HistogramValidator.h"
#include
"MantidKernel/BoundedValidator.h"
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
namespace
Mantid
{
namespace
Algorithms
{
...
...
@@ -347,7 +347,7 @@ int MedianDetectorTest::doDetectorTests(
const
double
signal
=
countsWS
->
y
(
hists
.
at
(
i
))[
0
];
// Mask out NaN and infinite
if
(
boost
::
math
::
isinf
(
signal
)
||
boost
::
math
::
isnan
(
signal
))
{
if
(
!
std
::
isfinite
(
signal
))
{
maskWS
->
mutableY
(
hists
.
at
(
i
))[
0
]
=
deadValue
;
PARALLEL_ATOMIC
++
numFailed
;
...
...
Framework/Algorithms/src/TOFSANSResolutionByPixel.cpp
View file @
297d9d0a
...
...
@@ -13,7 +13,6 @@
#include
"MantidKernel/UnitFactory.h"
#include
"MantidKernel/make_unique.h"
#include
"boost/math/special_functions/fpclassify.hpp"
#include
"boost/lexical_cast.hpp"
namespace
Mantid
{
...
...
Framework/Crystal/src/IntegratePeaksHybrid.cpp
View file @
297d9d0a
...
...
@@ -51,7 +51,7 @@
#include
"MantidDataObjects/PeaksWorkspace.h"
#include
<boost/format.hpp>
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
...
...
@@ -232,7 +232,7 @@ void IntegratePeaksHybrid::exec() {
const
Mantid
::
signal_t
signalValue
=
localProjection
.
signalAtPeakCenter
(
peak
);
// No normalization when extracting label ids!
if
(
boost
::
math
::
isnan
(
signalValue
))
{
if
(
std
::
isnan
(
signalValue
))
{
g_log
.
warning
()
<<
"Warning: image for integration is off edge of detector for peak "
<<
i
<<
'\n'
;
...
...
Framework/Crystal/src/IntegratePeaksUsingClusters.cpp
View file @
297d9d0a
...
...
@@ -13,7 +13,7 @@
#include
"MantidKernel/Utils.h"
#include
"MantidDataObjects/PeaksWorkspace.h"
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Kernel
;
...
...
@@ -156,7 +156,7 @@ void IntegratePeaksUsingClusters::exec() {
Geometry
::
IPeak
&
peak
=
peakWS
->
getPeak
(
i
);
const
Mantid
::
signal_t
signalValue
=
projection
.
signalAtPeakCenter
(
peak
);
// No normalization when extracting label ids!
if
(
boost
::
math
::
isnan
(
signalValue
))
{
if
(
std
::
isnan
(
signalValue
))
{
g_log
.
warning
()
<<
"Warning: image for integration is off edge of detector for peak "
<<
i
<<
'\n'
;
...
...
Framework/Crystal/src/PeakIntegration.cpp
View file @
297d9d0a
...
...
@@ -11,7 +11,7 @@
#include
"MantidKernel/ArrayProperty.h"
#include
"MantidKernel/VisibleWhenProperty.h"
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
#include
<boost/math/special_functions/round.hpp>
namespace
Mantid
{
...
...
@@ -250,7 +250,7 @@ void PeakIntegration::exec() {
// Calculate intensity
for
(
iTOF
=
0
;
iTOF
<
n
;
iTOF
++
)
if
(
!
boost
::
math
::
isnan
(
y
[
iTOF
])
&&
!
boost
::
math
::
isinf
(
y
[
iTOF
]))
if
(
std
::
isfinite
(
y
[
iTOF
]))
I
+=
y
[
iTOF
];
}
else
for
(
iTOF
=
TOFmin
;
iTOF
<=
TOFmax
;
iTOF
++
)
...
...
Framework/Crystal/src/SaveHKL.cpp
View file @
297d9d0a
...
...
@@ -11,7 +11,7 @@
#include
<fstream>
#include
<Poco/File.h>
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
using
namespace
Mantid
::
Geometry
;
using
namespace
Mantid
::
DataObjects
;
...
...
@@ -321,8 +321,7 @@ void SaveHKL::exec() {
for
(
auto
wi
:
ids
)
{
Peak
&
p
=
peaks
[
wi
];
if
(
p
.
getIntensity
()
==
0.0
||
boost
::
math
::
isnan
(
p
.
getIntensity
())
||
boost
::
math
::
isnan
(
p
.
getSigmaIntensity
()))
{
if
(
p
.
getIntensity
()
==
0.0
||
!
(
std
::
isfinite
(
p
.
getSigmaIntensity
())))
{
banned
.
insert
(
wi
);
continue
;
}
...
...
Framework/Crystal/src/SaveLauenorm.cpp
View file @
297d9d0a
...
...
@@ -10,7 +10,7 @@
#include
<fstream>
#include
<Poco/File.h>
#include
<Poco/Path.h>
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
using
namespace
Mantid
::
Geometry
;
using
namespace
Mantid
::
DataObjects
;
...
...
@@ -119,8 +119,7 @@ void SaveLauenorm::exec() {
Peak
&
p
=
peaks
[
wi
];
double
intensity
=
p
.
getIntensity
();
double
sigI
=
p
.
getSigmaIntensity
();
if
(
intensity
==
0.0
||
boost
::
math
::
isnan
(
intensity
)
||
boost
::
math
::
isnan
(
sigI
))
if
(
intensity
==
0.0
||
!
(
std
::
isfinite
(
sigI
)))
continue
;
if
(
minIsigI
!=
EMPTY_DBL
()
&&
intensity
<
std
::
abs
(
minIsigI
*
sigI
))
continue
;
...
...
Framework/Crystal/src/TOFExtinction.cpp
View file @
297d9d0a
...
...
@@ -7,7 +7,7 @@
#include
"MantidKernel/Utils.h"
#include
"MantidKernel/ListValidator.h"
#include
<fstream>
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
using
namespace
Mantid
::
Geometry
;
using
namespace
Mantid
::
DataObjects
;
...
...
@@ -168,7 +168,7 @@ void TOFExtinction::exec() {
double
ys
=
fsq
/
y_corr
;
// std::cout << fsq << " " << y_corr<<" "<<wl<<" "<<twoth<<" "<<tbar<< "
// " << ys <<"\n";
if
(
!
boost
::
math
::
isnan
(
ys
))
if
(
!
std
::
isnan
(
ys
))
peak1
.
setIntensity
(
ys
);
else
peak1
.
setIntensity
(
0.0
);
...
...
Framework/Crystal/test/PeakClusterProjectionTest.h
View file @
297d9d0a
...
...
@@ -16,8 +16,7 @@
#include
"MantidTestHelpers/ComponentCreationHelper.h"
#include
"MantidKernel/UnitLabelTypes.h"
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<math.h>
#include
<cmath>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Geometry
;
...
...
@@ -139,7 +138,7 @@ public:
Mantid
::
signal_t
value
=
projection
.
signalAtPeakCenter
(
outOfBoundsPeak
);
TSM_ASSERT
(
"Should indicate is out of bounds via a NAN."
,
boost
::
math
::
isnan
(
value
));
std
::
isnan
(
value
));
}
void
test_labelAtPeakCenter_with_peak_at_0_0_0
()
{
...
...
@@ -207,7 +206,7 @@ public:
PeakClusterProjection
projection
(
inWS
);
Mantid
::
signal_t
value
=
projection
.
signalAtPeakCenter
(
outOfBoundsPeak
);
TS_ASSERT
(
boost
::
math
::
isnan
(
value
));
TS_ASSERT
(
std
::
isnan
(
value
));
}
};
...
...
Framework/DataHandling/inc/MantidDataHandling/AsciiPointBase.h
View file @
297d9d0a
...
...
@@ -62,10 +62,6 @@ private:
void
init
()
override
;
/// Overwrites Algorithm method
void
exec
()
override
;
/// returns true if the value is NaN
bool
checkIfNan
(
const
double
&
value
)
const
;
/// returns true if the value if + or - infinity
bool
checkIfInfinite
(
const
double
&
value
)
const
;
/// print the appropriate value to file
void
outputval
(
double
val
,
std
::
ofstream
&
file
,
bool
leadingSep
=
true
);
/// write the top of the file
...
...
Framework/DataHandling/src/AsciiPointBase.cpp
View file @
297d9d0a
...
...
@@ -13,8 +13,7 @@ GUI
#include
<boost/tokenizer.hpp>
#include
<boost/regex.hpp>
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<cmath>
#include
<fstream>
namespace
Mantid
{
...
...
@@ -112,8 +111,8 @@ void AsciiPointBase::data(std::ofstream &file, const std::vector<double> &XData,
*/
void
AsciiPointBase
::
outputval
(
double
val
,
std
::
ofstream
&
file
,
bool
leadingSep
)
{
bool
nancheck
=
checkIfN
an
(
val
);
bool
infcheck
=
checkIfInfinite
(
val
);
bool
nancheck
=
std
::
isn
an
(
val
);
bool
infcheck
=
std
::
isinf
(
val
);
if
(
leadingSep
)
{
file
<<
sep
();
}
...
...
@@ -128,18 +127,5 @@ void AsciiPointBase::outputval(double val, std::ofstream &file,
}
}
/** checks if a value is Not A Number
* @returns boolean true if the supplied value was Not a Number
*/
bool
AsciiPointBase
::
checkIfNan
(
const
double
&
value
)
const
{
return
(
boost
::
math
::
isnan
(
value
));
}
/** checks if a value is Infinite
* @returns boolean true if the supplied value was Infinite
*/
bool
AsciiPointBase
::
checkIfInfinite
(
const
double
&
value
)
const
{
return
(
std
::
abs
(
value
)
==
std
::
numeric_limits
<
double
>::
infinity
());
}
}
// namespace DataHandling
}
// namespace Mantid
Framework/DataHandling/src/LoadNXSPE.cpp
View file @
297d9d0a
...
...
@@ -17,7 +17,6 @@
#include
"MantidGeometry/Surfaces/Sphere.h"
#include
<boost/regex.hpp>
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<map>
#include
<sstream>
...
...
@@ -290,7 +289,7 @@ void LoadNXSPE::exec() {
itdataend
=
itdata
+
numBins
;
iterrorend
=
iterror
+
numBins
;
outputWS
->
dataX
(
i
)
=
energies
;
if
((
!
boost
::
math
::
isfinite
(
*
itdata
))
||
(
*
itdata
<=
-
1e10
))
// masked bin
if
((
!
std
::
isfinite
(
*
itdata
))
||
(
*
itdata
<=
-
1e10
))
// masked bin
{
outputWS
->
dataY
(
i
)
=
std
::
vector
<
double
>
(
numBins
,
0
);
outputWS
->
dataE
(
i
)
=
std
::
vector
<
double
>
(
numBins
,
0
);
...
...
Framework/DataHandling/src/LoadQKK.cpp
View file @
297d9d0a
...
...
@@ -14,8 +14,6 @@
#include
"MantidKernel/UnitFactory.h"
#include
"MantidNexus/NexusClasses.h"
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<Poco/File.h>
#include
<fstream>
...
...
Framework/DataHandling/src/SaveGSS.cpp
View file @
297d9d0a
...
...
@@ -10,10 +10,10 @@
#include
"MantidKernel/TimeSeriesProperty.h"
#include
"MantidKernel/ListValidator.h"
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<Poco/File.h>
#include
<Poco/Path.h>
#include
<fstream>
#include
<cmath>
namespace
Mantid
{
namespace
DataHandling
{
...
...
@@ -498,8 +498,7 @@ inline void writeBankLine(std::stringstream &out, const std::string &bintype,
/** Fix error if value is less than zero or infinity
*/
inline
double
fixErrorValue
(
const
double
value
)
{
if
(
value
<=
0.
||
boost
::
math
::
isnan
(
value
)
||
boost
::
math
::
isinf
(
value
))
// Negative errors cannot be read by GSAS
if
(
value
<=
0.
||
!
std
::
isfinite
(
value
))
// Negative errors cannot be read by GSAS
return
0.
;
else
return
value
;
...
...
@@ -516,7 +515,7 @@ void SaveGSS::writeRALFdata(const int bank, const bool MultiplyByBinWidth,
double
bc2
=
(
X
[
1
]
-
X
[
0
])
*
32
;
// Logarithmic step
double
bc4
=
(
X
[
1
]
-
X
[
0
])
/
X
[
0
];
if
(
boost
::
math
::
isnan
(
fabs
(
bc4
))
||
boost
::
math
::
isinf
(
bc4
))
if
(
!
std
::
isfinite
(
bc4
))
bc4
=
0
;
// If X is zero for BANK
// Write out the data header
...
...
Framework/DataHandling/src/SaveSPE.cpp
View file @
297d9d0a
...
...
@@ -12,7 +12,7 @@
#include
"MantidKernel/CompositeValidator.h"
#include
"Poco/File.h"
#include
<
boost/math/special_functions/fpclassify.hpp
>
#include
<
cmath
>
#include
<cstdio>
#include
<cmath>
...
...
@@ -272,7 +272,7 @@ void SaveSPE::check_and_copy_spectra(const MantidVec &inSignal,
Error
.
resize
(
inSignal
.
size
());
}
for
(
size_t
i
=
0
;
i
<
inSignal
.
size
();
i
++
)
{
if
(
boost
::
math
::
isnan
(
inSignal
[
i
])
||
boost
::
math
::
isinf
(
inSignal
[
i
]))
{
if
(
!
std
::
isfinite
(
inSignal
[
i
]))
{
Signal
[
i
]
=
SaveSPE
::
MASK_FLAG
;
Error
[
i
]
=
SaveSPE
::
MASK_ERROR
;
}
else
{
...
...
Framework/DataHandling/test/SaveNXSPETest.h
View file @
297d9d0a
...
...
@@ -11,7 +11,6 @@
#include
"MantidDataHandling/LoadInstrument.h"
#include
"MantidTestHelpers/ComponentCreationHelper.h"
#include
<boost/math/special_functions/fpclassify.hpp>
#include
<boost/shared_array.hpp>
#include
"boost/tuple/tuple.hpp"
...
...
@@ -73,7 +72,7 @@ public:
TS_ASSERT_DELTA
(
9.0
,
signal
[
9
],
tolerance
);
TS_ASSERT_DELTA
(
18.0
,
error
[
9
],
tolerance
);
// element 1,2 in 2D flat buffer
TS_ASSERT
(
boost
::
math
::
isnan
(
signal
[
1
*
dims
[
1
]
+
2
]));
TS_ASSERT
(
std
::
isnan
(
signal
[
1
*
dims
[
1
]
+
2
]));
TS_ASSERT_DELTA
(
0.0
,
error
[
1
*
dims
[
1
]
+
2
],
tolerance
);
// final element
TS_ASSERT_DELTA
(
29.0
,
signal
[
dims
[
0
]
*
dims
[
1
]
-
1
],
tolerance
);
...
...
@@ -99,7 +98,7 @@ public:
TS_ASSERT_DELTA
(
99.0
,
signal
[
99
],
tolerance
);
TS_ASSERT_DELTA
(
198.0
,
error
[
99
],
tolerance
);
// element 1,2 in 2D flat buffer
TS_ASSERT
(
boost
::
math
::
isnan
(
signal
[
1
*
dims
[
1
]
+
2
]));
TS_ASSERT
(
std
::
isnan
(
signal
[
1
*
dims
[
1
]
+
2
]));
TS_ASSERT_DELTA
(
0.0
,
error
[
1
*
dims
[
1
]
+
2
],
tolerance
);
// final element
TS_ASSERT_DELTA
(
524999.0
,
signal
[
dims
[
0
]
*
dims
[
1
]
-
1
],
tolerance
);
...
...
Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.tcc
View file @
297d9d0a
...
...
@@ -908,7 +908,7 @@ TMDE(API::IMDWorkspace::LinePlot MDEventWorkspace)
if (!box->getIsMasked()) {
line.x.push_back(line_pos);
signal_t signal = this->getNormalizedSignal(box, normalize);
if (
boost::math
::isinf(signal)) {
if (
std
::isinf(signal)) {
// The plotting library (qwt) doesn't like infs.
signal = std::numeric_limits<signal_t>::quiet_NaN();
}
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment