feat: add blas/ext/axpb#12861
Conversation
---
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
---
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
Total implementation time: 202 minutes 😅 I finally was able to implement this, @kgryte! 😮💨 |
---
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
---
| 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' ); |
There was a problem hiding this comment.
| var uniform = require( '@stdlib/random/array/uniform' ); | |
| var uniform = require( '@stdlib/random/uniform' ); |
You should be using the API to generate random ndarrays directly.
There was a problem hiding this comment.
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' ); |
There was a problem hiding this comment.
| 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). |
There was a problem hiding this comment.
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.
| type Alpha = ndarray | number | ComplexLike; | ||
|
|
||
| /** | ||
| * Beta parameter. | ||
| */ | ||
| type Beta = ndarray | number | ComplexLike; |
There was a problem hiding this comment.
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] ) | |||
There was a problem hiding this comment.
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.
| // 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' ); |
There was a problem hiding this comment.
Use the top-level random/discrete-uniform package. Then you can avoid all this manual ndarray creation noise.
| 'default': gaxpb | ||
| }; | ||
| var options = { | ||
| 'strictTraversalOrder': true |
kgryte
left a comment
There was a problem hiding this comment.
Left initial comments. TL;DR: this needs to be refactored to make alpha and beta mandatory. This should simplify your argument juggling logic significantly.
Resolves stdlib-js/metr-issue-tracker#639
Description
This pull request:
blas/ext/base/axpbRelated Issues
This pull request has the following related issues:
blas/ext/axpbmetr-issue-tracker#639Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
Used Cursor+VS Code code-generation tools to help assist with the feature.
@stdlib-js/reviewers