Open CASCADE Technology Reference Manual 8.0.0
Loading...
Searching...
No Matches
Namespaces | Functions | Variables
MathUtils_Core.hxx File Reference
#include <math_Vector.hxx>
#include <cmath>
#include <algorithm>
#include <limits>

Namespaces

namespace  MathUtils
 Modern math solver types and result structures.
 

Functions

constexpr double MathUtils::Clamp (double theValue, double theLower, double theUpper)
 Clamp value to range [theLower, theUpper].
 
bool MathUtils::IsZero (double theValue, double theTolerance=THE_ZERO_TOL)
 Check if value is effectively zero.
 
bool MathUtils::IsEqual (double theA, double theB, double theTolerance=THE_ZERO_TOL)
 Check if two values are approximately equal.
 
double MathUtils::SafeDiv (double theNumerator, double theDenominator, double theDefault=0.0)
 Safe division avoiding division by zero.
 
int MathUtils::Sign (double theValue)
 Sign function.
 
double MathUtils::SignTransfer (double theA, double theB)
 Sign transfer function: returns |theA| with sign of theB. Equivalent to copysign but avoids edge cases with zero.
 
constexpr double MathUtils::Sqr (double theValue)
 Square of a value.
 
constexpr double MathUtils::Cube (double theValue)
 Cube of a value.
 
double MathUtils::CubeRoot (double theValue)
 Cube root with proper sign handling. Unlike std::cbrt, this handles negative values correctly on all platforms.
 
bool MathUtils::IsFinite (double theValue)
 Check if value is finite (not NaN or Inf).
 
double MathUtils::ComputeScaleFactor (const double *theCoeffs, int theCount)
 Compute scaling factor for coefficient normalization. Used to improve numerical stability by scaling coefficients.
 
double MathUtils::DotProduct (const math_Vector &theA, const math_Vector &theB)
 Compute dot product of two vectors.
 
double MathUtils::VectorNorm (const math_Vector &theVec)
 Compute Euclidean norm of a vector.
 
double MathUtils::VectorInfNorm (const math_Vector &theVec)
 Compute infinity norm (maximum absolute value) of a vector.
 

Variables

constexpr double MathUtils::THE_EPSILON = std::numeric_limits<double>::epsilon()
 Machine epsilon for double precision.
 
constexpr double MathUtils::THE_ZERO_TOL = 1.0e-15
 Small value for zero comparisons (more practical than epsilon).
 
constexpr double MathUtils::THE_PI = 3.14159265358979323846
 Pi constant.
 
constexpr double MathUtils::THE_2PI = 6.28318530717958647692
 Two Pi constant.
 
constexpr double MathUtils::THE_GOLDEN_RATIO = 1.618033988749895
 Golden ratio for optimization algorithms.
 
constexpr double MathUtils::THE_GOLDEN_SECTION = 0.381966011250105
 Inverse golden ratio (1 - 1/phi).