Skip to content

Commit

Permalink
#294 Avoid std::isinf
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizu committed Sep 27, 2018
1 parent 5acc227 commit dafc639
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions ecell4/gillespie/GillespieSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ bool GillespieSimulator::__draw_next_reaction(void)
double dt = 0.0;
unsigned int idx = 0;

if (std::isinf(atot))
if (atot == std::numeric_limits<double>::infinity())
{
std::vector<unsigned int> selected;
for (unsigned int i(0); i < a.size(); ++i)
{
if (std::isinf(a[i]))
if (a[i] == std::numeric_limits<double>::infinity())
{
selected.push_back(i);
}
Expand Down
2 changes: 1 addition & 1 deletion ecell4/gillespie/GillespieSimulator.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef ECELL4_GILLESPIE_GILLESPIE_SIMULATOR_HPP
#define ECELL4_GILLESPIE_GILLESPIE_SIMULATOR_HPP

#include <cmath>
#include <limits>
#include <stdexcept>
#include <boost/shared_ptr.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
Expand Down
4 changes: 2 additions & 2 deletions ecell4/meso/MesoscopicSimulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ MesoscopicSimulator::draw_next_reaction(const coordinate_type& c)
return std::make_pair(inf, (ReactionRuleProxyBase*)NULL);
}

if (std::isinf(atot))
if (atot == std::numeric_limits<Real>::infinity())
{
std::vector<unsigned int> selected;
for (unsigned int i(0); i < a.size(); ++i)
{
if (std::isinf(a[i]))
if (a[i] == std::numeric_limits<Real>::infinity())
{
selected.push_back(i);
}
Expand Down
2 changes: 1 addition & 1 deletion ecell4/spatiocyte/StepEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ StepEvent::attempt_reaction_(
const Real k((*itr).k());
const Real P(k * factor * alpha);
accp += P;
if (accp > 1 && !std::isinf(k))
if (accp > 1 && k != std::numeric_limits<Real>::infinity())
{
std::cerr << "The total acceptance probability [" << accp
<< "] exceeds 1 for '" << speciesA.serial()
Expand Down
3 changes: 1 addition & 2 deletions ecell4/spatiocyte/utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <cmath>
#include "utils.hpp"


Expand Down Expand Up @@ -70,7 +69,7 @@ const Real calculate_alpha(const ReactionRule& rr, const boost::shared_ptr<Spati
const ReactionRule::reactant_container_type& reactants(rr.reactants());
if (reactants.size() != 2)
return 1.0;
else if (std::isinf(rr.k()))
else if (rr.k() == std::numeric_limits<Real>::infinity())
return 1.0;

const Species species[2] = {reactants.at(0), reactants.at(1)};
Expand Down

0 comments on commit dafc639

Please sign in to comment.