Testing - Cover math module with GTests#684
Conversation
…mance test - Created a new test file for math_Vector class covering various functionalities including constructors, initialization, access, properties, normalization, inversion, scalar operations, vector addition/subtraction, and more. - Implemented checks for exceptions and edge cases in vector operations. - Enhanced the OSD_PerfMeter test by replacing geometric operations with computationally intensive mathematical operations to better measure performance.
- Implemented comprehensive tests for the Gauss and Kronrod single integration methods, covering various function types including constant, linear, quadratic, trigonometric, and exponential functions. - Added tests for different integration orders and edge cases such as zero-length intervals and reverse intervals. - Introduced tests for the SVD class, validating its behavior with well-conditioned, identity, diagonal, overdetermined, underdetermined, and rank-deficient matrices. - Included checks for exception handling and singular values in the SVD tests. - Ensured that all tests verify the correctness of solutions against expected results with appropriate tolerances.
- Implement tests for the Powell optimization method in `math_Powell_Test.cxx`, covering various functions including quadratic, Rosenbrock, and multi-dimensional cases. - Introduce tests for trigonometric function roots in `math_TrigonometricFunctionRoots_Test.cxx`, validating solutions for sine and cosine equations, including edge cases and custom bounds. - Create tests for the Uzawa algorithm in `math_Uzawa_Test.cxx`, assessing its performance on equality and inequality constraints, custom tolerances, and larger systems. - Ensure comprehensive coverage of expected behaviors, including convergence checks, error handling, and validation of solutions against known results.
- Renamed tests to reflect state handling instead of exception handling for various mathematical optimizers and solvers. - Updated tests to check for non-done states instead of expecting exceptions before performing operations. - Improved dimension compatibility tests by verifying correct dimensions for input vectors and matrices. - Removed redundant exception checks and focused on validating the state of the solver or optimizer. - Enhanced clarity in test descriptions and assertions to better communicate intent and expected outcomes.
…improved performance
There was a problem hiding this comment.
Pull Request Overview
This pull request adds comprehensive GTest coverage for the math module in Open CASCADE Technology (OCCT), introducing 20 new test files covering various mathematical algorithms and data structures. The PR includes bug fixes in math_FunctionRoot and math_SVD along with performance improvements to the test framework by replacing heavy CAD operations with lightweight mathematical computations.
Key improvements:
- Extensive test coverage for core mathematical algorithms (Newton methods, optimization, linear algebra, root finding)
- Bug fix for proper iteration count tracking in
math_FunctionRoot - Bug fix for custom vector bounds handling in
math_SVD - Performance enhancement in
OSD_PerfMeter_Testby replacing heavy CAD operations with mathematical computations
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/FoundationClasses/TKernel/GTests/OSD_PerfMeter_Test.cxx |
Performance improvements replacing heavy CAD operations with math functions |
src/FoundationClasses/TKMath/math/math_SVD.cxx |
Bug fix for custom bounds handling in SVD vector operations |
src/FoundationClasses/TKMath/math/math_FunctionRoot.cxx |
Bug fix for proper iteration count tracking |
| 17 new GTest files | Comprehensive test coverage for mathematical algorithms and data structures |
| // Handle custom bounds in X vector - SVD_Solve expects 1-based indexing | ||
| if (X.Lower() != 1) | ||
| { | ||
| math_Vector anXTemp(&X.Value(X.Lower()), 1, X.Length()); | ||
| SVD_Solve(U, Diag, V, BB, anXTemp); | ||
| } | ||
| else | ||
| { | ||
| SVD_Solve(U, Diag, V, BB, X); | ||
| } |
There was a problem hiding this comment.
This fix for custom bounds handling is correct but the logic could be clearer. Consider adding a comment explaining that SVD_Solve requires 1-based indexing and this wrapper creates a compatible vector view when the input has different bounds.
| NbIter = Sol.NbIterations(); | ||
| if (Done) | ||
| { | ||
| F.GetStateNumber(); | ||
| TheRoot = Sol.Root()(1); | ||
| TheDerivative = Sol.Derivative()(1, 1); | ||
| F.Value(TheRoot, TheError); | ||
| NbIter = Sol.NbIterations(); | ||
| } |
There was a problem hiding this comment.
The iteration count assignment should be moved outside the Done check to ensure it's always updated, regardless of convergence status. This matches the pattern used in the bounded version below.
No description provided.