QUGaR 0.0.4
|
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. | |
Class for tolerance related computations.
|
explicit |
Constructor.
value | Tolerance value (it must be greater than zero). |
Constructor. Creates a new class instance using the largest of the two given tolerances.
tol_0 | First tolerance. |
tol_1 | Second tolerance. |
Constructor. Creates a new class instance using the largest of the two given tolerances.
tol_0 | First tolerance. |
tol_1 | Second tolerance. |
|
explicit |
Default constructor. It initalizes the class instance with a near epsilon tolerance.
|
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.
dim | The dimension of the points. |
T | The type of the coordinates of the points. |
pt_0 | The first point to compare. |
pt_1 | The second point to compare. |
Compares if two values are equal up to tolerance.
It checks \(|lhs -rhs| \leq tolerance\)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
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|) \)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
|
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.
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
rel_tolerance | Relative tolerance. |
Compares if a value is greater or equal than other up to tolerance.
It checks \((lhs - rhs) > tolerance\) or \(|rhs - lhs| < tolerance\).
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is greater or equal than rhs
up to tolerance. Compares if a value is greater than other up to tolerance.
It checks \((lhs - rhs) > tolerance\)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is greater than rhs
up to tolerance. 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|)\)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is relatively greater than rhs
up to tolerance.
|
nodiscard |
Check if val
is negative.
It checks \(val \leq -tolerance\)
val | Value to be checked. |
val
is negative up to tolerance.
|
nodiscard |
Check if val
is positive.
It checks \(tolerance < val\)
val | Value to be checked. |
val
is positive up to tolerance.
|
nodiscard |
Check if val
is zero up to tolerance.
It checks \(|val| \leq tolerance\)
val | Value to be checked. |
val
is equal to zero up to tolerance. Compares if a value is smaller or equal than other up to tolerance.
It checks \((rhs - lhs) > tolerance\) or \(|rhs - lhs| < tolerance\).
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is smaller or equal than rhs
up to tolerance. Compares if a value is smaller than other up to tolerance.
It checks \((rhs - lhs) > tolerance\)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is smaller than rhs
up to tolerance. 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|)\)
lhs | Left-hand-side value in the comparison. |
rhs | Right-hand-side value in the comparison. |
lhs
is relatively smaller than rhs
up to tolerance. void qugar::Tolerance::unique | ( | std::vector< real > & | values | ) | const |
Makes the given values
unique up to tolerance. values
will be also sorted.
values | Vector of value of make unique. |
void qugar::Tolerance::update | ( | const real | tol | ) |
Resets the tolerance value as the maximum between the current tolerance_ and tol
.
tol | Tolerance value to be reset. |
void qugar::Tolerance::update | ( | const Tolerance & | tol | ) |
Resets the tolerance value as the maximum between the current tolerance_ and tol
.
tol | Tolerance value to be reset. |
|
nodiscard |
Returns the real tolerance value.