Skip to content

Conversation

@piyxsh31
Copy link
Contributor


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: na
  • 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: passed
  • task: lint_license_headers status: passed ---

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/base/ndarray/dapxsum

Related Issues

Does this pull request have any related issues?

No.

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

{{TODO: add disclosure if applicable}}


@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: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@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 Dec 20, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Dec 20, 2025

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/ndarray/dapxsum $\color{green}116/116$
$\color{green}+0.00%$
$\color{green}3/3$
$\color{green}+0.00%$
$\color{green}1/1$
$\color{green}+0.00%$
$\color{green}116/116$
$\color{green}+0.00%$

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

Signed-off-by: piyxsh31 <[email protected]>
@kgryte kgryte added Feature Issue or pull request for adding a new feature. and removed Needs Review A pull request which needs code review. labels Dec 20, 2025

# dapxsum

> Add a scalar constant to each one-dimensional double-precision floating-point ndarray element and compute the sum.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> Add a scalar constant to each one-dimensional double-precision floating-point ndarray element and compute the sum.
> Add a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.

Let's go ahead and make this change to the description here and elsewhere in this PR. I know that you are basing it off of blas/ext/base/dapxsum, but I think the suggested phrasing is a touch better.

/**
* Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.
*
* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant

* Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.
*
* @param arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
* @returns computed sum
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @returns computed sum
* @returns sum

/**
* Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.
*
* @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
* @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant

* Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.
*
* @param {ArrayLikeObject<Object>} arrays - array-like object containing a one-dimensional input ndarray and a zero-dimensional ndarray containing a scalar constant.
* @returns {number} computed sum
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @returns {number} computed sum
* @returns {number} sum

{
"name": "@stdlib/blas/ext/base/ndarray/dapxsum",
"version": "0.0.0",
"description": "Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"description": "Adds a scalar constant to each one-dimensional double-precision floating-point ndarray element and computes the sum.",
"description": "Add a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.",

t.end();
});

tape( 'the function adds a scalar constant to each element and computes the sum', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

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

The tests here are a little too spartan. See other similar base/ndarray packages. You should include tests for non-unit strides, a non-zero offset, negative strides, and what happens when provided an empty ndarray.

v = dapxsum( [ x, alpha ] );

t.strictEqual( v, 16.0, 'returns expected sum' );
t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'does not mutate input ndarray' );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'does not mutate input ndarray' );
t.deepEqual( getData( x ), new Float64Array( [ 1.0, -2.0, 2.0 ] ), 'returns expected value' );


v = dapxsum( [ x, alpha ] );

t.strictEqual( v, 16.0, 'returns expected sum' );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
t.strictEqual( v, 16.0, 'returns expected sum' );
t.strictEqual( v, 16.0, 'returns expected value' );

Copy link
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.

Overall, this is looking good. Needs some minor clean-up and additional tests.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Dec 20, 2025
---
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: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - 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: passed
  - task: lint_license_headers
    status: passed
---
@piyxsh31
Copy link
Contributor Author

@kgryte
I’ve addressed all the suggested cleanups and added additional tests covering non-unit strides, non-zero offsets, negative strides, and empty ndarrays.

Whenever you have time, could you please take another look? Thanks!

Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

A few small documentation edits. Thanks for your PR, which should be ready to go otherwise!

#### dapxsum( arrays )

Computes the sum of a one-dimensional ndarray, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm.
Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
Copy link
Member

Choose a reason for hiding this comment

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

There's a verb form mismatch here - "Adds" (indicative) followed by "compute" (imperative). Function descriptions should use consistent indicative mood throughout.

Suggested change
Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum.

Comment on lines +3 to +4
Adds a scalar constant to each element of a one-dimensional
double-precision floating-point ndarray and compute the sum.
Copy link
Member

Choose a reason for hiding this comment

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

Same verb form issue - "Adds" followed by "compute" should be "computes" for consistency.

Suggested change
Adds a scalar constant to each element of a one-dimensional
double-precision floating-point ndarray and compute the sum.
Adds a scalar constant to each element of a one-dimensional
double-precision floating-point ndarray and computes the sum.

-------
out: number
Sum.
Computed sum.
Copy link
Member

Choose a reason for hiding this comment

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

For consistency with other ndarray packages (e.g., dsum), the return value description should be just "Sum." rather than "Computed sum."

Suggested change
Computed sum.
Sum.


/**
* Computes the sum of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using ordinary recursive summation.
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
Copy link
Member

Choose a reason for hiding this comment

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

Verb form mismatch - "compute" should be "computes" for consistency with "Adds".

Suggested change
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum.


/**
* Sorts a one-dimensional double-precision floating-point ndarray using Shellsort.
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
Copy link
Member

Choose a reason for hiding this comment

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

Same verb form issue - should be "computes" to match "Adds".

Suggested change
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and compute the sum.
* Adds a scalar constant to each element of a one-dimensional double-precision floating-point ndarray and computes the sum.

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. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants