Skip to content

Commit

Permalink
Change the definition of min & max to ignore nan on any side of the c…
Browse files Browse the repository at this point in the history
…omparison. For ravel #175.
  • Loading branch information
highperformancecoder committed May 14, 2024
1 parent 85a1162 commit 2edc31c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions engine/evalOp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ namespace minsky

template <>
double EvalOp<OperationType::min>::evaluate(double in1, double in2) const
{return std::min(in1,in2);}
{
if (isnan(in1)) return in2; // see ravel #175
if (isnan(in2)) return in1;
return std::min(in1,in2);
}
template <>
double EvalOp<OperationType::min>::d1(double x1, double x2) const
{return x1<=x2;} // TODO: thow exception if x1==x2?
Expand All @@ -366,7 +370,11 @@ namespace minsky

template <>
double EvalOp<OperationType::max>::evaluate(double in1, double in2) const
{return std::max(in1,in2);}
{
if (isnan(in1)) return in2; // see ravel #175
if (isnan(in2)) return in1;
return std::max(in1,in2);
}
template <>
double EvalOp<OperationType::max>::d1(double x1, double x2) const
{return x1>x2;} // TODO: thow exception if x1==x2?
Expand Down

0 comments on commit 2edc31c

Please sign in to comment.