Skip to content

feat: add C implementation for blas/ext/base/ndarray/saxpby - #15816

Open
Erennn7 wants to merge 4 commits into
stdlib-js:developfrom
Erennn7:c-impl/blas/ext/base/ndarray/saxpby
Open

Erennn7 wants to merge 4 commits into
stdlib-js:developfrom
Erennn7:c-impl/blas/ext/base/ndarray/saxpby

Conversation

@Erennn7

@Erennn7 Erennn7 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Progresses #14819

Description

What is the purpose of this pull request?

This pull request:

  • add C implementation for blas/ext/base/ndarray/saxpby

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

  • AI assistance was used for reviewing changes and research. All files, builds, JS/native test suites, benchmarks, and linting have been verified locally.

@stdlib-js/reviewers

@Erennn7
Erennn7 requested a review from a team October 2, 2026 15:30
@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 2, 2026
@stdlib-bot

stdlib-bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

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

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

int main( void ) {
// Create data buffers:
float dataX[] = { 1.0f, 2.0f, 3.0f, 4.0f };
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f };

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.

Suggested change
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f };
const float dataX[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };

const int64_t ndims = 1;

// Specify the array shape:
int64_t shape[] = { 4 };

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.

Suggested change
int64_t shape[] = { 4 };
int64_t shape[] = { 8 };

stdlib_blas_ext_saxpby( arrays );

// Print the result:
for ( int i = 0; i < 4; i++ ) {

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.

Suggested change
for ( int i = 0; i < 4; i++ ) {
for ( int i = 0; i < 8; i++ ) {

int main( void ) {
// Create data buffers:
float dataX[] = { 1.0f, 2.0f, 3.0f, 4.0f };
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f };

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.

Suggested change
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f };
const float dataX[] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
float dataY[] = { 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f };

The C example here repeats the same data and constants as the usage example above, so the two end up showing the exact same computation. It would be clearer if this one used a different setup.

How about reusing the data from blas/ext/base/ndarray/dxpy's C example? Since y is also an input for saxpby, it should stay non-zero;

const int64_t ndims = 1;

// Specify the array shape:
int64_t shape[] = { 4 };

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.

Suggested change
int64_t shape[] = { 4 };
int64_t shape[] = { 8 };

const int64_t nsubmodes = 1;

// Create input ndarrays:
struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)dataX, ndims, shape, strides, offset, order, imode, nsubmodes, submodes );

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.

Suggested change
struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)dataX, ndims, shape, strides, offset, order, imode, nsubmodes, submodes );
struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)dataX, ndims, shape, strides, offset, order, imode, nsubmodes, submodes );

stdlib_blas_ext_saxpby( arrays );

// Print the result:
for ( int i = 0; i < 4; i++ ) {

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.

Suggested change
for ( int i = 0; i < 4; i++ ) {
for ( int i = 0; i < 8; i++ ) {

@ujjwalv01

Copy link
Copy Markdown
Member

Left a few suggestions;

@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 Oct 5, 2026
@Erennn7

Erennn7 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @ujjwalv01! I've updated binding.gyp and updated the C example data and formatting accordingly.

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

Looks good to me!

@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. and removed Needs Changes Pull request which needs changes before being merged. labels Oct 6, 2026

@0PrashantYadav0 0PrashantYadav0 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.

The AI disclosure in the PR description still reads {{TODO: add disclosure if applicable}} even though "Yes" is checked. Please fill it in.

Comment thread lib/node_modules/@stdlib/blas/ext/base/ndarray/saxpby/README.md Outdated
Co-authored-by: JoyBoy <prashantyadav09783@gmail.com>
Signed-off-by: Samarth Kolarkar <144821218+Erennn7@users.noreply.github.com>

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. Feature Issue or pull request for adding a new feature. Needs Review A pull request which needs code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants