| 95 | } |
| 96 | |
| 97 | inline bool RelativeDifference(float x1, float x2, float min_x1, float & diff) |
| 98 | { |
| 99 | const float absx1 = fabs(x1); |
| 100 | const float div = std::max(absx1, min_x1); |
| 101 | const float thisDiff = fabs(x1 - x2) / div; |
| 102 | if (thisDiff > diff) |
| 103 | { |
| 104 | diff = thisDiff; |
| 105 | return true; |
| 106 | } |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | // Return true if diff has been updated. |
| 111 | inline bool ComputeDiff(float x1, float x2, bool rel, float min_x1, float & diff) |