From d9805d2e04b0620fdbec557e12192fe2fed4778b Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sun, 29 Mar 2026 11:15:46 +0100 Subject: [PATCH] Modeling - Zero-initialize output array in Weights method for valid finite values (#1175) - Initialize the full `theTabWeights` array to `0.0` at the start of `Weights()` to avoid leaving any cells uninitialized. - Remove the now-redundant explicit loop that previously zeroed only row 0 up to `myDegree`. - Clarify the row-0 filling comment for the odd-`NbGaussPoints` case. --- .../TKMath/PLib/PLib_JacobiPolynomial.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx index 2f5cb3ed2b..da5e6cac6c 100644 --- a/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx +++ b/src/FoundationClasses/TKMath/PLib/PLib_JacobiPolynomial.cxx @@ -104,6 +104,10 @@ void PLib_JacobiPolynomial::Points(const int theNbGaussPoints, void PLib_JacobiPolynomial::Weights(const int theNbGaussPoints, NCollection_Array2& theTabWeights) const { + // Zero-initialize entire output array to ensure columns beyond myDegree + // (which are not populated below) contain valid finite values. + theTabWeights.Init(0.0); + double const* aDbPointer = THE_WEIGHTS_DB[myNivConstr]; const int aMinDegree = 2 * (myNivConstr + 1); @@ -165,13 +169,7 @@ void PLib_JacobiPolynomial::Weights(const int theNbGaussPoints aDbPointer0 += ((THE_NB_GAUSS_POINTS_25 - 1 - aMinDegree) / 2 + 1); } - // Fill row 0: zeros everywhere (explicit column loop for proper 2D array access) - for (int j = 0; j <= myDegree; j++) - { - theTabWeights.ChangeValue(0, j) = 0.0; - } - - // Overwrite even columns with data from database + // Overwrite even columns of row 0 with data from database for (int j = 0; j <= myDegree; j += 2) { theTabWeights.ChangeValue(0, j) = *aDbPointer0++;