Skip to content

Commit 155722d

Browse files
ooplesclaude
andcommitted
fix(ci): resolve commitlint duplicate runs and coifletwavelet stack overflow
- Remove pull_request_target trigger from commitlint workflow to prevent duplicate runs on every PR - Add recursion depth limit to CoifletWavelet.ScalingFunction to prevent stack overflow during SonarCloud analysis 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 966a16f commit 155722d

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/commitlint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Commit Message Lint
22

33
on:
44
pull_request:
5-
pull_request_target:
65

76
concurrency:
87
group: ${{ github.workflow }}-${{ github.ref }}

src/WaveletFunctions/CoifletWavelet.cs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,29 +137,48 @@ public override T Calculate(T x)
137137
/// <para>
138138
/// <b>For Beginners:</b>
139139
/// The scaling function is the basic building block used to construct the wavelet.
140-
///
140+
///
141141
/// For Coiflet wavelets, the scaling function satisfies a two-scale relation:
142142
/// f(t) = S c_k f(2t-k)
143-
///
143+
///
144144
/// This is a recursive definition, which makes exact calculation challenging.
145145
/// This method implements a simple recursive approximation that:
146146
/// 1. Checks if the point is within the support [0,1]
147147
/// 2. If so, calculates the function value using the two-scale relation
148-
///
148+
///
149149
/// In practice, this recursive approach has limitations and would typically be
150150
/// replaced by more sophisticated numerical methods for accurate calculation.
151151
/// However, it illustrates the fundamental recursive nature of wavelet scaling functions.
152152
/// </para>
153153
/// </remarks>
154154
private double ScalingFunction(double t)
155155
{
156+
return ScalingFunctionRecursive(t, 0);
157+
}
158+
159+
/// <summary>
160+
/// Recursive helper for scaling function with depth limit to prevent stack overflow.
161+
/// </summary>
162+
private double ScalingFunctionRecursive(double t, int depth)
163+
{
164+
// Base case: outside support
156165
if (t < 0 || t > 1)
157166
return 0;
158167

168+
// Base case: max recursion depth reached - return approximation
169+
const int MaxDepth = 10;
170+
if (depth >= MaxDepth)
171+
return 1.0; // Return constant approximation at max depth
172+
159173
double result = 0;
160174
for (int k = 0; k < 6 * _order; k++)
161175
{
162-
result += Convert.ToDouble(_coefficients[k]) * ScalingFunction(2 * t - k);
176+
double shiftedT = 2 * t - k;
177+
// Only recurse if the shifted value is within support
178+
if (shiftedT >= 0 && shiftedT <= 1)
179+
{
180+
result += Convert.ToDouble(_coefficients[k]) * ScalingFunctionRecursive(shiftedT, depth + 1);
181+
}
163182
}
164183

165184
return result;

0 commit comments

Comments
 (0)