Skip to content

fix: review findings for src/locweights.f#8

Open
Davidvandijcke wants to merge 1 commit intomainfrom
fix/review-src-locweights
Open

fix: review findings for src/locweights.f#8
Davidvandijcke wants to merge 1 commit intomainfrom
fix/review-src-locweights

Conversation

@Davidvandijcke
Copy link
Copy Markdown
Owner

Automated fixes from code review pipeline.

Changes

  • F1 (src/init.c): Fix type mismatch (double*int* for KERNEL_TYPE) and rename R_init_YourPackageNameR_init_R3D for correct DLL registration.
  • F2 (src/locweights.f): Guard against zero/negative bandwidth before first kernel-weight pass; returns INFO=-97 to prevent divide-by-zero under -ffpe-trap=divbyzero.
  • F3 (src/locweights.f, R/r3d_main.R, R/r3d_bwselect.R): Replace early return on singular DGETRF with cycle+NaN sentinel so subsequent quantiles are not silently zeroed. R callers convert NaN outputs to NA after .Fortran calls.
  • F4 (src/locweights.f): Add local W(N) array to cache kernel weights from the first pass; second pass reads W(i) instead of recomputing, eliminating duplicate kernel logic.
  • F5 (src/locweights.f): Input validation at subroutine entry — SIDE not in {0,1}INFO=-96, NQ<1INFO=-95, N<dimINFO=-94.
  • New tests: 4 tests covering H=0 (INFO=-97), SIDE=2 (INFO=-96), per-quantile NaN cycling, and DLL symbol resolution.

devtools::check() passes with 0 errors, 0 warnings, 3 pre-existing NOTEs.

F1 (src/init.c): fix type mismatch double*->int* for KERNEL_TYPE argument
and rename R_init_YourPackageName to R_init_R3D for correct DLL registration.

F2 (locweights.f): add H(q)<=0 guard before first kernel-weight pass;
returns INFO=-97 to prevent divide-by-zero on HPC with -ffpe-trap=divbyzero.

F3 (locweights.f + R callers): replace early return on singular DGETRF with
cycle+NaN sentinel so subsequent quantiles are not silently zeroed. R callers
(r3d_main.R, r3d_bwselect.R) convert NaN outputs to NA after .Fortran calls.

F4 (locweights.f): add local W(N) array to cache kernel weights from the
first pass; second pass reads W(i) instead of recomputing, eliminating
duplicate kernel logic and divergence risk.

F5 (locweights.f): add input validation at subroutine entry:
SIDE not in {0,1}->INFO=-96, NQ<1->INFO=-95, N<dim->INFO=-94.

tests: add 4 new tests covering H=0 (INFO=-97), SIDE=2 (INFO=-96),
per-quantile NaN cycling, and DLL symbol resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant