Skip to content

Foundation Classes - Move to constexpr Pascal allocator for PLib::Bin#777

Merged
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:Plib_optimization
Nov 1, 2025
Merged

Foundation Classes - Move to constexpr Pascal allocator for PLib::Bin#777
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi:Plib_optimization

Conversation

@dpasukhi
Copy link
Copy Markdown
Member

  • Change BSplCLib::MaxDegree to constexpr.
  • Replace dynamic BinomAllocator with a compile-time constexpr Pascal triangle allocator to avoid runtime allocations and cyclic dependency.
  • Add thread-safe lazy accessor for the allocator and bounds checks in PLib::Bin.
  • Tests - expand and split PLib binomial tests (basic values, symmetry, recurrence, large values, sum property, edge cases).

- Change BSplCLib::MaxDegree to constexpr.
- Replace dynamic BinomAllocator with a compile-time constexpr Pascal triangle allocator to avoid runtime allocations and cyclic dependency.
- Add thread-safe lazy accessor for the allocator and bounds checks in PLib::Bin.
- Tests - expand and split PLib binomial tests (basic values, symmetry, recurrence, large values, sum property, edge cases).
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 PR refactors the binomial coefficient computation in PLib to use compile-time constexpr evaluation instead of runtime dynamic allocation, eliminating cyclic dependencies and improving performance through static initialization.

  • Converts BSplCLib::MaxDegree() to a constexpr function to enable compile-time evaluation
  • Replaces the dynamically allocated BinomAllocator with a template-based constexpr Pascal's triangle that is computed at compile time
  • Adds comprehensive test coverage for binomial coefficients, expanding from a single test to six focused test cases covering basic values, symmetry, recurrence relations, large values, edge cases, and sum properties

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
BSplCLib.hxx Adds constexpr to the MaxDegree() declaration to enable compile-time evaluation
BSplCLib.lxx Adds constexpr to the MaxDegree() implementation
PLib.cxx Replaces dynamic memory allocator with constexpr template-based Pascal's triangle, adds bounds checking to PLib::Bin, and introduces thread-safe lazy initialization
PLib_Test.cxx Expands test coverage from one basic test to six comprehensive tests validating binomial coefficient properties

Comment thread src/FoundationClasses/TKMath/PLib/PLib.cxx Outdated
Comment thread src/FoundationClasses/TKMath/PLib/PLib.cxx
Comment thread src/FoundationClasses/TKMath/BSplCLib/BSplCLib.hxx
…t myBinom[N][P]),

add a note that callers must ensure N and P are within valid range, and use the
GetBinomAllocator() overload (no explicit template argument) in PLib::Bin.
@dpasukhi dpasukhi self-assigned this Oct 29, 2025
@dpasukhi dpasukhi added 2. Enhancement New feature or request 1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code labels Oct 29, 2025
@dpasukhi dpasukhi marked this pull request as ready for review October 29, 2025 23:05
@dpasukhi dpasukhi merged commit b04257c into Open-Cascade-SAS:IR Nov 1, 2025
23 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Maintenance Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1. Foundation Classes Containers, system calls wrappers, smart pointers and other low level of OCCT code 2. Enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants