Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change from boost::math to std #20

Merged
merged 1 commit into from
May 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/AdaptiveImportanceSampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include <cmath>

#include "ndarray/eigen.h"

#define LSST_MAX_DEBUG 10
#include "lsst/pex/logging/Debug.h"
#include "lsst/utils/ieee.h"
#include "lsst/afw/table/BaseRecord.h"
#include "lsst/afw/table/Catalog.h"
#include "lsst/meas/modelfit/AdaptiveImportanceSampler.h"
Expand Down Expand Up @@ -133,7 +133,7 @@ void AdaptiveImportanceSampler::run(
for (int k = 0; k < ctrl.nSamples; ++k) {
PTR(afw::table::BaseRecord) record = samples.addNew();
double objectiveValue = objective(parameters[k], *record);
if (utils::isfinite(objectiveValue)) {
if (std::isfinite(objectiveValue)) {
subSamples.push_back(record);
record->set(_parametersKey, parameters[k]);
record->set(_objectiveKey, objectiveValue);
Expand All @@ -157,7 +157,7 @@ void AdaptiveImportanceSampler::run(
}
computeRobustWeights(subSamples, _weightKey);
perplexity = computeNormalizedPerplexity(subSamples);
if (!lsst::utils::isfinite(perplexity)) {
if (!std::isfinite(perplexity)) {
throw LSST_EXCEPT(
pex::exceptions::LogicError,
"Normalized perplexity is non-finite."
Expand Down
2 changes: 1 addition & 1 deletion src/CModel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@ class CModelAlgorithm::Impl {
keys->checkBadReferenceFlag(record);
// Check for unflagged NaNs. Warn if we see any so we can fix the underlying problem, and
// then flag them anyway.
if (lsst::utils::isnan(record.get(keys->flux)) && !record.get(keys->flags[CModelResult::FAILED])) {
if (std::isnan(record.get(keys->flux)) && !record.get(keys->flags[CModelResult::FAILED])) {
// We throw a non-MeasurementError exception so the measurement error *will* log a warning.
throw LSST_EXCEPT(
pex::exceptions::LogicError,
Expand Down
7 changes: 3 additions & 4 deletions src/MarginalSamplingInterpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/

#include "boost/math/special_functions/round.hpp"
#include <cmath>

#include "ndarray/eigen.h"

Expand Down Expand Up @@ -255,7 +254,7 @@ void UnnestMarginalSamples::apply(
marginalIter != marginalRecord.getSamples().end();
++marginalIter
) {
nNewSamplesTotal += boost::math::iround(
nNewSamplesTotal += std::lround(
_multiplier
* marginalRecord.getSamples().size()
* marginalIter->get(_marginalInterpreter->getWeightKey())
Expand All @@ -276,7 +275,7 @@ void UnnestMarginalSamples::apply(
++marginalIter
) {
Scalar marginalWeight = marginalIter->get(_marginalInterpreter->getWeightKey());
int nNewSamples = boost::math::iround(
int nNewSamples = std::lround(
_multiplier * marginalRecord.getSamples().size() * marginalWeight
);
if (nNewSamples == 0) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/PixelFitRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include <cmath>

#include "lsst/meas/modelfit/PixelFitRegion.h"
#include "lsst/utils/ieee.h"

namespace lsst { namespace meas { namespace modelfit {

Expand Down
10 changes: 5 additions & 5 deletions src/optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* the GNU General Public License along with this program. If not,
* see <http://www.lsstcorp.org/LegalNotices/>.
*/
#include <cmath>

#include "Eigen/Eigenvalues"
#include "boost/math/special_functions/erf.hpp"
Expand All @@ -28,7 +29,6 @@

#define LSST_MAX_DEBUG 10
#include "lsst/pex/logging/Debug.h"
#include "lsst/utils/ieee.h"
#include "lsst/afw/table/Catalog.h"
#include "lsst/afw/table/BaseTable.h"
#include "lsst/afw/table/BaseRecord.h"
Expand Down Expand Up @@ -196,7 +196,7 @@ void OptimizerObjective::fillObjectiveValueGrid(
if (hasPrior()) {
Scalar prior = computePrior(grid[i]);
output[i] -= std::log(prior);
if (utils::isnan(output[i])) {
if (std::isnan(output[i])) {
output[i] = std::numeric_limits<Scalar>::infinity();
}
}
Expand Down Expand Up @@ -577,7 +577,7 @@ bool Optimizer::_stepImpl(
);
_next.parameters.asEigen() = _current.parameters.asEigen() + _step.asEigen();
double stepLength = _step.asEigen().norm();
if (utils::isnan(stepLength)) {
if (std::isnan(stepLength)) {
log.debug<7>("NaN encountered in step length");
_state |= FAILED_NAN;
return false;
Expand All @@ -586,7 +586,7 @@ bool Optimizer::_stepImpl(
if (_objective->hasPrior()) {
_next.priorValue = _objective->computePrior(_next.parameters);
_next.objectiveValue = -std::log(_next.priorValue);
if (_next.priorValue <= 0.0 || utils::isnan(_next.objectiveValue)) {
if (_next.priorValue <= 0.0 || std::isnan(_next.objectiveValue)) {
_next.objectiveValue = std::numeric_limits<Scalar>::infinity();
log.debug<10>("Rejecting step due to zero prior");
if (stepLength < _trustRadius) {
Expand Down Expand Up @@ -617,7 +617,7 @@ bool Optimizer::_stepImpl(
_gradient.asEigen() + 0.5*_hessian.asEigen()*_step.asEigen()
);
double rho = actualChange / predictedChange;
if (utils::isnan(rho)) {
if (std::isnan(rho)) {
log.debug<10>("NaN encountered in rho");
_state |= FAILED_NAN;
return false;
Expand Down