Skip to content

feat: add C implementation for blas/ext/base/ndarray/dcartesian-product - #15804

Open
benatsf wants to merge 1 commit into
stdlib-js:developfrom
benatsf:feat/ndarray-dcartesian-product-native
Open

benatsf wants to merge 1 commit into
stdlib-js:developfrom
benatsf:feat/ndarray-dcartesian-product-native

Conversation

@benatsf

@benatsf benatsf commented Oct 2, 2026

Copy link
Copy Markdown

Refs #14819.

Description

This pull request adds a C API and optional Node.js native addon for @stdlib/blas/ext/base/ndarray/dcartesian-product. The adapter passes two input ndarrays and the output ndarray to the existing Cartesian-product C kernel, converting byte strides and offsets into element indices. The function retains its ndarray collection argument, pair ordering, and output identity. Browser and unavailable-addon environments use the existing JavaScript implementation.

The complete package port includes a public header, N-API bridge, native build metadata, C documentation/example/benchmark, and public, JavaScript, and native behavior tests. Its GYP configuration follows the existing strided Cartesian-product package, including Fortran compilation for the transitive BLAS dcopy dependency used by column-major outputs.

Related Issues

Questions

No.

Other

Validated on Linux x86_64 with Node 24.19.0, GCC 14.2.0, and GNU Fortran 14.2.0. The compiled addon is selected by the public export, and direct per-file processes pass all 102 assertions: 34 public, 34 JavaScript, and 34 native, with no skips. Fixtures cover mathematical pair order, row-major and column-major outputs, empty inputs, padded/negative/zero strides, logical and typed-buffer offsets, unchanged input/output guards, and NaN/infinity/signed-zero copying. Simulated unavailable-addon execution selects the unchanged JavaScript implementation and produces the expected column-major result. An independent Codex review also passed 10 additional native/JavaScript parity probes, including shared input views and overlapping output layouts.

The C example compiles and produces all six expected pairs; all nine C and nine native JavaScript benchmark runs complete. JavaScript, Markdown, explicit package metadata, applicable C lint/license checks, both upstream EditorConfig configurations, and whitespace checks pass. No performance improvement is claimed. Other platforms were not tested.

Checklist

AI Assistance

  • Yes

  • No

  • Code generation

  • Test/benchmark generation

  • Documentation (including examples)

  • Research and understanding

Disclosure

The C adapter, Node.js addon, tests, build metadata, documentation, and research were prepared primarily by OpenAI Codex, using the project's existing native ndarray adapters and strided Cartesian-product build configuration. The numerical C kernel and JavaScript implementation are reused. The contributing-guidelines acknowledgment records Codex's review and application of the guidelines under benatsf's explicit authorization to contribute. It does not claim that benatsf personally read the guide or manually reviewed the code. No manual applicant review is claimed.

Add the ndarray C adapter, Node-API bridge and Fortran-aware native build metadata. Preserve the JavaScript fallback and cover Cartesian ordering, column-major layouts, strides, offsets and special values in native parity tests.

Assisted-by: OpenAI Codex
@benatsf
benatsf requested a review from a team October 2, 2026 11:13
@stdlib-bot stdlib-bot added BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). 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. labels Oct 2, 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). 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.

2 participants