LLNL / Silo

Mesh and Field I/O Library and Scientific Database
https://silo.llnl.gov
Other
30 stars 24 forks source link

Fix diff'ing nans #275

Closed markcmiller86 closed 2 years ago

markcmiller86 commented 2 years ago

If both operands of a diff have nans, then those always get reported as different. We should add an option to treat NaNs as equal for purposes of diffing. Some of the logic neede in src/silo/silo.c is...

int DBIsDifferentDouble(double a, double b, double abstol, double reltol, double reltol_eps)
{
   double       num, den;

   /* handle NaNs first */
   if (isnan(a))
   {
       if isnan(b) return 0;
       return 1;
   }
   else if (isnan(b))
   {
       if isnan(a) return 0;
       return 1;
   }

   /*
    * First, see if we should use the alternate diff.
    * check |A-B|/(|A|+|B|+EPS) in a way that won't overflow.
    */
   if (reltol_eps >= 0 && reltol > 0)
   {