Skip to content

feat: add C implementation for blas/ext/base/ndarray/ztriu - #16237

Open
AtharvaPatange wants to merge 2 commits into
stdlib-js:developfrom
AtharvaPatange:feat/blas-ztriu
Open

AtharvaPatange wants to merge 2 commits into
stdlib-js:developfrom
AtharvaPatange:feat/blas-ztriu

Conversation

@AtharvaPatange

Copy link
Copy Markdown
Contributor

Related to #14819.

Description

What is the purpose of this pull request?

This pull request:

  • Adds a native C ndarray implementation for blas/ext/base/ndarray/ztriu, using the existing strided C routine.
  • Adds the Node.js addon and uses the native implementation when available, with the JavaScript implementation as a fallback.
  • Adds native tests, benchmarks, a C example, and C API documentation.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

The native JS wrapper extracts k from the generic scalar ndarray and passes a float64 scalar ndarray to C, so the existing JS example works. For direct C callers, should stdlib_blas_ext_ztriu require a 0-D float64 ndarray for k, or support other numeric dtypes? Since the C function returns void, how would you prefer it to handle an unsupported dtype or unreadable scalar?

Other

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

No.

Checklist

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

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.".

I used codex for tests generation and documentation writing , all the changes made by ai are reviewed carefully


@stdlib-js/reviewers

@AtharvaPatange
AtharvaPatange requested a review from a team October 18, 2026 15:09
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review. labels Oct 18, 2026
@stdlib-bot

stdlib-bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/ndarray/ztriu $\\color{green}227/227$
$\\color{green}+0.00\\%$
$\\color{green}7/7$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}227/227$
$\\color{green}+0.00\\%$

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

@ujjwalv01

Copy link
Copy Markdown
Member

@AtharvaPatange The CI failure comes from k still being generic in a few places. The README already uses int32, but the JSDoc examples, TypeScript declarations and tests, REPL help, and examples still use 'dtype': 'generic'.

A generic ndarray is backed by a plain JS array, not a typed array, so when the lib/index.js example runs through the native add-on, stdlib_ndarray_napi_addon_arguments fails its assertion and the process aborts. That's the "Lint Changed Files" failure.

The scalar ndarray passed to the native add-on needs a concrete dtype, so k should be int32 throughout the package. See kgryte's comments in #14471 and #14860, and the same change in ztril (#16063).

Mind making these changes?

@ujjwalv01 ujjwalv01 added the Needs Changes Pull request which needs changes before being merged. label Oct 18, 2026
@AtharvaPatange

Copy link
Copy Markdown
Contributor Author

Thanks for pointing that out! I have updated k to use 'dtype': 'int32' across all remaining locations in the package

@ujjwalv01 ujjwalv01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @AtharvaPatange!

@ujjwalv01 ujjwalv01 removed the Needs Changes Pull request which needs changes before being merged. label Oct 18, 2026

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

BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants