Skip to content

feat: add blas/ext/base/gmskrev#10925

Open
headlessNode wants to merge 5 commits into
stdlib-js:developfrom
headlessNode:gmskrev
Open

feat: add blas/ext/base/gmskrev#10925
headlessNode wants to merge 5 commits into
stdlib-js:developfrom
headlessNode:gmskrev

Conversation

@headlessNode
Copy link
Copy Markdown
Member

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

Description

What is the purpose of this pull request?

This pull request:

  • add blas/ext/base/gmskrev

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

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

Primarily written by Claude Code.


@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 Mar 14, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Mar 14, 2026

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/gmskrev $\color{green}353/353$
$\color{green}+0.00%$
$\color{green}27/27$
$\color{green}+0.00%$
$\color{green}3/3$
$\color{green}+0.00%$
$\color{green}353/353$
$\color{green}+0.00%$

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

@headlessNode headlessNode added Feature Issue or pull request for adding a new feature. METR Pull request associated with the METR project. labels Mar 14, 2026
@headlessNode headlessNode requested a review from kgryte March 14, 2026 00:55
@kgryte kgryte removed the Needs Review A pull request which needs code review. label May 20, 2026
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/docs/types/index.d.ts Outdated
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/docs/types/index.d.ts Outdated
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/docs/types/test.ts Outdated
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/docs/types/test.ts Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte kgryte requested a review from a team May 20, 2026 20:31
Signed-off-by: Athan <kgryte@gmail.com>
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label May 20, 2026
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/docs/repl.txt Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/lib/accessors.js Outdated
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/lib/accessors.js
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/lib/accessors.js
Comment thread lib/node_modules/@stdlib/blas/ext/base/gmskrev/lib/accessors.js Outdated
im = offsetMask;
jm = im + ( ( N - 1 ) * strideMask );
for ( i = 0; i < n; i++ ) {
if ( mget( mbuf, im ) === 0 && mget( mbuf, jm ) === 0 ) {
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.

This is not correct. Why do pairs need to both be unmasked? This means that one value can effectively mask another. A mask is intended to reduce the domain of which values are reversed.

Consider the following trivial example:

var x = [ 1, 2, 3 ];
var mask = [ 1, 0, 0 ];

gmskrev( ..., x, ..., mask, ... )

By your logic, the result should be

[ 1, 2, 3 ]

But that is not the right result. It should be

[ 1, 3, 2 ]

This affects all of this and related PRs.

return x;
}
for ( i = m; i < n; i += M ) {
if ( mask[ im ] === 0 && mask[ jm ] === 0 ) {
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.

Loop unrolling is not useful for this implementation. You should refactor to use a single loop.

iy = ix + ( (N-1) * strideX );
jm = im + ( (N-1) * strideMask );
for ( i = 0; i < n; i++ ) {
if ( mask[ im ] === 0 && mask[ jm ] === 0 ) {
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.

While this implementation is incorrect, this is the only loop which is necessary. Loop unrolling is not particularly effective when you have nested conditionals.

- **N**: number of indexed elements.
- **x**: input array.
- **strideX**: stride length for `x`.
- **mask**: mask array.
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.


- If `N <= 0`, both functions return `x` unchanged.
- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/complex64`][@stdlib/array/complex64]).
- A mask value of `0` indicates that the corresponding element in `x` participates in the reversal, while a non-zero mask value indicates that the corresponding element should be skipped.
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.

This can be removed once you update above.

Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Copy link
Copy Markdown
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 initial comments. This and related PRs need quite a bit of clean-up and refactoring.

@kgryte kgryte removed the Needs Review A pull request which needs code review. label May 20, 2026
@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label May 20, 2026
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. METR Pull request associated with the METR project. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add blas/ext/base/gmskrev

3 participants