QUGaR 0.0.4
Loading...
Searching...
No Matches
qugar::Tolerance Class Reference

Class for tolerance related computations. More...

#include <tolerance.hpp>

Public Member Functions

 Tolerance (const real value)
 Constructor.
 
 Tolerance (const real tol_0, const real tol_1)
 Constructor. Creates a new class instance using the largest of the two given tolerances.
 
 Tolerance (const Tolerance &tol_0, const Tolerance &tol_1)
 Constructor. Creates a new class instance using the largest of the two given tolerances.
 
 Tolerance ()
 Default constructor. It initalizes the class instance with a near epsilon tolerance.
 
void update (const real tol)
 Resets the tolerance value as the maximum between the current tolerance_ and tol.
 
void update (const Tolerance &tol)
 Resets the tolerance value as the maximum between the current tolerance_ and tol.
 
real value () const
 Returns the real tolerance value.
 
bool is_zero (const real val) const
 Check if val is zero up to tolerance.
 
bool is_negative (const real val) const
 Check if val is negative.
 
bool is_positive (const real val) const
 Check if val is positive.
 
bool equal (const real lhs, const real rhs) const
 Compares if two values are equal up to tolerance.
 
bool equal_rel (const real lhs, const real rhs) const
 Compares if two values are equal up to tolerance relative to the larger of the two arguments.
 
bool equal_rel (const real lhs, const real rhs, const Tolerance &rel_tolerance) const
 Compares if two values are equal up to the different absolute and relative tolerances.
 
bool greater_than (const real lhs, const real rhs) const
 Compares if a value is greater than other up to tolerance.
 
bool greater_equal_than (const real lhs, const real rhs) const
 Compares if a value is greater or equal than other up to tolerance.
 
bool greater_than_rel (const real lhs, const real rhs) const
 Compares if a value is greater than other up to tolerance relative to the larger of the two argumetns.
 
bool smaller_than (const real lhs, const real rhs) const
 Compares if a value is smaller than other up to tolerance.
 
bool smaller_equal_than (const real lhs, const real rhs) const
 Compares if a value is smaller or equal than other up to tolerance.
 
bool smaller_than_rel (const real lhs, const real rhs) const
 Compares if a value is smaller than other up to tolerance relative to the larger of the two argumetns.
 
void unique (std::vector< real > &values) const
 Makes the given values unique up to tolerance. values will be also sorted.
 
template<int dim, typename T >
bool coincident (const Point< dim, T > &pt_0, const Point< dim, T > &pt_1) const
 Checks if two points are coincident.
 

Private Attributes

real tolerance_
 Tolerance value.
 

Detailed Description

Class for tolerance related computations.

Constructor & Destructor Documentation

◆ Tolerance() [1/4]

qugar::Tolerance::Tolerance ( const real value)
explicit

Constructor.

Parameters
valueTolerance value (it must be greater than zero).

◆ Tolerance() [2/4]

qugar::Tolerance::Tolerance ( const real tol_0,
const real tol_1 )
explicit

Constructor. Creates a new class instance using the largest of the two given tolerances.

Parameters
tol_0First tolerance.
tol_1Second tolerance.

◆ Tolerance() [3/4]

qugar::Tolerance::Tolerance ( const Tolerance & tol_0,
const Tolerance & tol_1 )
explicit

Constructor. Creates a new class instance using the largest of the two given tolerances.

Parameters
tol_0First tolerance.
tol_1Second tolerance.

◆ Tolerance() [4/4]

qugar::Tolerance::Tolerance ( )
explicit

Default constructor. It initalizes the class instance with a near epsilon tolerance.

Member Function Documentation

◆ coincident()

template<int dim, typename T >
bool qugar::Tolerance::coincident ( const Point< dim, T > & pt_0,
const Point< dim, T > & pt_1 ) const
inlinenodiscard

Checks if two points are coincident.

This function compares two points of the same dimension and type to determine if they are coincident. Two points are considered coincident if all their corresponding coordinates are equal up to tolerance.

Template Parameters
dimThe dimension of the points.
TThe type of the coordinates of the points.
Parameters
pt_0The first point to compare.
pt_1The second point to compare.
Returns
true if the points are coincident, false otherwise.
Here is the call graph for this function:

◆ equal()

bool qugar::Tolerance::equal ( const real lhs,
const real rhs ) const
nodiscard

Compares if two values are equal up to tolerance.

It checks \(|lhs -rhs| \leq tolerance\)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether both arguments are equal up to tolerance.
Here is the caller graph for this function:

◆ equal_rel() [1/2]

bool qugar::Tolerance::equal_rel ( const real lhs,
const real rhs ) const
nodiscard

Compares if two values are equal up to tolerance relative to the larger of the two arguments.

It checks \(|lhs -rhs| \leq tolerance \max (|lhs|, |rhs|) \)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether both arguments are relatively equal up to tolerance.

◆ equal_rel() [2/2]

bool qugar::Tolerance::equal_rel ( const real lhs,
const real rhs,
const Tolerance & rel_tolerance ) const
nodiscard

Compares if two values are equal up to the different absolute and relative tolerances.

It checks \(|lhs -rhs| \leq (tolerance + rel_tolerance \max (|lhs|, |rhs|)) \) where \(tolerance\) is the current tolerance and \(rel_tolerance\) is the one provided as input.

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
rel_toleranceRelative tolerance.
Returns
Whether both arguments are relatively equal up to tolerance.

◆ greater_equal_than()

bool qugar::Tolerance::greater_equal_than ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is greater or equal than other up to tolerance.

It checks \((lhs - rhs) > tolerance\) or \(|rhs - lhs| < tolerance\).

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is greater or equal than rhs up to tolerance.

◆ greater_than()

bool qugar::Tolerance::greater_than ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is greater than other up to tolerance.

It checks \((lhs - rhs) > tolerance\)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is greater than rhs up to tolerance.

◆ greater_than_rel()

bool qugar::Tolerance::greater_than_rel ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is greater than other up to tolerance relative to the larger of the two argumetns.

It checks \((lhs - rhs) > tolerance \max (|lhs|, |rhs|)\)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is relatively greater than rhs up to tolerance.

◆ is_negative()

bool qugar::Tolerance::is_negative ( const real val) const
nodiscard

Check if val is negative.

It checks \(val \leq -tolerance\)

Parameters
valValue to be checked.
Returns
Whether val is negative up to tolerance.

◆ is_positive()

bool qugar::Tolerance::is_positive ( const real val) const
nodiscard

Check if val is positive.

It checks \(tolerance < val\)

Parameters
valValue to be checked.
Returns
Whether val is positive up to tolerance.

◆ is_zero()

bool qugar::Tolerance::is_zero ( const real val) const
nodiscard

Check if val is zero up to tolerance.

It checks \(|val| \leq tolerance\)

Parameters
valValue to be checked.
Returns
Whether val is equal to zero up to tolerance.

◆ smaller_equal_than()

bool qugar::Tolerance::smaller_equal_than ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is smaller or equal than other up to tolerance.

It checks \((rhs - lhs) > tolerance\) or \(|rhs - lhs| < tolerance\).

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is smaller or equal than rhs up to tolerance.

◆ smaller_than()

bool qugar::Tolerance::smaller_than ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is smaller than other up to tolerance.

It checks \((rhs - lhs) > tolerance\)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is smaller than rhs up to tolerance.

◆ smaller_than_rel()

bool qugar::Tolerance::smaller_than_rel ( const real lhs,
const real rhs ) const
nodiscard

Compares if a value is smaller than other up to tolerance relative to the larger of the two argumetns.

It checks \((rhs - lhs) > tolerance \max (|lhs|, |rhs|)\)

Parameters
lhsLeft-hand-side value in the comparison.
rhsRight-hand-side value in the comparison.
Returns
Whether lhs is relatively smaller than rhs up to tolerance.

◆ unique()

void qugar::Tolerance::unique ( std::vector< real > & values) const

Makes the given values unique up to tolerance. values will be also sorted.

Parameters
valuesVector of value of make unique.

◆ update() [1/2]

void qugar::Tolerance::update ( const real tol)

Resets the tolerance value as the maximum between the current tolerance_ and tol.

Parameters
tolTolerance value to be reset.

◆ update() [2/2]

void qugar::Tolerance::update ( const Tolerance & tol)

Resets the tolerance value as the maximum between the current tolerance_ and tol.

Parameters
tolTolerance value to be reset.

◆ value()

real qugar::Tolerance::value ( ) const
nodiscard

Returns the real tolerance value.

Returns
Tolerance real value.

Member Data Documentation

◆ tolerance_

real qugar::Tolerance::tolerance_
private

Tolerance value.


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