LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
Public Types | Public Member Functions | Private Attributes | List of all members
ndarray::ApproximatelyEqual< T1, T2 > Struct Template Reference

Binary predicate for floating point equality comparison with tolerance. More...

#include <types.h>

Public Types

typedef T1 first_argument_type
 
typedef T2 second_argument_type
 
typedef bool result_type
 
typedef Promote< T1, T2 >::Type Promoted
 
typedef
detail::SafeFloatingPointOps
< Promoted
Ops
 

Public Member Functions

result_type operator() (T1 a, T2 b) const
 
 ApproximatelyEqual (Promoted tolerance)
 

Private Attributes

Promoted _tolerance
 

Detailed Description

template<typename T1, typename T2 = T1>
struct ndarray::ApproximatelyEqual< T1, T2 >

Binary predicate for floating point equality comparison with tolerance.

Implementation is roughly modeled after the floating point comparisons in the Boost.Test library.

Definition at line 149 of file types.h.

Member Typedef Documentation

template<typename T1, typename T2 = T1>
typedef T1 ndarray::ApproximatelyEqual< T1, T2 >::first_argument_type

Definition at line 150 of file types.h.

template<typename T1, typename T2 = T1>
typedef detail::SafeFloatingPointOps<Promoted> ndarray::ApproximatelyEqual< T1, T2 >::Ops

Definition at line 155 of file types.h.

template<typename T1, typename T2 = T1>
typedef Promote<T1,T2>::Type ndarray::ApproximatelyEqual< T1, T2 >::Promoted

Definition at line 154 of file types.h.

template<typename T1, typename T2 = T1>
typedef bool ndarray::ApproximatelyEqual< T1, T2 >::result_type

Definition at line 152 of file types.h.

template<typename T1, typename T2 = T1>
typedef T2 ndarray::ApproximatelyEqual< T1, T2 >::second_argument_type

Definition at line 151 of file types.h.

Constructor & Destructor Documentation

template<typename T1, typename T2 = T1>
ndarray::ApproximatelyEqual< T1, T2 >::ApproximatelyEqual ( Promoted  tolerance)
inlineexplicit

Definition at line 164 of file types.h.

164 : _tolerance(Ops::abs(tolerance)) {}

Member Function Documentation

template<typename T1, typename T2 = T1>
result_type ndarray::ApproximatelyEqual< T1, T2 >::operator() ( T1  a,
T2  b 
) const
inline

Definition at line 157 of file types.h.

157  {
158  Promoted diff = Ops::abs(a - b);
159  Promoted da = Ops::divide(diff,Ops::abs(a));
160  Promoted db = Ops::divide(diff,Ops::abs(b));
161  return db <= _tolerance && da <= _tolerance;
162  }
Promote< T1, T2 >::Type Promoted
Definition: types.h:154
afw::table::Key< double > b

Member Data Documentation

template<typename T1, typename T2 = T1>
Promoted ndarray::ApproximatelyEqual< T1, T2 >::_tolerance
private

Definition at line 167 of file types.h.


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