Skip to content

Commit ddf77ac

Browse files
committed
Merge branch 'features/integral' into dev
2 parents fd95727 + 7f30c03 commit ddf77ac

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/numerical/integral.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ where
386386

387387
// Handle zero-width interval initially
388388
if a_f64 == b_f64 {
389-
return Y::ZERO; // Integral over zero width is zero
389+
return Y::ZERO;
390390
}
391391

392392
// Push the initial interval onto the stack
@@ -405,7 +405,6 @@ where
405405
// Determine the tolerance threshold for this interval
406406
let current_tolerance_threshold = if is_relative {
407407
// Scale relative tolerance by the norm of the higher-order estimate (K)
408-
// Need Clone if Y is not Copy
409408
tol_curr * K.clone().gk_norm()
410409
} else {
411410
// Use absolute tolerance directly
@@ -422,15 +421,11 @@ where
422421
if !K.is_finite() {
423422
// If K is not finite, check G
424423
if G.is_finite() {
425-
// If K is not finite but G is, add G (matches original behavior)
426-
// Need Clone if Y is not Copy
424+
// If K is not finite but G is, add G
427425
I = I + G.clone();
428426
}
429-
// If both K and G are not finite, add nothing (or handle error appropriately)
430-
// Consider logging a warning here if possible.
431427
} else {
432428
// K is finite, add it to the total integral
433-
// Need Clone if Y is not Copy
434429
I = I + K.clone();
435430
}
436431
} else {
@@ -448,7 +443,6 @@ where
448443
} else {
449444
I = I + K.clone();
450445
}
451-
// Log warning about precision limit if possible.
452446
continue; // Skip pushing to stack
453447
}
454448

@@ -461,9 +455,9 @@ where
461455
S.push((a_curr, c, next_tol, next_iter)); // Left subinterval [a, c]
462456
S.push((c, b_curr, next_tol, next_iter)); // Right subinterval [c, b]
463457
}
464-
} // End while loop
458+
}
465459

466-
I // Return the accumulated integral value
460+
I
467461
}
468462

469463
/// Helper function to compute G and K integrals reusing function evaluations.
@@ -478,7 +472,7 @@ fn compute_gauss_kronrod_sums_stored<F, Y>(
478472
) -> (Y, Y, Y)
479473
where
480474
F: Fn(f64) -> Y,
481-
Y: GKIntegrable, // Requires Clone, Add, Sub, Mul<f64>, ZERO, gk_norm, is_finite
475+
Y: GKIntegrable,
482476
{
483477
// 1. Get Kronrod nodes and weights
484478
// Assumes nodes ordered [-xn,...,0,...,+xn] and weights correspond.
@@ -523,7 +517,10 @@ where
523517
// Contribution from paired Gauss nodes (+/- xg_j)
524518
for j in 1..=num_gauss_pairs {
525519
if 2 * j > kronrod_center_idx {
526-
panic!("Kronrod node index underflow. k={}, center_idx={}, j={}", k, kronrod_center_idx, j);
520+
panic!(
521+
"Kronrod node index underflow. k={}, center_idx={}, j={}",
522+
k, kronrod_center_idx, j
523+
);
527524
}
528525

529526
// Indices in f_evals corresponding to Kronrod nodes +/- xk_{2j}

0 commit comments

Comments
 (0)