Skip to content

Support rectangular solve and qr.solve compilation - #82

Merged
t-kalinowski merged 5 commits into
mainfrom
update-readme
Jan 21, 2026
Merged

Support rectangular solve and qr.solve compilation#82
t-kalinowski merged 5 commits into
mainfrom
update-readme

Conversation

@t-kalinowski

Copy link
Copy Markdown
Owner

Summary

  • add a dgels fallback so rectangular solve() uses least-squares when needed and keeps output dims aligned
  • compile qr.solve() and harden generated symbol naming for mixed-case C bindings
  • refresh README examples and figures to showcase the updated matrix capabilities

- Use dgesv when A is known square
- Infer solve() output dims from ncol(A)
- Add tests for least-squares and codegen calls
- Add r2f handler for qr.solve() with tests
- Fix Fortran subscript emission for hoisted temporaries
- Validate compiled names and preserve mixed-case C bindings
@codecov

codecov Bot commented Jan 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.13084% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.30%. Comparing base (f30fa88) to head (8fecece).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
R/r2f-matrix-blas.R 98.75% 1 Missing ⚠️
R/subroutine.R 95.45% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   92.08%   92.30%   +0.21%     
==========================================
  Files          22       22              
  Lines        4472     4560      +88     
==========================================
+ Hits         4118     4209      +91     
+ Misses        354      351       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 484c509e7e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread R/r2f-matrix-blas.R
Comment on lines +718 to +720
hoist$emit(glue(
"call dgesv({blas_int(m)}, {blas_int(nrhs)}, {A_work@name}, {blas_int(m)}, {ipiv@name}, {out_name}, {blas_int(m)}, {info@name})"
))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Route qr.solve square inputs through QR, not dgesv

Because qr.solve() now dispatches to lapack_solve(), any input whose dimensions are proven square takes the dgesv LU branch (this call), which ignores QR rank‑deficiency handling and tol. For singular or near‑singular square matrices (e.g., collinear columns), qr.solve() is expected to use QR to produce a least‑squares solution or signal rank issues; here it will return whatever dgesv leaves in B (and info is never checked), so results can be incorrect or undefined in exactly the cases users call qr.solve for.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed by skipping the LU/dgesv fast path for qr.solve. In lapack_solve() the square-matrix branch now guards on !identical(context, "qr.solve"), so qr.solve always routes through the QR path (with rank/tol handling) even when inputs are square.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also added tests to cover the qr.solve path via QR (including square inputs), so we exercise the rank/tol handling and keep the LU fast path out of qr.solve.

- Route qr.solve through dgelsy (QR pivoting)
- Accept scalar tol and thread to rcond
- Add tests for solver routing and name suggestions
@t-kalinowski
t-kalinowski merged commit 130fad3 into main Jan 21, 2026
6 checks passed
@t-kalinowski
t-kalinowski deleted the update-readme branch January 21, 2026 14:03
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