Skip to content

feat: add blas/ext/base/zdiff#11741

Open
headlessNode wants to merge 3 commits into
stdlib-js:developfrom
headlessNode:blas/zdiff
Open

feat: add blas/ext/base/zdiff#11741
headlessNode wants to merge 3 commits into
stdlib-js:developfrom
headlessNode:blas/zdiff

Conversation

@headlessNode
Copy link
Copy Markdown
Member


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 status: passed
  • 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: missing_dependencies
  • task: lint_c_examples status: missing_dependencies
  • task: lint_c_benchmarks status: missing_dependencies
  • 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 ---

Resolves stdlib-js/metr-issue-tracker#466.

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/base/zdiff

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?

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

Primarily written by Claude Code.


@stdlib-js/reviewers

---
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
    status: passed
  - 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: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
@headlessNode headlessNode requested a review from a team April 23, 2026 12:57
@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 Apr 23, 2026
@headlessNode headlessNode added Feature Issue or pull request for adding a new feature. METR Pull request associated with the METR project. labels Apr 23, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Apr 23, 2026

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/zdiff $\color{red}684/686$
$\color{green}+0.00%$
$\color{red}42/43$
$\color{green}+0.00%$
$\color{green}5/5$
$\color{green}+0.00%$
$\color{red}684/686$
$\color{green}+0.00%$

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

---
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
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - 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: na
  - task: lint_license_headers
    status: passed
---
@kgryte kgryte removed the Needs Review A pull request which needs code review. label May 19, 2026
/**
* Calculates the k-th discrete forward difference of a double-precision complex floating-point strided array.
*/
void API_SUFFIX(stdlib_strided_zdiff)( const CBLAS_INT N, const CBLAS_INT k, const void *X, const CBLAS_INT strideX, const CBLAS_INT N1, const void *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const void *Append, const CBLAS_INT strideA, void *Out, const CBLAS_INT strideOut, void *Workspace, const CBLAS_INT strideW );
Copy link
Copy Markdown
Member

@kgryte kgryte May 19, 2026

Choose a reason for hiding this comment

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

@headlessNode Why are you using void * here and throughout this PR? That is only for blas/base/* APIs because we need to be compliant with reference BLAS.

In your other work, you correctly typed the interfaces. For example,

CBLAS_INT API_SUFFIX(stdlib_strided_zindex_of)( const CBLAS_INT N, const stdlib_complex128_t searchElement, const stdlib_complex128_t *X, const CBLAS_INT strideX );

This interface is no different.

You need to figure the entirety of the C implementation in this PR.

STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Append, N2, strideA, argv, 8 );
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Out, N+N1+N2-k, strideOut, argv, 10 );
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Workspace, N+N1+N2-1, strideW, argv, 12 );
API_SUFFIX(stdlib_strided_zdiff)( N, k, X, strideX, N1, Prepend, strideP, N2, Append, strideA, Out, strideOut, Workspace, strideW );
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.

This will need to be updated.

STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Append, N2, strideA, argv, 10 );
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Out, N+N1+N2-k, strideOut, argv, 13 );
STDLIB_NAPI_ARGV_STRIDED_COMPLEX128ARRAY( env, Workspace, N+N1+N2-1, strideW, argv, 16 );
API_SUFFIX(stdlib_strided_zdiff_ndarray)( N, k, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Out, strideOut, offsetOut, Workspace, strideW, offsetW );
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.

This will need to be updated.

// If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array...
if ( k == 0 ) {
// Copy `Prepend` into output array:
c_zcopy_ndarray( N1, Prepend, strideP, offsetP, Out, strideOut, offsetOut );
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.

Here, you will cast the arrays to void * when calling into zcopy, as that is what it expects.

Copy link
Copy Markdown
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Apart from the C implementation, this is coming along.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label May 19, 2026
@kgryte kgryte mentioned this pull request May 19, 2026
7 tasks
// If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array...
if ( k == 0 ) {
// Copy `Prepend` into output array:
c_zcopy_ndarray( N1, Prepend, strideP, offsetP, Out, strideOut, offsetOut );
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.

You need to wrap in API_SUFFIX.


// Copy `X` into output array:
io = offsetOut + ( N1 * strideOut );
c_zcopy_ndarray( N, X, strideX, offsetX, Out, strideOut, io );
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.

Same comment.


// Copy `Append` into output array:
io = offsetOut + ( ( N1 + N ) * strideOut );
c_zcopy_ndarray( N2, Append, strideA, offsetA, Out, strideOut, io );
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.

Same comment.

* @param strideOut stride length for Out
* @param offsetOut starting index for Out
*/
static void stdlib_strided_internal_zdiff_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const void *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const void *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, void *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) {
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.

You need to wrap in API_SUFFIX. Also applies to your call signatures below.

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). Feature Issue or pull request for adding a new feature. METR Pull request associated with the METR project. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add blas/ext/base/zdiff

3 participants