Skip to content

feat: add C implementation for blas/ext/base/ndarray/ddiff - #16639

Open
utkarshpatwa393-sys wants to merge 6 commits into
stdlib-js:developfrom
utkarshpatwa393-sys:feat/c-impl-blas-ext-base-ndarray-ddiff
Open

utkarshpatwa393-sys wants to merge 6 commits into
stdlib-js:developfrom
utkarshpatwa393-sys:feat/c-impl-blas-ext-base-ndarray-ddiff

Conversation

@utkarshpatwa393-sys

@utkarshpatwa393-sys utkarshpatwa393-sys commented Nov 15, 2026 •

Copy link
Copy Markdown

Resolves a part of #14819.

Description

What is the purpose of this pull request?

This pull request:

  • Adds native C and Node-API add-on bindings for the double-precision discrete difference ndarray routine @stdlib/blas/ext/base/ndarray/ddiff.
  • Adds C headers (include/stdlib/blas/ext/base/ndarray/ddiff.h), C implementation (src/main.c), Node-API add-on wrapper (src/addon.c), build configuration (binding.gyp, include.gypi, manifest.json, src/Makefile), and loader dispatch (lib/native.js).
  • Adds unit tests (test/test.main.js, test/test.native.js), C benchmarks (benchmark/c/), native benchmarks (benchmark/benchmark.native.js), C example (examples/c/example.c), and TypeScript definitions (docs/types/).

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:

  • blas/ext/base/ndarray/daxpb
  • blas/ext/base/ndarray/dsum
  • blas/ext/base/ndarray/dwxdy

What carried over from the reference(s)?

  • Package structure, Node-API add-on argument serialization/deserialization patterns, C benchmark and example formatting, and TypeScript definition typings.

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

  • Multi-array discrete difference logic requiring workspace buffer allocation, prepend/append handling, and 0-d integer order k parameter handling across C and Node-API boundaries.

Questions

Any questions for reviewers of this pull request?

No.

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 consulted AI assistance for understanding codebase conventions, cross-referencing package documentation styles, and structuring the PR description per the template, but all implementation code, C bindings, and test files were authored and verified directly against stdlib conventions.


@stdlib-js/reviewers

Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
@utkarshpatwa393-sys
utkarshpatwa393-sys requested a review from a team November 15, 2026 10:08
@stdlib-bot stdlib-bot added the BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). label Nov 15, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. labels Nov 15, 2026
@utkarshpatwa393-sys utkarshpatwa393-sys changed the title feat: add C and native implementation for ddiff ndarray routine feat: add C implementation for blas/ext/base/ndarray/ddiff Nov 15, 2026
Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
@stdlib-bot

stdlib-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

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

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

@ujjwalv01

Copy link
Copy Markdown
Member

The same changes suggested in #16640 apply here as well (except the native benchmark label, printf and float ones): benchmark.js requiring main.js, the README k allocation and Examples matching example.c, the C benchmark declaration order and single-element mallocs, the unused dcopy in manifest.json, the native.js/main.c layout, the examples/c/Makefile comment, and the PR template. Could you apply them here too?

@ujjwalv01 ujjwalv01 added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Nov 19, 2026
…enchmarks, README, and native bindings

Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
@utkarshpatwa393-sys

Copy link
Copy Markdown
Author

Hi @ujjwalv01, thank you for the review!

I have applied the corresponding updates to this PR as well in the latest commit:

  • Updated the PR description to adhere strictly to the stdlib PR template with all required sections, reference packages, and AI disclosure.
  • Updated benchmark.js to require ./../lib/main.js.
  • Updated C benchmarks in benchmark.length.c: ordered declarations by length (longest first), allocated single-element buffers on the stack without dynamic mallocs, and declared kstrides alongside other declarations.
  • Updated Makefile comment syntax for LIBPATH.
  • Aligned lib/native.js argument extraction and src/main.c layout with merged reference packages.
  • Removed unused @stdlib/blas/base/dcopy from manifest.json.
  • Updated README.md C usage and examples with kstrides 0-d ndarray allocation matching example.c.

Please take another look when you get a chance. Thanks!

@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 @utkarshpatwa393-sys , for working through the review!

@ujjwalv01 ujjwalv01 added Feature Issue or pull request for adding a new feature. Needs Review A pull request which needs code review. C Issue involves or relates to C. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. and removed Needs Changes Pull request which needs changes before being merged. labels Nov 23, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

⚠️ Tracking Issue Closure Warning ⚠️

I noticed your PR description contains closing keywords ("Resolves", "Closes", or "Fixes") referencing a "Tracking Issue".

Why this matters:
Tracking issues should typically remain open until all related sub-issues are completed. GitHub automatically closes issues with such closing keywords when the PR is merged. For more information, see GitHub's documentation on using keywords in issues and pull requests.

Required action:
Use "Progresses" instead to reference the tracking issue without automatically closing it.

Thank you for your contribution to the project!

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). C Issue involves or relates to C. difficulty: 2 May require some initial design or R&D, but should be straightforward to resolve and/or implement. Feature Issue or pull request for adding a new feature. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants