Skip to content

Conversation

headlessNode
Copy link
Member

Resolves stdlib-js/metr-issue-tracker#77.

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/sorthp

Related Issues

Does this pull request have any related issues?

This pull request:

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.


@stdlib-js/reviewers

@headlessNode headlessNode added the Feature Issue or pull request for adding a new feature. label Sep 18, 2025
@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 Sep 18, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Sep 18, 2025

Coverage Report

Package Statements Branches Functions Lines
blas/ext/sorthp $\color{green}367/367$
$\color{green}+100.00\%$
$\color{green}26/26$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}367/367$
$\color{green}+100.00\%$

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

Signed-off-by: Muhammad Haris <[email protected]>
@headlessNode headlessNode requested a review from kgryte September 18, 2025 18:26
The function has the following parameters:

- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have a numeric or "generic" [data type][@stdlib/ndarray/dtypes].
- **sortOrder**: sort order (_optional_). May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] having a real or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the complement of the shape defined by `options.dims`. For example, given the input shape `[2, 3, 4]` and `options.dims=[0]`, an [ndarray][@stdlib/ndarray/ctor] sort order must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. Similarly, when performing the operation over all elements in a provided input [ndarray][@stdlib/ndarray/ctor], an [ndarray][@stdlib/ndarray/ctor] sort order must be a zero-dimensional [ndarray][@stdlib/ndarray/ctor]. By default, the sort order is `1` (i.e., increasing order).
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering whether we should also support the string literals 'ascending' and 'descending' and then map those literals to 1 and -1 internally before calling into lower level functions. The rationale is that, from a code readability standpoint, a number literal does not readily convey its meaning. Compare

sorthp( x, -1 );

versus

sorthp( x, 'descending' );

The latter is more literate.

This comment is only directed at the top-level end-user APIs. I am not suggesting we update any lower-level packages.

Copy link
Member

Choose a reason for hiding this comment

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

I am also okay supporting 'desc' and 'asc', as well. Meaning, we could support four literal string values (but not ndarrays!): descending, ascending, desc, and asc.

Copy link
Member

Choose a reason for hiding this comment

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

Although, the abbreviated desc and asc are a bit less obvious.

Copy link
Member

Choose a reason for hiding this comment

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

@Planeshifter Do you have opinions here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@kgryte makes sense

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 Review A pull request which needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: add blas/ext/sorthp
3 participants