Rodin/Math/Constants.h file

Mathematical constants and related utility functions.

This file provides commonly used mathematical constants with machine precision, as well as utility functions for checking special values.

Namespaces

namespace Rodin
The Rodin library for finite element methods and shape optimization.
namespace Rodin::Math
Spatial arithmetic, matrix operations, and sparse linear algebra.

Functions

auto pi() -> Real constexpr
Returns the mathematical constant $ \pi $ to machine precision.
auto epsilon() -> Real constexpr
Returns the machine epsilon for Real type.
auto zero() -> Real constexpr
Returns the value zero.
auto isZero(Real x) -> Boolean constexpr
Checks if a value is exactly zero.
auto one() -> Real constexpr
Returns the value one.
auto isOne(Real x) -> Boolean constexpr
Checks if a value is exactly one.

Function documentation

Real pi() constexpr

Returns the mathematical constant $ \pi $ to machine precision.

Returns The value of $ \pi $ as a Real

The value of $ \pi \approx 3.14159265358979323846 $ is the ratio of a circle's circumference to its diameter.

Real epsilon() constexpr

Returns the machine epsilon for Real type.

Returns The machine epsilon value

Machine epsilon is the smallest positive number $ \varepsilon $ such that $ 1 + \varepsilon \neq 1 $ in floating-point arithmetic. It represents the upper bound on relative rounding error.

Real zero() constexpr

Returns the value zero.

Returns The Real value $ 0 $

Boolean isZero(Real x) constexpr

Checks if a value is exactly zero.

Parameters
x in Value to check
Returns True if $ x = 0 $ , false otherwise

Performs an exact comparison with zero. For approximate comparisons near zero, consider using a tolerance based on epsilon().

Real one() constexpr

Returns the value one.

Returns The Real value $ 1 $

Boolean isOne(Real x) constexpr

Checks if a value is exactly one.

Parameters
x in Value to check
Returns True if $ x = 1 $ , false otherwise

Performs an exact comparison with one. For approximate comparisons, consider using a tolerance based on epsilon().