SpatialOps
FieldComparisons.h File Reference

Comparison operators. More...

#include <spatialops/Nebo.h>
#include <spatialops/structured/SpatialFieldStore.h>
#include <sstream>
#include <cmath>
#include <boost/math/special_functions/next.hpp>
Include dependency graph for FieldComparisons.h:

Go to the source code of this file.

Classes

class  SpatialOps::FieldComparisonHelper< FieldT >
 static helper class for field comparison functions More...
 
class  SpatialOps::FieldComparisonHelper< FieldT >
 static helper class for field comparison functions More...
 

Functions

template<typename FieldT >
bool SpatialOps::field_not_equal (const FieldT &f1, const FieldT &f2, double error=0.0)
 Returns if f1 is element-wise not equal to f2 within a certain relative tolerance.This function simply calls field_equal and negates it. return !field_equal(f1, f2, error, error_abs); error_abs is defined as default to be the L2 norm of f1 multiplied by error and FIELDCOMPARISONS_ABS_ERROR_CONST. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal (const FieldT &f1, const FieldT &f2, double error, const double error_abs)
 Returns if f1 is element-wise not equal to f2 within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal (const FieldT &f1, const FieldT &f2, double error=0.0)
 Returns if f1 is element-wise equal to f2 within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal (const FieldT &f1, const FieldT &f2, double error, const double errorAbs)
 Determines if f1 is element-wise equal to f2 within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal_abs (const FieldT &f1, const FieldT &f2, double error=0.0)
 Returns if f1 is element-wise not equal to f2 within a certain absolute tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal_abs (const FieldT &f1, const FieldT &f2, double error=0.0)
 Returns if f1 is element-wise equal to f2 within a certain absolute tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal_ulp (const FieldT &f1, const FieldT &f2, const unsigned int ulps)
 Returns if f1 is element-wise not equal to f2 within a certain number of ulps. More...
 
template<typename FieldT >
bool SpatialOps::field_equal_ulp (const FieldT &f1, const FieldT &f2, const unsigned int ulps)
 Returns if f1 is element-wise equal to f2 within a certain number of ulps. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal (const double d, const FieldT &f1, double error=0.0)
 Returns if f1 is element-wise not equal to the scalar value d within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal (const double d, const FieldT &f1, double error, const double error_abs)
 Returns if f1 is element-wise not equal to the scalar value d within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal (const double d, const FieldT &f1, double error=0.0)
 Returns if f1 is element-wise equal to the scalar value d within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal (const double d, const FieldT &f1, double error, const double errorAbs)
 Returns if f1 is element-wise equal to the scalar value d within a certain relative tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal_abs (const double d, const FieldT &f1, const double error=0.0)
 Returns if f1 is element-wise not equal to Scalar value d within a certain absolute tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_equal_abs (const double d, const FieldT &f1, double error=0.0)
 Returns if f1 is element-wise equal to Scalar value d within a certain absolute tolerance. More...
 
template<typename FieldT >
bool SpatialOps::field_not_equal_ulp (const double d, const FieldT &f1, const unsigned int ulps)
 Returns if f1 is element-wise not equal to Scalar value d within a certain number of ulps. More...
 
template<typename FieldT >
bool SpatialOps::field_equal_ulp (const double d, const FieldT &f1, const unsigned int ulps)
 Returns if f1 is element-wise equal to Scalar value d within a certain number of ulps. More...
 

Detailed Description

Comparison operators.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Definition in file FieldComparisons.h.

Function Documentation

◆ field_equal() [1/3]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_equal ( const FieldT &  f1,
const FieldT &  f2,
double  error = 0.0 
)

Returns if f1 is element-wise equal to f2 within a certain relative tolerance.

This function returns the result of |f1 - f2|/(error_abs + |f1|) > error element wise. error_abs is defined as default to be the L2 norm of f1 multiplied by error and FIELDCOMPARISONS_ABS_ERROR_CONST.

WARNING: Undefined behavior if f1 is a field of all 0's.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
error– Allowable percentage of error. i.e. 1% = .01

Definition at line 113 of file FieldComparisons.h.

◆ field_equal() [2/3]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_equal ( const FieldT &  f1,
const FieldT &  f2,
double  error,
const double  errorAbs 
)

Determines if f1 is element-wise equal to f2 within a certain relative tolerance.

This function returns the result of |f1 - f2|/(error_abs + |f1|) > error element wise.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
error– Allowable percentage of error. i.e. 1% = .01
errorAbs– Allowable absolute error. This term becomes significant in the calculation as f1 approaches zero.

Definition at line 136 of file FieldComparisons.h.

◆ field_equal() [3/3]

template<typename FieldT >
bool SpatialOps::field_equal ( const double  d,
const FieldT &  f1,
double  error = 0.0 
)

Returns if f1 is element-wise equal to the scalar value d within a certain relative tolerance.

This function returns the result of |d - f1|/(error_abs + |d|) > error element wise. error_abs is defined as default to be the L2 norm of f1 multiplied by error and FIELDCOMPARISONS_ABS_ERROR_CONST.

WARNING: Undefined behavior if f1 is a field of all 0's.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
error– Allowable percentage of error. i.e. 1% = .01

Definition at line 368 of file FieldComparisons.h.

◆ field_equal_abs() [1/2]

template<typename FieldT >
bool SpatialOps::field_equal_abs ( const FieldT &  f1,
const FieldT &  f2,
double  error = 0.0 
)

Returns if f1 is element-wise equal to f2 within a certain absolute tolerance.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
error– Allowable absolute value of error.

Definition at line 201 of file FieldComparisons.h.

References SpatialOps::field_equal_abs().

Referenced by SpatialOps::field_equal_abs(), and SpatialOps::field_not_equal_abs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_equal_abs() [2/2]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_equal_abs ( const double  d,
const FieldT &  f1,
double  error = 0.0 
)

Returns if f1 is element-wise equal to Scalar value d within a certain absolute tolerance.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
error– Allowable absolute value of error.

Definition at line 452 of file FieldComparisons.h.

References SpatialOps::field_equal_abs().

Here is the call graph for this function:

◆ field_equal_ulp() [1/2]

template<typename FieldT >
bool SpatialOps::field_equal_ulp ( const FieldT &  f1,
const FieldT &  f2,
const unsigned int  ulps 
)

Returns if f1 is element-wise equal to f2 within a certain number of ulps.

This function determines the amount of ulps two floating point numbers are off and compares them to the allowed tolerance. Ulp stands for Unit in the Last Place and is a measure of rounding error in floating point numbers. A more detailed article can be found at: http://en.wikipedia.org/wiki/Unit_in_the_last_place

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
ulps– Allowable difference in ulps

Definition at line 270 of file FieldComparisons.h.

References SpatialOps::field_equal_ulp().

Referenced by SpatialOps::field_equal_ulp(), and SpatialOps::field_not_equal_ulp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_equal_ulp() [2/2]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_equal_ulp ( const double  d,
const FieldT &  f1,
const unsigned int  ulps 
)

Returns if f1 is element-wise equal to Scalar value d within a certain number of ulps.

This function determines the amount of ulps two floating point numbers are off and compares them to the allowed tolerance. Ulp stands for Unit in the Last Place and is a measure of rounding error in floating point numbers. A more detailed article can be found at: http://en.wikipedia.org/wiki/Unit_in_the_last_place

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
ulps– Allowable difference in ulps

Definition at line 517 of file FieldComparisons.h.

References SpatialOps::field_equal_ulp().

Here is the call graph for this function:

◆ field_not_equal() [1/3]

template<typename FieldT >
bool SpatialOps::field_not_equal ( const FieldT &  f1,
const FieldT &  f2,
double  error,
const double  error_abs 
)

Returns if f1 is element-wise not equal to f2 within a certain relative tolerance.

This function simply calls field_equal and negates it. return !field_equal(f1, f2, error, error_abs);

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
error– Allowable percentage of error. i.e. 1% = .01
error_abs– Allowable absolute error passed on to field_equal

Definition at line 88 of file FieldComparisons.h.

References SpatialOps::field_equal(), and SpatialOps::field_not_equal().

Here is the call graph for this function:

◆ field_not_equal() [2/3]

template<typename FieldT >
bool SpatialOps::field_not_equal ( const double  d,
const FieldT &  f1,
double  error = 0.0 
)

Returns if f1 is element-wise not equal to the scalar value d within a certain relative tolerance.

This function simply calls field_equal and negates it. return !field_equal(d, f1, error, error_abs); error_abs is defined as default to be the L2 norm of f1 multiplied by error and FIELDCOMPARISONS_ABS_ERROR_CONST.

WARNING: Undefined behavior if f1 is a field of all 0's.

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
error– Allowable percentage of error. i.e. 1% = .01

Definition at line 324 of file FieldComparisons.h.

References SpatialOps::field_not_equal().

Here is the call graph for this function:

◆ field_not_equal() [3/3]

template<typename FieldT >
bool SpatialOps::field_not_equal ( const double  d,
const FieldT &  f1,
double  error,
const double  error_abs 
)

Returns if f1 is element-wise not equal to the scalar value d within a certain relative tolerance.

This function simply calls field_equal and negates it. return !field_equal(d, f1, error, error_abs);

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
error– Allowable percentage of error. i.e. 1% = .01
error_abs– Allowable absolute error passed on to field_equal

Definition at line 345 of file FieldComparisons.h.

References SpatialOps::field_equal(), and SpatialOps::field_not_equal().

Here is the call graph for this function:

◆ field_not_equal_abs() [1/2]

template<typename FieldT >
bool SpatialOps::field_not_equal_abs ( const FieldT &  f1,
const FieldT &  f2,
double  error = 0.0 
)

Returns if f1 is element-wise not equal to f2 within a certain absolute tolerance.

This function simply returns the negated result of field_equal_abs

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
error– Allowable absolute value of error.

Definition at line 184 of file FieldComparisons.h.

References SpatialOps::field_equal_abs(), and SpatialOps::field_not_equal_abs().

Referenced by SpatialOps::field_not_equal_abs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_not_equal_abs() [2/2]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_not_equal_abs ( const double  d,
const FieldT &  f1,
const double  error = 0.0 
)

Returns if f1 is element-wise not equal to Scalar value d within a certain absolute tolerance.

This function simply returns the negated result of field_equal_abs

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
error– Allowable absolute value of error.

Definition at line 433 of file FieldComparisons.h.

References SpatialOps::field_equal_abs(), and SpatialOps::field_not_equal_abs().

Here is the call graph for this function:

◆ field_not_equal_ulp() [1/2]

template<typename FieldT >
bool SpatialOps::field_not_equal_ulp ( const FieldT &  f1,
const FieldT &  f2,
const unsigned int  ulps 
)

Returns if f1 is element-wise not equal to f2 within a certain number of ulps.

This function simply returns the negated result of field_equal_ulp

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
f1– Field 1
f2– Field 2
ulps– Allowable difference in ulps

Definition at line 247 of file FieldComparisons.h.

References SpatialOps::field_equal_ulp(), and SpatialOps::field_not_equal_ulp().

Referenced by SpatialOps::field_not_equal_ulp().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ field_not_equal_ulp() [2/2]

template<typename FieldT >
template< typename FieldT > bool SpatialOps::field_not_equal_ulp ( const double  d,
const FieldT &  f1,
const unsigned int  ulps 
)

Returns if f1 is element-wise not equal to Scalar value d within a certain number of ulps.

This function simply returns the negated result of field_equal_ulp

WARNING: Slow in general and comparison with external fields will incur copy penalties.

Template Parameters
FieldT– Any type of SpatialField
Parameters
d– Scalar value
f1– Field 1
ulps– Allowable difference in ulps

Definition at line 492 of file FieldComparisons.h.

References SpatialOps::field_equal_ulp(), and SpatialOps::field_not_equal_ulp().

Here is the call graph for this function: