Skip to content

Testing - Cover math module with GTests#684

Merged
dpasukhi merged 14 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:gtests_math
Aug 24, 2025
Merged

Testing - Cover math module with GTests#684
dpasukhi merged 14 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:gtests_math

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

No description provided.

…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.
@dpasukhi dpasukhi requested a review from Copilot August 23, 2025 10:01
@dpasukhi dpasukhi self-assigned this Aug 23, 2025
@dpasukhi dpasukhi added the 1. Testing Updating of the DRAW/GTests or GH tests label Aug 23, 2025
@dpasukhi dpasukhi added this to the Release 8.0 milestone Aug 23, 2025

This comment was marked as outdated.

- 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.
@dpasukhi dpasukhi requested a review from Copilot August 24, 2025 18:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_Test by 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

Comment on lines +56 to +65
// 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);
}
Copy link

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +88 to 95
NbIter = Sol.NbIterations();
if (Done)
{
F.GetStateNumber();
TheRoot = Sol.Root()(1);
TheDerivative = Sol.Derivative()(1, 1);
F.Value(TheRoot, TheError);
NbIter = Sol.NbIterations();
}
Copy link

Copilot AI Aug 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@dpasukhi dpasukhi merged commit 51abcfc into Open-Cascade-SAS:IR Aug 24, 2025
23 checks passed
@dpasukhi dpasukhi deleted the gtests_math branch August 24, 2025 18:52
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Testing Updating of the DRAW/GTests or GH tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants