checks for the existence of finite(x) and isinf(x) built into app/gpsymreg.

Linux gcc compilers have the 'macros ??' but solaris gcc does not
This commit is contained in:
jeggermo 2001-06-29 12:15:15 +00:00
commit 375568853a
2 changed files with 6 additions and 0 deletions

View file

@ -203,10 +203,13 @@ class RegFitness: public eoEvalFunc< eoParseTree<FType, TreeNode> >
fit += pow(target - output, 2); fit += pow(target - output, 2);
} }
// check if the fitness is valid // check if the fitness is valid
// some versions of gcc (e.g. 2.95.2 on solaris) don't have isinf(x) defined
#ifdef isinf
if (isinf(fit) == 0) if (isinf(fit) == 0)
fitness[NORMAL] = fit; fitness[NORMAL] = fit;
else else
fitness[NORMAL] = MAXFLOAT; fitness[NORMAL] = MAXFLOAT;
#endif
fitness[SMALLESTSIZE] = _eo.size() / (1.0*parameter.MaxSize); fitness[SMALLESTSIZE] = _eo.size() / (1.0*parameter.MaxSize);
_eo.fitness(fitness); _eo.fitness(fitness);

View file

@ -161,8 +161,11 @@ class Node
} }
// if the result is infinite (positive or negative) or not_a_number (nan) then result becomes 0 // if the result is infinite (positive or negative) or not_a_number (nan) then result becomes 0
// however some versions of gcc (e.g. 2.95.2 on solaris) don't have the finite(x) defined
#ifdef finite
if (!finite(result)) if (!finite(result))
result=0; result=0;
#endif
} }
template<class Children> template<class Children>