Skip to content

Strategy API: pass all candidates, Λ, and kadd - #33

Merged
timholy merged 1 commit into
mainfrom
teh/appending
Jun 21, 2026
Merged

Strategy API: pass all candidates, Λ, and kadd#33
timholy merged 1 commit into
mainfrom
teh/appending

Conversation

@timholy

@timholy timholy commented Jun 21, 2026

Copy link
Copy Markdown
Member

Strategies now receive (X, W0, H0, Hadd, Λ, kadd): Hadd holds all candidate directions as rows, aligned 1:1 with Λ in descending order, and each strategy defines how to interpret the requested count kadd. truncating and joint_nnls add exactly kadd components.

The new appending strategy adds at most kadd, leaving the existing factors unmodified — for callers whose current components are validated, constrained, or shared with a fit over a larger domain. Its selection combines a generalized-singular-value threshold (appending(thresh), default 1), a nonnegative amplitude refit that rejects candidates unable to reduce the residual and corrects the NNDSVD quadrant-truncation scale, and a relative-amplitude floor rtol guarding against the scale-freeness of Λ.

gsvdrecover rejects numerically rank-deficient SVDs with a clear error rather than failing deep inside the GSVD, and gsvdnmf sizes its polishing run to the number of components the strategy kept.

Strategies now receive `(X, W0, H0, Hadd, Λ, kadd)`: `Hadd` holds all
candidate directions as rows, aligned 1:1 with `Λ` in descending
order, and each strategy defines how to interpret the requested count
`kadd`. `truncating` and `joint_nnls` add exactly `kadd` components.

The new `appending` strategy adds at most `kadd`, leaving the existing
factors unmodified — for callers whose current components are
validated, constrained, or shared with a fit over a larger domain. Its
selection combines a generalized-singular-value threshold
(`appending(thresh)`, default 1), a nonnegative amplitude refit that
rejects candidates unable to reduce the residual and corrects the
NNDSVD quadrant-truncation scale, and a relative-amplitude floor
`rtol` guarding against the scale-freeness of Λ.

`gsvdrecover` rejects numerically rank-deficient SVDs with a clear
error rather than failing deep inside the GSVD, and `gsvdnmf` sizes
its polishing run to the number of components the strategy kept.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@timholy

timholy commented Jun 21, 2026

Copy link
Copy Markdown
Member Author

Whether or not appending proves useful, the new API seems unquestionably better.

@timholy
timholy merged commit a8d18ab into main Jun 21, 2026
2 checks passed
@timholy
timholy deleted the teh/appending branch June 21, 2026 12:47
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