Open
Conversation
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>
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.
Automated fixes from code review pipeline.
Changes
src/init.c): Fix type mismatch (double*→int*forKERNEL_TYPE) and renameR_init_YourPackageName→R_init_R3Dfor correct DLL registration.src/locweights.f): Guard against zero/negative bandwidth before first kernel-weight pass; returnsINFO=-97to prevent divide-by-zero under-ffpe-trap=divbyzero.src/locweights.f,R/r3d_main.R,R/r3d_bwselect.R): Replace earlyreturnon singularDGETRFwithcycle+NaN sentinel so subsequent quantiles are not silently zeroed. R callers convert NaN outputs toNAafter.Fortrancalls.src/locweights.f): Add localW(N)array to cache kernel weights from the first pass; second pass readsW(i)instead of recomputing, eliminating duplicate kernel logic.src/locweights.f): Input validation at subroutine entry —SIDEnot in{0,1}→INFO=-96,NQ<1→INFO=-95,N<dim→INFO=-94.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.