Core utilities and helper functions for modern math solvers in OCCT.
The MathUtils package provides foundational utilities used by all other modern math packages:
MathUtils_Types.hxx - Common result types and status enumsMathUtils_Config.hxx - Solver configuration structures and shared Newton/line-search constantsMathUtils_Core.hxx - Mathematical constants and helper functionsMathUtils_Convergence.hxx - Convergence testing utilitiesMathUtils_Poly.hxx - Polynomial evaluation and manipulationMathUtils_Domain.hxx - 1D/2D parameter domain helpers (contains/clamp/normalize/equality checks)MathUtils_Bracket.hxx - Root and minimum bracketing algorithms (including bounded options for minima)MathUtils_Gauss.hxx - Gauss-Legendre quadrature points and weights (orders >= 1)MathUtils_Deriv.hxx - Numerical differentiation utilitiesMathUtils_LineSearch.hxx - Line search algorithms for optimizationMathUtils_GaussKronrodWeights.hxx/.cxx - Access to Gauss-Kronrod quadrature weightsMathUtils_FunctorScalar.hxx - Scalar (1D) function functorsMathUtils_FunctorVector.hxx - Vector (N-D) function functorsAll utilities are in the MathUtils namespace:
#include <MathUtils_Core.hxx> #include <MathUtils_Convergence.hxx> // Use constants double x = MathUtils::THE_PI; // Check convergence bool converged = MathUtils::IsXConverged(xOld, xNew, 1e-8);
#include <MathUtils_FunctorScalar.hxx> #include <MathRoot_Brent.hxx> // Using polynomial functor MathUtils::Polynomial poly({-2.0, 0.0, 1.0}); // x^2 - 2 auto result = MathRoot::Brent(poly, 0.0, 2.0); // Find sqrt(2) // Using lambda wrapper auto func = MathUtils::MakeScalar([](double x, double& y) { y = x * x - 2.0; return true; }); auto result2 = MathRoot::Brent(func, 0.0, 2.0);
enum class Status { OK, NotConverged, MaxIterations, NumericalError, InvalidInput, InfiniteSolutions, NoSolution, NotPositiveDefinite, Singular, NonDescentDirection };
Note: specialized MathSys 2D/3D/4D Newton solvers also use MathUtils::Status via MathSys_NewtonTypes.hxx.
ScalarResult - For 1D root finding resultsPolyResult - For polynomial root results (up to 4 roots)VectorResult - For N-D optimization resultsLinearMultipleResult - For linear systems with matrix right-hand side (AX=B)IntegResult - For integration results with error estimatestruct Config { double XTolerance = 1e-10; // Tolerance on X double FTolerance = 1e-10; // Tolerance on F int MaxIterations = 100; // Maximum iterations };