Skip to content

feat: add blas/ext/axpb#12861

Open
anandkaranubc wants to merge 3 commits into
stdlib-js:developfrom
anandkaranubc:feat/axpb
Open

feat: add blas/ext/axpb#12861
anandkaranubc wants to merge 3 commits into
stdlib-js:developfrom
anandkaranubc:feat/axpb

Conversation

@anandkaranubc

Copy link
Copy Markdown
Contributor

Resolves stdlib-js/metr-issue-tracker#639

Description

What is the purpose of this pull request?

This pull request:

  • adds blas/ext/base/axpb

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

Used Cursor+VS Code code-generation tools to help assist with the feature.


@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_pkg_readmes
    status: passed
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - 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
---
@anandkaranubc anandkaranubc requested a review from a team June 14, 2026 03:04
@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 Jun 14, 2026
@stdlib-bot

stdlib-bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
blas/ext/axpb $\\color{green}395/395$
$\\color{green}+100.00\\%$
$\\color{green}59/59$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}395/395$
$\\color{green}+100.00\\%$

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

@anandkaranubc

Copy link
Copy Markdown
Contributor Author

Total implementation time: 202 minutes 😅

I finally was able to implement this, @kgryte! 😮‍💨

@anandkaranubc anandkaranubc added Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. METR Pull request associated with the METR project. labels Jun 14, 2026
anandkaranubc and others added 2 commits June 13, 2026 20:07
---
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_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - 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: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc anandkaranubc changed the title feat: add blas/ext/base/axpb feat: add blas/ext/axpb Jun 14, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Jun 14, 2026
var bench = require( '@stdlib/bench' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var uniform = require( '@stdlib/random/array/uniform' );

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
var uniform = require( '@stdlib/random/array/uniform' );
var uniform = require( '@stdlib/random/uniform' );

You should be using the API to generate random ndarrays directly.

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.

I see that we are doing this in blas/ext/cusum, but that should likely be updated in order to use top-level APIs. Feel free to make a METR task to update the top-level blas/ext/* APIs (where appropriate).

var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pow = require( '@stdlib/math/base/special/pow' );
var uniform = require( '@stdlib/random/array/uniform' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );

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
var ndarray = require( '@stdlib/ndarray/base/ctor' );

* ## Notes
*
* - The input ndarray is modified **in-place** (i.e., the input ndarray is **mutated**).
* - By default, the function multiplies each element by `1.0` and adds `0.0` (i.e., performs a no-op).

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.

Why are alpha and beta optional parameters? This seems odd to me. I would expect them to be mandatory, as that is the entire point of axpb.

Comment on lines +35 to +40
type Alpha = ndarray | number | ComplexLike;

/**
* Beta parameter.
*/
type Beta = ndarray | number | ComplexLike;

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.

Instead of separate types, I would suggest doing something like type ScalarArgument = ndarray | ... and then, in your signatures, do alpha: ScalarArgument, beta: ScalarArgument, etc.

@@ -0,0 +1,50 @@

{{alias}}( x[, alpha][, beta][, options] )

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.

Yeah, this sort of signature is going to lead to all sorts of argument juggling, especially as you have no way of distinguishing between alpha and beta when wanting to only provide beta.

TL;DR: make alpha and beta mandatory arguments, similar to have the searchElement argument in index-of is mandatory.

Comment on lines +26 to +41
// Create a data buffer:
var xbuf = discreteUniform( 10, -100, 100, {
'dtype': 'generic'
});

// Define the shape of the input array:
var shape = [ 5, 2 ];

// Define the array strides:
var sx = [ 2, 1 ];

// Define the index offset:
var ox = 0;

// Create an input ndarray:
var x = new ndarray( 'generic', xbuf, shape, sx, ox, 'row-major' );

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.

Use the top-level random/discrete-uniform package. Then you can avoid all this manual ndarray creation noise.

'default': gaxpb
};
var options = {
'strictTraversalOrder': true

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.

Why is this necessary?

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

Left initial comments. TL;DR: this needs to be refactored to make alpha and beta mandatory. This should simplify your argument juggling logic significantly.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Jun 14, 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. JavaScript Issue involves or relates to JavaScript. 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/axpb

3 participants