Skip to content

feat: add lapack/base/dgbequ - #17002

Open
Udaygund wants to merge 1 commit into
stdlib-js:developfrom
Udaygund:feat/dgbequ
Open

Udaygund wants to merge 1 commit into
stdlib-js:developfrom
Udaygund:feat/dgbequ

Conversation

@Udaygund

@Udaygund Udaygund commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Resolves a part of #2464.

Description

What is the purpose of this pull request?

This pull request:

  • adds @stdlib/lapack/base/dgbequ, which computes row and column scale factors intended to equilibrate an M-by-N band matrix A and reduce its condition number.

The implementation is a port of reference LAPACK DGBEQU. Its only dependency is the smallest normal double-precision number (used as dlamch('S')), so it is independent of the other open LAPACK PRs.

Conventions:

  • Outputs follow dgeequ (feat: add lapack/base/dgeequ #13155): dgbequ( order, M, N, KL, KU, AB, LDAB, R, C, out ) and dgbequ.ndarray( M, N, KL, KU, AB, sab1, sab2, oab, R, sr, or, C, sc, oc, out, so, oo ), with out set to [ ROWCND, COLCND, AMAX ]. The return value is the status code: 0 on success, i (one-based) if row i is exactly zero, and M+j if column j is exactly zero. On an early return, the outputs are left exactly as the reference implementation leaves them (e.g., R holds the unscaled row maxima when a row is zero).
  • Band storage follows dgbtf2 (feat: add lapack/base/dgbtf2 #15833): AB is the (KL+KU+1)-by-N band array, with A(i,j) stored in band row KU+i-j (zero-based) of column j. Column-major indexing is AB[b+j*LDAB] with LDAB >= KL+KU+1; row-major indexing is AB[b*LDAB+j] with LDAB >= max(1,N). The ndarray API doesn't take order, since strides fully describe the band array.
  • Only elements within the band are referenced, and KL/KU may exceed the matrix dimensions.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Reference Packages

Did the content of this pull request follow one or more existing packages? Answering is optional.

This pull request followed these packages:

What carried over from the reference(s)?

What differed, or what did you have to work out yourself?

  • the band traversal: for column j, only rows max(0,j-KU) through min(M-1,j+KL) are visited, reading band row KU+i-j
  • fixtures are generated with reference LAPACK dgbequ (Apple Accelerate) and compared exactly with isSameFloat64Array, as in feat: add lapack/base/dgeequ #13155. They cover both layouts, square, wide, and tall matrices, KL = KU = 0, bandwidths larger than the matrix, LDAB larger than required, zero rows and zero columns (status codes and partially written outputs), row and column maxima below the smallest normal number (clamping), values near the overflow threshold, and offsets and positive, negative, and mixed strides. Matrices and band arrays are shown row by row in *_mat fields
  • additional check outside the test suite: on 5,000 random band matrices (including zero rows/columns, magnitudes from about 1e-310 to 1e305, and KL/KU up to 9 for matrices up to 7-by-7), the status code, R, C, and out match reference LAPACK bit for bit in both column-major and row-major layouts
  • as a check on the tests, each of 12 targeted changes to lib/base.js (band row index, row bounds, status codes, row scaling, row/column clamping, ROWCND/COLCND/AMAX, quick return) makes the tests fail

Questions

Any questions for reviewers of this pull request?

Yes (also asked in #2464): no band routine has been merged yet, and #6707 raised a question about the row-major band layout. This PR follows the LAPACKE-style layout used in #15833 (row-major AB[b*LDAB+j], LDAB >= max(1,N)). Is that the convention new band routines should use? If not, only the stride setup in lib/dgbequ.js and the row-major fixtures would need to change.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Ran locally: package tests (211 assertions), benchmarks, the example, and the commit-hook linters (file names, EditorConfig, Markdown, package.json, repl.txt, JavaScript, TypeScript declarations and tests, license headers), all passing.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

  • Read, understood, and followed the [contributing guidelines][contributing].

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".


@stdlib-js/reviewers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: passed
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: passed
  - task: lint_license_headers
    status: passed
---
@Udaygund
Udaygund requested a review from a team November 30, 2026 06:14
@stdlib-bot stdlib-bot added LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Review A pull request which needs code review. labels Nov 30, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
lapack/base/dgbequ $\\color{green}541/541$
$\\color{green}+100.00\\%$
$\\color{green}64/64$
$\\color{green}+100.00\\%$
$\\color{green}3/3$
$\\color{green}+100.00\\%$
$\\color{green}541/541$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants