Repository navigation
Conversation
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
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
dcopydependency used by column-major outputs.Related Issues
blas/ext/base/ndarraypackages #14819Questions
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.