Skip to content

Conversation

@MeKaustubh07
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
Resolves None.


Description

What is the purpose of this pull request?

This pull request:

  • feat : add blas/ext/base/ndarray/dsort2hp

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

  • none

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

This PR was created by duplicating the dsorthp package and adapting it to compute the maximum absolute value instead of the maximum value. GitHub Copilot assisted with updating test cases, documentation, and verifying consistency across all files.


@stdlib-js/reviewers

@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/dsort2hp $\color{green}143/143$
$\color{green}+0.00%$
$\color{green}3/3$
$\color{green}+0.00%$
$\color{green}1/1$
$\color{green}+0.00%$
$\color{green}143/143$
$\color{green}+0.00%$

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

@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
'dtype': 'generic'
});

var out = dsort2hp( [ x, y, order ] );
Copy link
Member

Choose a reason for hiding this comment

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

You should probably show that the return array is the first input array.

var bool = ( out === x );
// returns true

var out = dsort2hp( [ x, y, order ] );
// returns <ndarray>

var arrX = ndarray2array( out );
Copy link
Member

Choose a reason for hiding this comment

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

Using ndarray2array here is fine, as it is not readily doable to use <ndarray>[ ... ] notation above.

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':len='+len, f );
Copy link
Member

Choose a reason for hiding this comment

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

@MeKaustubh07 Mind for all future PRs going ahead and heeding the lint warning here? Namely, using @string/string/format for benchmark descriptions. This will save ourselves future work.

Simultaneously sorts two one-dimensional double-precision floating-point
ndarrays based on the sort order of the first array using heapsort.

When the sort order is less than zero, the input ndarrays are sorted in
Copy link
Member

Choose a reason for hiding this comment

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

This note is not accurate. We only sort the first input ndarray in decreasing order. The second input ndarray is sorted based on the first and that likely means it is not sorted in either ascending or descending order.

decreasing order. When the sort order is greater than zero, the input
ndarrays are sorted in increasing order. When the sort order is equal to
zero, the input ndarrays are left unchanged.

Copy link
Member

Choose a reason for hiding this comment

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

Compared to blas/ext/base/dsort2hp, you've left out a number of the notes regarding sort properties. Why?

Copy link
Member

Choose a reason for hiding this comment

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

We should likely include those notes, with some modification, as well as include the omitted notes in the sorting packages you've already landed.

*
* ## Notes
*
* - When the sort order is less than zero, the input ndarrays are sorted in **decreasing** order. When the sort order is greater than zero, the input ndarrays are sorted in **increasing** order. When the sort order is equal to zero, the input ndarrays are left unchanged.
Copy link
Member

Choose a reason for hiding this comment

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

This note isn't accurate.

*
* ## Notes
*
* - When the sort order is less than zero, the input ndarrays are sorted in **decreasing** order. When the sort order is greater than zero, the input ndarrays are sorted in **increasing** order. When the sort order is equal to zero, the input ndarrays are left unchanged.
Copy link
Member

Choose a reason for hiding this comment

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

This note isn't accurate.

* - When the sort order is less than zero, the input ndarrays are sorted in **decreasing** order. When the sort order is greater than zero, the input ndarrays are sorted in **increasing** order. When the sort order is equal to zero, the input ndarrays are left unchanged.
*
* @param {ArrayLikeObject<Object>} arrays - array-like object containing two one-dimensional input ndarrays and a zero-dimensional ndarray specifying the sort order
* @returns {ndarray} first 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
* @returns {ndarray} first input ndarray
* @returns {Object} first 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.

Why do we use Object here? The reason is due to how these packages are used. Namely, they are consumed by higher-order machinery which doesn't actually pass in an ndarray here, but an object with ndarray-like properties. Hence, we use Object, rather than ndarray, where the latter conveys an instance.

Copy link
Member

Choose a reason for hiding this comment

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

We could use ndarrayLike, but we've already established precedent with ArrayLikeObject<Object>.

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.

Left an initial review.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Dec 20, 2025
@MeKaustubh07
Copy link
Contributor Author

@kgryte: I understand the concerns.I’ll address all of the suggested changes and ensure greater consistency going forward to avoid this in future PRs.

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.

3 participants