aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::AlmostDifferent< T > Struct Template Reference

Indicate whether two elements are (almost) different or not. More...

#include <utils_misc.h>

Public Member Functions

bool operator() (const T &t1, const T &t2)
 

Detailed Description

template<typename T>
struct gum::AlmostDifferent< T >

Indicate whether two elements are (almost) different or not.

Template Parameters
TThe type of the elements to compare.

Definition at line 151 of file utils_misc.h.

Member Function Documentation

◆ operator()()

template<typename T >
bool gum::AlmostDifferent< T >::operator() ( const T &  t1,
const T &  t2 
)
inline

Definition at line 152 of file utils_misc.h.

152  {
153  if (t1 == t2)
154  return false;
155  else if (t1 == 0)
156  return (std::abs(t2) > 1e-5);
157  else
158  return (std::abs(t2 - t1) / t1 > 1e-5);
159  }
Potential< GUM_SCALAR > abs(const Potential< GUM_SCALAR > &arg)
Definition: potential.h:595

The documentation for this struct was generated from the following file: