Skip to content

Commit

Permalink
Remove FP specializations of JParameterManager::Equals
Browse files Browse the repository at this point in the history
These contain a logic error resulting in lots of spurious "loses equality after stringification" warnings.
We don't want fuzzy floating-point equality here anyhow -- we want all parameter values to be bit-for-bit exact.
See Issue #233 for discussion.
  • Loading branch information
nathanwbrei committed Oct 9, 2023
1 parent bed0c8a commit 77ef618
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/libraries/JANA/Services/JParameterManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,20 +430,14 @@ inline std::string JParameterManager::Stringify(const std::array<T,N> &values) {
return ss.str();
}

// @brief Equals() is called internally by SetDefaultParameter. This allows the user to define equivalence relations on custom data types so that
// they can silence any spurious "loses equality with itself after stringification" warnings. Generally you should try specializing Stringify and Parse
// first to normalize your data representation.
template <typename T>
inline bool JParameterManager::Equals(const T& lhs, const T& rhs) {
return lhs == rhs;
}

template <>
inline bool JParameterManager::Equals(const float& lhs, const float& rhs) {
return (std::abs(lhs-rhs) < std::abs(lhs)*std::numeric_limits<float>::epsilon());
}

template <>
inline bool JParameterManager::Equals(const double& lhs, const double& rhs) {
return (std::abs(lhs-rhs) < std::abs(lhs)*std::numeric_limits<double>::epsilon());
}

#endif // _JParameterManager_h_

Expand Down

0 comments on commit 77ef618

Please sign in to comment.