Foundation Classes - Move to constexpr Pascal allocator for PLib::Bin#777
Merged
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom Nov 1, 2025
Merged
Foundation Classes - Move to constexpr Pascal allocator for PLib::Bin#777dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
dpasukhi merged 2 commits intoOpen-Cascade-SAS:IRfrom
Conversation
Member
dpasukhi
commented
Oct 29, 2025
- 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).
There was a problem hiding this comment.
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
BinomAllocatorwith 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 |
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.