Skip to content

feat: add blas/base/wasm/zscal #6810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

ShabiShett07
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 ---

Progresses #2039

Description

What is the purpose of this pull request?

This pull request:

  • Adds the package blas/base/wasm/zscal

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

---
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
---
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Apr 25, 2025
---
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: 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@ShabiShett07
Copy link
Contributor Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added the bot: In Progress Pull request is currently awaiting automation. label Apr 25, 2025
@stdlib-bot stdlib-bot removed the bot: In Progress Pull request is currently awaiting automation. label Apr 25, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Apr 25, 2025

Coverage Report

Package Statements Branches Functions Lines
blas/base/wasm/zscal $\color{green}698/698$
$\color{green}+100.00\%$
$\color{green}17/17$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}698/698$
$\color{green}+100.00\%$
complex/float64/base/mul $\color{green}310/310$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}310/310$
$\color{green}+100.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. WebAssembly Issue involves or relates to WebAssembly. BLAS Issue or pull request related to Basic Linear Algebra Subprograms (BLAS). labels Apr 25, 2025
@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 25, 2025
---
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: na
  - 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
---
@ShabiShett07
Copy link
Contributor Author

@kgryte, I have changed the variable names

Shabareesh Shetty added 7 commits August 1, 2025 11:32
---
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: 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: na
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: 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: na
  - 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
---
---
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: 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: passed
  - task: lint_javascript_tests
    status: na
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: 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: na
  - 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
---
---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
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: 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: na
  - 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: na
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@ShabiShett07 ShabiShett07 marked this pull request as ready for review August 1, 2025 06:30
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 1, 2025
@ShabiShett07 ShabiShett07 requested a review from kgryte August 1, 2025 06:30
@kgryte kgryte removed the Needs Changes Pull request which needs changes before being merged. label Aug 13, 2025
Comment on lines +84 to +102
mod.realloc( ((N*2)*nb)+nb );

// Define a pointer (i.e., byte offset) to the first vector element:
xptr = 0;

// Define a pointer to a complex number:
zptr = (N*2) * nb;

// Write random values to module memory:
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) );
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) );

// Retrieve a DataView of module memory:
view = mod.view;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
mod.main( (N*2), zptr, xptr, 1 );
byteOffset = xptr + ( (i%(N*2))*nb );
Copy link
Member

Choose a reason for hiding this comment

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

You seem to be a bit confused regarding bytes offsets and the mixing of real and complex.

Suggested change
mod.realloc( ((N*2)*nb)+nb );
// Define a pointer (i.e., byte offset) to the first vector element:
xptr = 0;
// Define a pointer to a complex number:
zptr = (N*2) * nb;
// Write random values to module memory:
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) );
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) );
// Retrieve a DataView of module memory:
view = mod.view;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
mod.main( (N*2), zptr, xptr, 1 );
byteOffset = xptr + ( (i%(N*2))*nb );
mod.realloc( (N*nb)+nb );
// Define a pointer (i.e., byte offset) to the first vector element:
xptr = 0;
// Define a pointer to a complex number:
zptr = N * nb;
// Write random values to module memory:
mod.write( xptr, uniform( (N*2), -100.0, 100.0, options ) );
mod.write( zptr, new Float64Array( [ 1.0, 0.0 ] ) );
// Retrieve a DataView of module memory:
view = mod.view;
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
mod.main( N, zptr, xptr, 1 );
byteOffset = xptr + ( (i%N)*nb );


// Reallocate the underlying memory to allow storing one vector and a complex number:
nb = bytesPerElement( 'complex128' );
mod.realloc( ((N*2)*nb)+nb );
Copy link
Member

Choose a reason for hiding this comment

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

Same changes here. You are over-allocating by 2x. nb is the number of bytes per element for complex128, not float64.

> {{alias}}.main( 2, alpha, x, 1 )
<Complex128Array>[ -3.0, 4.0, -5.0, 10.0 ]

// Advanced indexing:
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
// Advanced indexing:
// Using `N` and stride parameters:

// Using typed array views:
> var x0 = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
> var x1 = new {{alias:@stdlib/array/complex128}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
> var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 );
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
> var alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 );
> alpha = new {{alias:@stdlib/complex/float64/ctor}}( 2.0, 2.0 );

alpha has already been declared above.

Number of indexed elements.

alpha: Complex128
Complex constant.
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
Complex constant.
Scalar constant.

Number of indexed elements.

alpha: Complex128
Complex constant.
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
Complex constant.
Scalar constant.

Number of indexed elements.

ap: integer
Pointer (i.e., byte offset) to a scalar complex constant.
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
Pointer (i.e., byte offset) to a scalar complex constant.
Pointer (i.e., byte offset) to a scalar constant.

Number of indexed elements.

ap: integer
Pointer (i.e., byte offset) to a scalar complex constant.
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
Pointer (i.e., byte offset) to a scalar complex constant.
Pointer (i.e., byte offset) to a scalar constant.

mod.write( xp, new Complex128Array( [ 0.3, 0.1, 0.5, 0.0, 0.0, 0.5 ] ) );
mod.write( ap, new Float64Array( [ 0.4, -0.7 ] ) );

out = mod.main( 0, ap, xp, 1 );
Copy link
Member

Choose a reason for hiding this comment

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

This test is incorrect. You need to actually confirm that the original array is unchanged. This test does nothing of the sort. For an idea of what is expected, see blas/base/wasm/daxpy/test/test.module.main.js.

t.end();
});

tape( 'a module instance has a `main` method which returns a reference to the input array', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't return a reference. It returns a pointer. See the Wasm implementation for daxpy.

t.end();
});

tape( 'a module instance has an `ndarray` method which returns a reference to the input array', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

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

It doesn't return a reference. It returns a pointer. See the Wasm implementation for daxpy.

mod.write( ap, new Float64Array( [ 0.4, -0.7 ] ) );

out = mod.ndarray( 0, ap, xp, 1, 0 );
t.strictEqual( out, xp, 'returns expected value' );
Copy link
Member

Choose a reason for hiding this comment

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

Same comment. You are not testing that the array is left unchanged.

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 initial comments. This PR is mostly in good shape. The most glaring defect is in the tests.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Aug 13, 2025
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. WebAssembly Issue involves or relates to WebAssembly.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants