From 54bf3d5b1682fb9cc02786ac610b4154866aacaa Mon Sep 17 00:00:00 2001 From: aman-095 Date: Sat, 15 Feb 2025 18:26:41 +0530 Subject: [PATCH 1/4] feat: add wasm support for sscal --- 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../@stdlib/blas/base/wasm/sscal/README.md | 317 +++++++++++ .../base/wasm/sscal/benchmark/benchmark.js | 106 ++++ .../wasm/sscal/benchmark/benchmark.module.js | 66 +++ .../sscal/benchmark/benchmark.module.main.js | 135 +++++ .../benchmark/benchmark.module.ndarray.js | 135 +++++ .../wasm/sscal/benchmark/benchmark.ndarray.js | 106 ++++ .../blas/base/wasm/sscal/docs/repl.txt | 520 ++++++++++++++++++ .../base/wasm/sscal/docs/types/index.d.ts | 376 +++++++++++++ .../blas/base/wasm/sscal/docs/types/test.ts | 413 ++++++++++++++ .../blas/base/wasm/sscal/examples/index.js | 44 ++ .../sscal/examples/little_endian_arrays.js | 65 +++ .../blas/base/wasm/sscal/examples/module.js | 68 +++ .../base/wasm/sscal/lib/binary.browser.js | 33 ++ .../blas/base/wasm/sscal/lib/binary.js | 34 ++ .../@stdlib/blas/base/wasm/sscal/lib/index.js | 108 ++++ .../@stdlib/blas/base/wasm/sscal/lib/main.js | 60 ++ .../blas/base/wasm/sscal/lib/module.js | 235 ++++++++ .../blas/base/wasm/sscal/lib/routine.js | 175 ++++++ .../blas/base/wasm/sscal/manifest.json | 36 ++ .../@stdlib/blas/base/wasm/sscal/package.json | 80 +++ .../blas/base/wasm/sscal/scripts/build.js | 63 +++ .../blas/base/wasm/sscal/scripts/template.txt | 33 ++ .../@stdlib/blas/base/wasm/sscal/src/Makefile | 243 ++++++++ .../blas/base/wasm/sscal/src/exports.json | 4 + .../blas/base/wasm/sscal/src/main.wasm | Bin 0 -> 433 bytes .../@stdlib/blas/base/wasm/sscal/src/main.wat | 177 ++++++ .../@stdlib/blas/base/wasm/sscal/test/test.js | 53 ++ .../blas/base/wasm/sscal/test/test.main.js | 186 +++++++ .../blas/base/wasm/sscal/test/test.module.js | 154 ++++++ .../base/wasm/sscal/test/test.module.main.js | 253 +++++++++ .../wasm/sscal/test/test.module.ndarray.js | 289 ++++++++++ .../blas/base/wasm/sscal/test/test.ndarray.js | 183 ++++++ .../blas/base/wasm/sscal/test/test.routine.js | 71 +++ 33 files changed, 4821 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/src/exports.json create mode 100755 lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wasm create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.routine.js diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md new file mode 100644 index 000000000000..d60be003bafa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md @@ -0,0 +1,317 @@ + + +# sscal + +> Multiply a vector `x` by a constant `alpha`. + +
+ +## Usage + +```javascript +var sscal = require( '@stdlib/blas/base/wasm/sscal' ); +``` + +#### sscal.main( N, alpha, x, strideX ) + +Multiplies a vector `x` by a constant `alpha`. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +sscal.main( x.length, 5.0, x, 1 ); +// x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **alpha**: scalar constant. +- **x**: input [`Float32Array`][@stdlib/array/float32]. +- **strideX**: index increment for `x`. + +The `N` and stride parameters determine which elements in the input strided array are accessed at runtime. For example, to multiply every other value in `x` by `alpha` in reverse order, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +sscal.main( 5, 5.0, x, -1 ); +// x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial array: +var x0 = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create a typed array view: +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +sscal.main( 3, 5.0, x1, -2 ); +// x0 => [ 1.0, 10.0, 3.0, 20.0, 5.0, 30.0 ] +``` + +#### sscal.ndarray( N, alpha, x, strideX, offsetX ) + +Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +sscal.ndarray( x.length, 5.0, x, 1, 0 ); +// x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to multiply every other value in `x` by a constant `alpha` starting from the second element, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +sscal.ndarray( 3, 5.0, x, 2, 1 ); +// x => [ 1.0, 10.0, 3.0, 20.0, 5.0, 30.0 ] +``` + +* * * + +### Module + +#### sscal.Module( memory ) + +Returns a new WebAssembly [module wrapper][@stdlib/wasm/module-wrapper] instance which uses the provided WebAssembly [memory][@stdlib/wasm/memory] instance as its underlying memory. + + + +```javascript +var Memory = require( '@stdlib/wasm/memory' ); + +// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +var mem = new Memory({ + 'initial': 10, + 'maximum': 100 +}); + +// Create a BLAS routine: +var mod = new sscal.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); +``` + +#### sscal.Module.prototype.main( N, α, xp, sx ) + +Multiplies a vector `x` by a constant `α`. + + + +```javascript +var Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ones = require( '@stdlib/array/ones' ); +var zeros = require( '@stdlib/array/zeros' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + +// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +var mem = new Memory({ + 'initial': 10, + 'maximum': 100 +}); + +// Create a BLAS routine: +var mod = new sscal.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float32'; + +// Specify a vector length: +var N = 5; + +// Define pointer (i.e., byte offsets) for storing input vector: +var xptr = 0; + +// Write vector values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); + +// Perform computation: +mod.main( N, 5.0, xptr, 1 ); + +// Read out the results: +var view = zeros( N, dtype ); +mod.read( xptr, view ); + +console.log( view ); +// => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **α**: scalar constant. +- **xp**: input [`Float32Array`][@stdlib/array/float32] pointer (i.e., byte offset). +- **sx**: index increment for `x`. + +#### sscal.Module.prototype.ndarray( N, α, xp, sx, ox ) + +Multiplies a vector `x` by a constant `α` using alternative indexing semantics. + + + +```javascript +var Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ones = require( '@stdlib/array/ones' ); +var zeros = require( '@stdlib/array/zeros' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + +// Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +var mem = new Memory({ + 'initial': 10, + 'maximum': 100 +}); + +// Create a BLAS routine: +var mod = new sscal.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float32'; + +// Specify a vector length: +var N = 5; + +// Define pointer (i.e., byte offsets) for storing input vector: +var xptr = 0; + +// Write vector values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); + +// Perform computation: +mod.ndarray( N, 5.0, xptr, 1, 0 ); + +// Read out the results: +var view = zeros( N, dtype ); +mod.read( xptr, view ); + +console.log( view ); +// => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. + +
+ + + +
+ +* * * + +## Notes + +- If `N <= 0`, `x` is left unchanged. +- This package implements routines using WebAssembly. When provided arrays which are not allocated on a `sscal` module memory instance, data must be explicitly copied to module memory prior to computation. Data movement may entail a performance cost, and, thus, if you are using arrays external to module memory, you should prefer using [`@stdlib/blas/base/sscal`][@stdlib/blas/base/sscal]. However, if working with arrays which are allocated and explicitly managed on module memory, you can achieve better performance when compared to the pure JavaScript implementations found in [`@stdlib/blas/base/sscal`][@stdlib/blas/base/sscal]. Beware that such performance gains may come at the cost of additional complexity when having to perform manual memory management. Choosing between implementations depends heavily on the particular needs and constraints of your application, with no one choice universally better than the other. +- `sscal()` corresponds to the [BLAS][blas] level 1 function [`sscal`][sscal]. + +
+ + + +
+ +* * * + +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sscal = require( '@stdlib/blas/base/wasm/sscal' ); + +var opts = { + 'dtype': 'float32' +}; +var x = discreteUniform( 10, 0, 100, opts ); +console.log( x ); + +sscal.ndarray( x.length, 5.0, x, 1, 0 ); +console.log( x ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js new file mode 100644 index 000000000000..73e9a5839b09 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var sscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -100.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = sscal.main( x.length, 1.01, x, 1 ); + if ( isnan( y[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js new file mode 100644 index 000000000000..89ab57e10ea7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var pkg = require( './../package.json' ).name; +var sscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; + + +// MAIN // + +bench( pkg+':Module:constructor', opts, function benchmark( b ) { + var values; + var o; + var v; + var i; + + o = { + 'initial': 0 + }; + values = [ + new Memory( o ), + new Memory( o ) + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = new sscal.Module( values[ i%values.length ] ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( typeof v !== 'object' ) { + b.fail( 'should return an object' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js new file mode 100644 index 000000000000..5dcf64347dec --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js @@ -0,0 +1,135 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var sscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var byteOffset; + var view; + var xptr; + var mod; + var mem; + var nb; + var i; + + // Create a new BLAS routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new sscal.Module( mem ); + + // Initialize the module: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Reallocate the underlying memory to allow storing two vectors: + nb = bytesPerElement( options.dtype ); + mod.realloc( len*nb ); + + // Define pointer (i.e., byte offsets) to the vector elements: + xptr = 0; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -100.0, 100.0, options ) ); + + // Retrieve a DataView of module memory: + view = mod.view; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mod.main( len, 5.0, xptr, 1 ); + byteOffset = xptr + ( (i%len)*nb ); + if ( isnan( view.getFloat32( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( view.getFloat32( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::module,pointers:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js new file mode 100644 index 000000000000..d9752bf8f32b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js @@ -0,0 +1,135 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var sscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var byteOffset; + var view; + var xptr; + var mod; + var mem; + var nb; + var i; + + // Create a new BLAS routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new sscal.Module( mem ); + + // Initialize the module: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Reallocate the underlying memory to allow storing two vectors: + nb = bytesPerElement( options.dtype ); + mod.realloc( len*nb ); + + // Define pointers (i.e., byte offsets) to the first vector elements: + xptr = 0; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -100.0, 100.0, options ) ); + + // Retrieve a DataView of module memory: + view = mod.view; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mod.ndarray( len, 5.0, xptr, 1, 0 ); + byteOffset = xptr + ( (i%len)*nb ); + if ( isnan( view.getFloat32( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( view.getFloat32( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+'::module,pointers:ndarray:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..ca594864aa08 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var sscal = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -100.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = sscal.ndarray( x.length, 5.0, x, 1, 0 ); + if ( isnan( y[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ i%x.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt new file mode 100644 index 000000000000..4468bb96ff79 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt @@ -0,0 +1,520 @@ + +{{alias}}.main( N, alpha, x, strideX ) + Multiplies a vector `x` by a constant `alpha`. + + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N <= 0`, the function returns `x` unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: number + Constant. + + x: Float32Array + Input array. + + strideX: integer + Index increment for `x`. + + Returns + ------- + x: Float32Array + Input array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > {{alias}}.main( x.length, 5.0, x, 1 ) + [ -10.0, 5.0, 15.0, -25.0 ] + + // Using `N` and stride parameters: + > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > {{alias}}.main( 2, 5.0, x, 2 ) + [ -10.0, 1.0, 15.0, -5.0 ] + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > {{alias}}.main( 2, 5.0, x1, 2 ) + [ -10.0, 3.0, -20.0 ] + > x0 + [ 1.0, -10.0, 3.0, -20.0 ] + + +{{alias}}.ndarray( N, alpha, x, strideX, offsetX ) + Multiplies a vector `x` by a constant `alpha` using alternative indexing + semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alpha: number + Constant. + + x: Float32Array + Input array. + + strideX: integer + Index increment for `x`. + + offsetX: integer + Starting index for `x`. + + Returns + ------- + x: Float32Array + Input array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 3.0, -5.0 ] ); + > {{alias}}.ndarray( x.length, 5.0, x, 1, 0 ) + [ -10.0, 5.0, 15.0, -25.0 ] + + // Using an index offset: + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, -4.0, 5.0 ] ); + > {{alias}}.ndarray( 2, 5.0, x, 2, 1 ) + [ 1.0, -10.0, 3.0, -20.0, 5.0 ] + + +{{alias}}.Module( memory ) + Returns a new WebAssembly module wrapper which uses the provided WebAssembly + memory instance as its underlying memory. + + Parameters + ---------- + memory: Memory + WebAssembly memory instance. + + Returns + ------- + mod: Module + WebAssembly module wrapper. + + Examples + -------- + // Create a new memory instance: + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + + // Create a new routine: + > var mod = new {{alias}}.Module( mem ); + + // Initialize the routine: + > mod.initializeSync(); + + +{{alias}}.Module.prototype.binary + Read-only property which returns WebAssembly binary code. + + Returns + ------- + out: Uint8Array + WebAssembly binary code. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.binary + + + +{{alias}}.Module.prototype.memory + Read-only property which returns WebAssembly memory. + + Returns + ------- + mem: Memory|null + WebAssembly memory. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.memory + + + +{{alias}}.Module.prototype.buffer + Read-only property which returns a WebAssembly memory buffer as a + Uint8Array. + + Returns + ------- + buf: Uint8Array|null + WebAssembly memory buffer. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.buffer + + + +{{alias}}.Module.prototype.view + Read-only property which returns a WebAsssembly memory buffer as a DataView. + + Returns + ------- + view: DataView|null + WebAssembly memory view. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.view + + + +{{alias}}.Module.prototype.exports + Read-only property which returns "raw" WebAssembly module exports. + + Returns + ------- + out: Object|null + WebAssembly module exports. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.exports + {...} + + +{{alias}}.Module.prototype.initialize() + Asynchronously initializes a WebAssembly module instance. + + Returns + ------- + p: Promise + Promise which resolves upon initializing a WebAssembly module instance. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initialize(); + + +{{alias}}.Module.prototype.initializeAsync( clbk ) + Asynchronously initializes a WebAssembly module instance. + + Parameters + ---------- + clbk: Function + Callback to invoke upon initializing a WebAssembly module instance. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > function clbk() { console.log( 'done' ) }; + > mod.initializeAsync( clbk ); + + +{{alias}}.Module.prototype.initializeSync() + Synchronously initializes a WebAssembly module instance. + + In web browsers, JavaScript engines may raise an exception when attempting + to synchronously compile large WebAssembly binaries due to concerns about + blocking the main thread. Hence, to initialize WebAssembly modules having + large binaries (e.g., >4KiB), consider using asynchronous initialization + methods in browser contexts. + + Returns + ------- + mod: Module + Module wrapper instance. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + + +{{alias}}.Module.prototype.realloc( nbytes ) + Reallocates the underlying WebAssembly memory instance to a specified number + of bytes. + + WebAssembly memory can only *grow*, not shrink. Hence, if provided a number + of bytes which is less than or equal to the size of the current memory, the + function does nothing. + + When non-shared memory is resized, the underlying the `ArrayBuffer` is + detached, consequently invalidating any associated typed array views. Before + resizing non-shared memory, ensure that associated typed array views no + longer need byte access and can be garbage collected. + + Parameters + ---------- + nbytes: integer + Memory size (in bytes). + + Returns + ------- + bool: boolean + Boolean indicating whether the resize operation was successful. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.realloc( 100 ) + + + +{{alias}}.Module.prototype.hasCapacity( byteOffset, values ) + Returns a boolean indicating whether the underlying WebAssembly memory + instance has the capacity to store a provided list of values starting from a + specified byte offset. + + Parameters + ---------- + byteOffset: integer + Byte offset at which to start writing values. + + values: ArrayLikeObject + Input array containing values to write. + + Returns + ------- + bool: boolean + Boolean indicating whether the underlying WebAssembly memory instance + has enough capacity. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.realloc( 100 ); + > mod.hasCapacity( 0, [ 1, 2, 3, 4 ] ) + true + + +{{alias}}.Module.prototype.isView( values ) + Returns a boolean indicating whether a provided list of values is a view of + the underlying memory of the WebAssembly module. + + Parameters + ---------- + values: ArrayLikeObject + Input array. + + Returns + ------- + bool: boolean + Boolean indicating whether the list is a memory view. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.realloc( 100 ); + > mod.isView( [ 1, 2, 3, 4 ] ) + false + + +{{alias}}.Module.prototype.write( byteOffset, values ) + Writes values to the underlying WebAssembly memory instance. + + The function infers element size (i.e., number of bytes per element) from + the data type of the input array. For example, if provided a Float32Array, + the function writes each element as a single-precision floating-point number + to the underlying WebAssembly memory instance. + + In order to write elements as a different data type, you need to perform an + explicit cast *before* calling this method. For example, in order to write + single-precision floating-point numbers contained in a Float32Array as + signed 32-bit integers, you must first convert the Float32Array to an + Int32Array before passing the values to this method. + + If provided an array having an unknown or "generic" data type, elements are + written as double-precision floating-point numbers. + + Parameters + ---------- + byteOffset: integer + Byte offset at which to start writing values. + + values: ArrayLikeObject + Input array containing values to write. + + Returns + ------- + mod: Module + Module wrapper instance. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.realloc( 100 ); + > mod.write( 0, [ 1, 2, 3, 4 ] ); + + +{{alias}}.Module.prototype.read( byteOffset, out ) + Reads values from the underlying WebAssembly memory instance. + + The function infers element size (i.e., number of bytes per element) from + the data type of the output array. For example, if provided a Float32Array, + the function reads each element as a single-precision floating-point number + from the underlying WebAssembly memory instance. + + In order to read elements as a different data type, you need to perform an + explicit cast *after* calling this method. For example, in order to read + single-precision floating-point numbers contained in a Float32Array as + signed 32-bit integers, you must convert the Float32Array to an Int32Array + after reading memory values using this method. + + If provided an output array having an unknown or "generic" data type, + elements are read as double-precision floating-point numbers. + + Parameters + ---------- + byteOffset: integer + Byte offset at which to start reading values. + + out: ArrayLikeObject + Output array for storing read values. + + Returns + ------- + mod: Module + Module wrapper instance. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 0 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + > mod.realloc( 100 ); + > mod.write( 0, [ 1, 2, 3, 4 ] ); + > var out = [ 0, 0, 0, 0 ]; + > mod.read( 0, out ); + > out + [ 1, 2, 3, 4 ] + + +{{alias}}.Module.prototype.main( N, α, xp, sx ) + Multiples a vector `x` by a constant `α`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + α: number + Constant. + + xp: integer + Input array pointer (i.e., byte offset). + + sx: integer + Index increment for `x`. + + Returns + ------- + xp: integer + Input array pointer (i.e., byte offset). + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + + // Define "pointer" (i.e., byte offsets) into module memory: + > var xptr = 0; + + // Write data to module memory: + > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float32' ) ); + + // Perform computation: + > mod.main( 5, 5.0, xptr, 1 ); + + // Extract results from module memory: + > var view = {{alias:@stdlib/array/zeros}}( 5, 'float32' ); + > mod.read( xptr, view ); + > view + [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + + +{{alias}}.Module.prototype.ndarray( N, α, xp, sx, ox ) + Multiples a vector `x` by a constant `α` using alternative indexing + semantics. + + Parameters + ---------- + N: integer + Number of indexed elements. + + α: number + Constant. + + xp: integer + Input array pointer (i.e., byte offset). + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + Returns + ------- + ox: integer + Input array pointer (i.e., byte offset). + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + + // Define "pointer" (i.e., byte offsets) into module memory: + > var xptr = 0; + + // Write data to module memory: + > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float32' ) ); + + // Perform computation: + > mod.ndarray( 5, 5.0, xptr, 1, 0 ); + + // Extract results from module memory: + > var view = {{alias:@stdlib/array/zeros}}( 5, 'float32' ); + > mod.read( xptr, view ); + > view + [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts new file mode 100644 index 000000000000..c0b2abba5b76 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts @@ -0,0 +1,376 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { ModuleWrapper, Memory } from '@stdlib/types/wasm'; + +/** +* Interface defining a module constructor which is both "newable" and "callable". +*/ +interface ModuleConstructor { + /** + * Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory. + * + * @param mem - WebAssembly memory instance + * @returns module wrapper instance + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var ones = require( '@stdlib/array/ones' ); + * var zeros = require( '@stdlib/array/zeros' ); + * var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + * + * // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + * var mem = new Memory({ + * 'initial': 10, + * 'maximum': 100 + * }); + * + * // Create a BLAS routine: + * var mod = new sscal.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float32'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointer (i.e., byte offsets) for storing input vector: + * var xptr = 0; + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var ptr = mod.main( N, 5.0, xptr, 1 ); + * // returns + * + * var bool = ( ptr === xptr ); + * // returns true + * + * // Read out the results: + * var view = zeros( N, dtype ); + * mod.read( xptr, view ); + * // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + new( mem: Memory ): Module; // newable + + /** + * Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory. + * + * @param mem - WebAssembly memory instance + * @returns module wrapper instance + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var ones = require( '@stdlib/array/ones' ); + * var zeros = require( '@stdlib/array/zeros' ); + * var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + * + * // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + * var mem = new Memory({ + * 'initial': 10, + * 'maximum': 100 + * }); + * + * // Create a BLAS routine: + * var mod = sscal.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float32'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointer (i.e., byte offsets) for storing input vectors: + * var xptr = 0; + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var ptr = mod.main( N, 5.0, xptr, 1 ); + * // returns + * + * var bool = ( ptr === xptr ); + * // returns true + * + * // Read out the results: + * var view = zeros( N, dtype ); + * mod.read( xptr, view ); + * // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + ( mem: Memory ): Module; // callable +} + +/** +* Interface describing a `sscal` WebAssembly module. +*/ +interface Module extends ModuleWrapper { + /** + * Multiplies a vector `x` by a constant `alpha`. + * + * @param N - number of indexed elements + * @param alpha - constant + * @param xptr - input array pointer (i.e., byte offset) + * @param strideX - `x` stride length + * @returns input array pointer (i.e., byte offset) + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var ones = require( '@stdlib/array/ones' ); + * var zeros = require( '@stdlib/array/zeros' ); + * var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + * + * // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + * var mem = new Memory({ + * 'initial': 10, + * 'maximum': 100 + * }); + * + * // Create a BLAS routine: + * var mod = new sscal.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float32'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointer (i.e., byte offsets) for storing input vector: + * var xptr = 0; + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var ptr = mod.main( N, 5.0, xptr, 1 ); + * // returns + * + * var bool = ( ptr === xptr ); + * // returns true + * + * // Read out the results: + * var view = zeros( N, dtype ); + * mod.read( xptr, view ); + * // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + main( N: number, alpha: number, xptr: number, strideX: number ): number; + + /** + * Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param alpha - constant + * @param xptr - input array pointer (i.e., byte offset) + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @returns input array pointer (i.e., byte offset) + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var ones = require( '@stdlib/array/ones' ); + * var zeros = require( '@stdlib/array/zeros' ); + * var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + * + * // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + * var mem = new Memory({ + * 'initial': 10, + * 'maximum': 100 + * }); + * + * // Create a BLAS routine: + * var mod = new sscal.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float32'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointer (i.e., byte offsets) for storing input vector: + * var xptr = 0; + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var ptr = mod.ndarray( N, 5.0, xptr, 1, 0 ); + * // returns + * + * var bool = ( ptr === xptr ); + * // returns true + * + * // Read out the results: + * var view = zeros( N, dtype ); + * mod.read( xptr, view ); + * // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + ndarray( N: number, alpha: number, xptr: number, strideX: number, offsetX: number ): number; +} + +/** +* Interface describing `sscal`. +*/ +interface Routine extends ModuleWrapper { + /** + * Multiplies a vector `x` by a constant `alpha`. + * + * @param N - number of indexed elements + * @param alpha - constant + * @param x - input array + * @param strideX - `x` stride length + * @returns input array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + * + * sscal.main( x.length, 5.0, x, 1 ); + * // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + main( N: number, alpha: number, x: Float32Array, strideX: number ): Float32Array; + + /** + * Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param alpha - constant + * @param x - input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @returns input array + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + * + * sscal.ndarray( x.length, 5.0, x, 1, 0 ); + * // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + ndarray( N: number, alpha: number, x: Float32Array, strideX: number, offsetX: number ): Float32Array; + + /** + * Returns a new WebAssembly module wrapper instance which uses the provided WebAssembly memory instance as its underlying memory. + * + * @param mem - WebAssembly memory instance + * @returns module wrapper instance + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var ones = require( '@stdlib/array/ones' ); + * var zeros = require( '@stdlib/array/zeros' ); + * var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); + * + * // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + * var mem = new Memory({ + * 'initial': 10, + * 'maximum': 100 + * }); + * + * // Create a BLAS routine: + * var mod = new sscal.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float32'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var ptr = mod.main( N, 5.0, xptr, 1 ); + * // returns + * + * var bool = ( ptr === xptr ); + * // returns true + * + * // Read out the results: + * var view = zeros( N, dtype ); + * mod.read( xptr, view ); + * // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] + */ + Module: ModuleConstructor; +} + +/** +* Multiplies a vector `x` by a constant `alpha`. +* +* @param N - number of indexed elements +* @param alpha - constant +* @param x - input array +* @param strideX - `x` stride length +* @returns input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* sscal.main( x.length, 5.0, x, 1 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* sscal.ndarray( x.length, 5.0, x, 1, 0 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +declare var sscal: Routine; + + +// EXPORTS // + +export = sscal; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts new file mode 100644 index 000000000000..8826a22d7d4d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts @@ -0,0 +1,413 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable space-in-parens */ + +import Memory = require( '@stdlib/wasm/memory' ); +import sscal = require( './index' ); + + +// TESTS // + +// Attached to the main export is a `main` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + + sscal.main( x.length, 5.0, x, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the `main` method is provided a first argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.main( '10', 5.0, x, 1 ); // $ExpectError + sscal.main( true, 5.0, x, 1 ); // $ExpectError + sscal.main( false, 5.0, x, 1 ); // $ExpectError + sscal.main( null, 5.0, x, 1 ); // $ExpectError + sscal.main( undefined, 5.0, x, 1 ); // $ExpectError + sscal.main( [], 5.0, x, 1 ); // $ExpectError + sscal.main( {}, 5.0, x, 1 ); // $ExpectError + sscal.main( ( x: number ): number => x, 5.0, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a second argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.main( x.length, '10', x, 1 ); // $ExpectError + sscal.main( x.length, true, x, 1 ); // $ExpectError + sscal.main( x.length, false, x, 1 ); // $ExpectError + sscal.main( x.length, null, x, 1 ); // $ExpectError + sscal.main( x.length, undefined, x, 1 ); // $ExpectError + sscal.main( x.length, [], x, 1 ); // $ExpectError + sscal.main( x.length, {}, x, 1 ); // $ExpectError + sscal.main( x.length, ( x: number ): number => x, x, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a third argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + + sscal.main( x.length, 5.0, 10, 1 ); // $ExpectError + sscal.main( x.length, 5.0, '10', 1 ); // $ExpectError + sscal.main( x.length, 5.0, true, 1 ); // $ExpectError + sscal.main( x.length, 5.0, false, 1 ); // $ExpectError + sscal.main( x.length, 5.0, null, 1 ); // $ExpectError + sscal.main( x.length, 5.0, undefined, 1 ); // $ExpectError + sscal.main( x.length, 5.0, [], 1 ); // $ExpectError + sscal.main( x.length, 5.0, {}, 1 ); // $ExpectError + sscal.main( x.length, 5.0, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.main( x.length, 5.0, x, '10' ); // $ExpectError + sscal.main( x.length, 5.0, x, true ); // $ExpectError + sscal.main( x.length, 5.0, x, false ); // $ExpectError + sscal.main( x.length, 5.0, x, null ); // $ExpectError + sscal.main( x.length, 5.0, x, undefined ); // $ExpectError + sscal.main( x.length, 5.0, x, [] ); // $ExpectError + sscal.main( x.length, 5.0, x, {} ); // $ExpectError + sscal.main( x.length, 5.0, x, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + + sscal.main(); // $ExpectError + sscal.main( x.length ); // $ExpectError + sscal.main( x.length, 5.0 ); // $ExpectError + sscal.main( x.length, 5.0, x ); // $ExpectError + sscal.main( x.length, 5.0, x, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( x.length, 5.0, x, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( '10', 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( true, 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( false, 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( null, 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( undefined, 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( [], 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( {}, 5.0, x, 1, 0 ); // $ExpectError + sscal.ndarray( ( x: number ): number => x, 5.0, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( x.length, '10', x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, true, x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, false, x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, null, x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, undefined, x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, [], x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, {}, x, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, ( x: number ): number => x, x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( x.length, 5.0, 10, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, '10', 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, true, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, false, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, null, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, undefined, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, [], 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, {}, 1, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( x.length, 5.0, x, '10', 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, true, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, false, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, null, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, undefined, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, [], 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, {}, 0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray( x.length, 5.0, x, 1, '10' ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, true ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, false ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, null ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, undefined ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, [] ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, {} ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + + sscal.ndarray(); // $ExpectError + sscal.ndarray( x.length ); // $ExpectError + sscal.ndarray( x.length, 5.0 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1 ); // $ExpectError + sscal.ndarray( x.length, 5.0, x, 1, 0, 10 ); // $ExpectError +} + +// Attached to the main export is a `Module` constructor which returns a module... +{ + const mem = new Memory({ + 'initial': 0 + }); + + sscal.Module( mem ); // $ExpectType Module +} + +// The compiler throws an error if the `Module` constructor is not provided a WebAssembly memory instance... +{ + sscal.Module( '10' ); // $ExpectError + sscal.Module( true ); // $ExpectError + sscal.Module( false ); // $ExpectError + sscal.Module( null ); // $ExpectError + sscal.Module( undefined ); // $ExpectError + sscal.Module( [] ); // $ExpectError + sscal.Module( {} ); // $ExpectError + sscal.Module( ( x: number ): number => x ); // $ExpectError +} + +// The `Module` constructor returns a module instance having a `main` method which returns a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main( 10, 5.0, 0, 1 ); // $ExpectType number +} + +// The compiler throws an error if the `main` method of a module instance is provided a first argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main( '10', 5.0, 10, 1 ); // $ExpectError + mod.main( true, 5.0, 10, 1 ); // $ExpectError + mod.main( false, 5.0, 10, 1 ); // $ExpectError + mod.main( null, 5.0, 10, 1 ); // $ExpectError + mod.main( undefined, 5.0, 10, 1 ); // $ExpectError + mod.main( [], 5.0, 10, 1 ); // $ExpectError + mod.main( {}, 5.0, 10, 1 ); // $ExpectError + mod.main( ( x: number ): number => x, 5.0, 10, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a second argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main( 10, '10', 0, 1 ); // $ExpectError + mod.main( 10, true, 0, 1 ); // $ExpectError + mod.main( 10, false, 0, 1 ); // $ExpectError + mod.main( 10, null, 0, 1 ); // $ExpectError + mod.main( 10, undefined, 0, 1 ); // $ExpectError + mod.main( 10, [], 0, 1 ); // $ExpectError + mod.main( 10, {}, 0, 1 ); // $ExpectError + mod.main( 10, ( x: number ): number => x, 0, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a third argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main( 10, 5.0, '10', 1 ); // $ExpectError + mod.main( 10, 5.0, true, 1 ); // $ExpectError + mod.main( 10, 5.0, false, 1 ); // $ExpectError + mod.main( 10, 5.0, null, 1 ); // $ExpectError + mod.main( 10, 5.0, undefined, 1 ); // $ExpectError + mod.main( 10, 5.0, [], 1 ); // $ExpectError + mod.main( 10, 5.0, {}, 1 ); // $ExpectError + mod.main( 10, 5.0, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a fourth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main( 10, 5.0, 0, '10' ); // $ExpectError + mod.main( 10, 5.0, 0, true ); // $ExpectError + mod.main( 10, 5.0, 0, false ); // $ExpectError + mod.main( 10, 5.0, 0, null ); // $ExpectError + mod.main( 10, 5.0, 0, undefined ); // $ExpectError + mod.main( 10, 5.0, 0, [] ); // $ExpectError + mod.main( 10, 5.0, 0, {} ); // $ExpectError + mod.main( 10, 5.0, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided an unsupported number of arguments... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.main(); // $ExpectError + mod.main( 10 ); // $ExpectError + mod.main( 10, 5.0 ); // $ExpectError + mod.main( 10, 5.0, 0 ); // $ExpectError + mod.main( 10, 5.0, 0, 1, 10 ); // $ExpectError +} + +// The `Module` constructor returns a module instance having an `ndarray` method which returns a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( 10, 5.0, 0, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a first argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( '10', 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( true, 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( false, 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( null, 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( undefined, 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( [], 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( {}, 5.0, 0, 1, 0 ); // $ExpectError + mod.ndarray( ( x: number ): number => x, 5.0, 0, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a second argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( 10, '10', 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, true, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, false, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, null, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, undefined, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, [], 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, {}, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, ( x: number ): number => x, 0, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a third argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( 10, 5.0, '10', 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, true, 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, false, 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, null, 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, undefined, 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, [], 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, {}, 1, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a fourth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( 10, 5.0, 0, '10', 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, true, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, false, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, null, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, undefined, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, [], 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, {}, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a fifth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray( 10, 5.0, 0, 1, '10' ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, true ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, false ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, null ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, undefined ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, [] ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, {} ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided an unsupported number of arguments... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = sscal.Module( mem ); + + mod.ndarray(); // $ExpectError + mod.ndarray( 10 ); // $ExpectError + mod.ndarray( 10, 5.0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1 ); // $ExpectError + mod.ndarray( 10, 5.0, 0, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js new file mode 100644 index 000000000000..7bec4764eb5f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js @@ -0,0 +1,44 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var oneTo = require( '@stdlib/array/one-to' ); +var sscal = require( './../lib' ); + +function main() { + if ( !hasWebAssemblySupport() ) { + console.error( 'Environment does not support WebAssembly.' ); + return; + } + // Specify a vector length: + var N = 5; + + // Create input array: + var x = oneTo( N, 'float32' ); + + // Perform computation: + sscal.ndarray( N, 5.0, x, 1, 0 ); + + // Print the results: + console.log( x ); + // => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js new file mode 100644 index 000000000000..ea3dee32693e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); +var Float32ArrayLE = require( '@stdlib/array/little-endian-float32' ); +var sscal = require( './../lib' ); + +function main() { + if ( !hasWebAssemblySupport() ) { + console.error( 'Environment does not support WebAssembly.' ); + return; + } + // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + var mem = new Memory({ + 'initial': 10, + 'maximum': 100 + }); + + // Create a BLAS routine: + var mod = new sscal.Module( mem ); + // returns + + // Initialize the routine: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Specify a vector length: + var N = 5; + + // Define pointer (i.e., byte offsets) for storing input vector: + var xptr = 0; + + // Create a typed array view over module memory: + var x = new Float32ArrayLE( mod.memory.buffer, xptr, N ); + + // Write values to module memory: + gfillBy( N, x, 1, discreteUniform( -10.0, 10.0 ) ); + + // Perform computation: + mod.ndarray( N, 5.0, xptr, 1, 0 ); + + // Print the result: + console.log( 'x[:] = [%s]', x.toString() ); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js new file mode 100644 index 000000000000..258641b69428 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var zeros = require( '@stdlib/array/zeros' ); +var sscal = require( './../lib' ); + +function main() { + if ( !hasWebAssemblySupport() ) { + console.error( 'Environment does not support WebAssembly.' ); + return; + } + // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): + var mem = new Memory({ + 'initial': 10, + 'maximum': 100 + }); + + // Create a BLAS routine: + var mod = new sscal.Module( mem ); + // returns + + // Initialize the routine: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Define a vector data type: + var dtype = 'float32'; + + // Specify a vector length: + var N = 5; + + // Define pointer (i.e., byte offsets) for storing input vector: + var xptr = 0; + + // Write vector values to module memory: + mod.write( xptr, oneTo( N, dtype ) ); + + // Perform computation: + mod.ndarray( N, 5.0, xptr, 1, 0 ); + + // Read out the results: + var view = zeros( N, dtype ); + mod.read( xptr, view ); + + console.log( view ); + // => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js new file mode 100644 index 000000000000..72b4e984485c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base64ToUint8Array = require( '@stdlib/string/base/base64-to-uint8array' ); + + +// MAIN // + +var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAETA2AAAGAEf31/fwBgBX99f39/AAIPAQNlbnYGbWVtb3J5AgAAAwQDAAECB0wEEV9fd2FzbV9jYWxsX2N0b3JzAAAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAHY19zc2NhbAABD2Nfc3NjYWxfbmRhcnJheQACCpsCAwMAAQscACAAIAEgAiADQQEgAGsgA2xBACADQQBMGxACC/cBAQJ/AkAgAEEATCABQwAAgD9bcg0AIANBAUcEQANAIAAgBUYNAiACIARBAnRqIgYgASAGKgIAlDgCACAFQQFqIQUgAyAEaiEEDAALAAsCQCAAQQVwIgZFDQADQCAFIAZGDQEgAiAEQQJ0aiIDIAEgAyoCAJQ4AgAgBUEBaiEFIARBAWohBAwACwALIABBBUgNAANAIAAgBkwNASACIARBAnRqIgMgASADKgIAlDgCACADIAEgAyoCBJQ4AgQgAyABIAMqAgiUOAIIIAMgASADKgIMlDgCDCADIAEgAyoCEJQ4AhAgBkEFaiEGIARBBWohBAwACwALCw==' ); + + +// EXPORTS // + +module.exports = wasm; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js new file mode 100644 index 000000000000..6f02393f96e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var readWASM = require( '@stdlib/fs/read-wasm' ).sync; + + +// MAIN // + +var wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) ); + + +// EXPORTS // + +module.exports = wasm; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js new file mode 100644 index 000000000000..7d6d313627a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js @@ -0,0 +1,108 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* WebAssembly routine to multiply a vector `x` by a constant `alpha`. +* +* @module @stdlib/blas/base/wasm/sscal +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sscal = require( '@stdlib/blas/base/wasm/sscal' ); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.main( x.length, 5.0, x, 1 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sscal = require( '@stdlib/blas/base/wasm/sscal' ); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.ndarray( x.length, 5.0, x, 1, 0 ); +* // y => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var ones = require( '@stdlib/array/ones' ); +* var zeros = require( '@stdlib/array/zeros' ); +* var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +* var sscal = require( '@stdlib/blas/base/wasm/sscal' ); +* +* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +* var mem = new Memory({ +* 'initial': 10, +* 'maximum': 100 +* }); +* +* // Create a BLAS routine: +* var mod = new sscal.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float32'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointer (i.e., byte offsets) for storing input vectors: +* var xptr = 0; +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* mod.main( N, 5.0, xptr, 1 ); +* +* // Read out the results: +* var view = zeros( N, dtype ); +* mod.read( xptr, view ); +* +* console.log( view ); +* // => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var Module = require( './module.js' ); + + +// MAIN // + +setReadOnly( main, 'Module', Module ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "Module": "main.Module" } diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js new file mode 100644 index 000000000000..5fbd81bb096f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Routine = require( './routine.js' ); + + +// MAIN // + +/** +* WebAssembly module to multiply a vector `x` by a constant `alpha`. +* +* @name sscal +* @type {Routine} +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.main( x.length, 5.0, x, 1 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.ndarray( x.length, 5.0, x, 1, 0 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +var sscal = new Routine(); +sscal.initializeSync(); // eslint-disable-line node/no-sync + + +// EXPORTS // + +module.exports = sscal; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js new file mode 100644 index 000000000000..f4d38f59006a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js @@ -0,0 +1,235 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var isWebAssemblyMemory = require( '@stdlib/assert/is-wasm-memory' ); +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var inherits = require( '@stdlib/utils/inherit' ); +var WasmModule = require( '@stdlib/wasm/module-wrapper' ); +var format = require( '@stdlib/string/format' ); +var wasmBinary = require( './binary.js' ); + + +// MAIN // + +/** +* BLAS routine WebAssembly module wrapper constructor. +* +* @constructor +* @param {Object} memory - WebAssembly memory instance +* @throws {TypeError} must provide a WebAssembly memory instance +* @returns {Module} module instance +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var ones = require( '@stdlib/array/ones' ); +* var zeros = require( '@stdlib/array/zeros' ); +* var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +* +* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +* var mem = new Memory({ +* 'initial': 10, +* 'maximum': 100 +* }); +* +* // Create a BLAS routine: +* var sscal = new Module( mem ); +* // returns +* +* // Initialize the routine: +* sscal.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float32'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointer (i.e., byte offsets) for storing input vector: +* var xptr = 0; +* +* // Write vector values to module memory: +* sscal.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var ptr = sscal.main( N, 5.0, xptr, 1 ); +* // returns +* +* var bool = ( ptr === xptr ); +* // returns true +* +* // Read out the results: +* var view = zeros( N, dtype ); +* sscal.read( xptr, view ); +* // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +function Module( memory ) { + if ( !( this instanceof Module ) ) { + return new Module( memory ); + } + if ( !isWebAssemblyMemory( memory ) ) { + throw new TypeError( format( 'invalid argument. Must provide a WebAssembly memory instance. Value: `%s`.', memory ) ); + } + // Call the parent constructor: + WasmModule.call( this, wasmBinary, memory, { + 'env': { + 'memory': memory + } + }); + + return this; +} + +// Inherit from the parent constructor: +inherits( Module, WasmModule ); + +/** +* Multiplies a vector `x` by a constant `alpha`. +* +* @name main +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - scalar +* @param {NonNegativeInteger} xptr - input array pointer (i.e., byte offset) +* @param {integer} strideX - `x` stride length +* @returns {NonNegativeInteger} input array pointer (i.e., byte offset) +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var ones = require( '@stdlib/array/ones' ); +* var zeros = require( '@stdlib/array/zeros' ); +* var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +* +* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +* var mem = new Memory({ +* 'initial': 10, +* 'maximum': 100 +* }); +* +* // Create a BLAS routine: +* var sscal = new Module( mem ); +* // returns +* +* // Initialize the routine: +* sscal.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float32'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointer (i.e., byte offsets) for storing input vector: +* var xptr = 0; +* +* // Write vector values to module memory: +* sscal.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var ptr = sscal.main( N, 5.0, xptr, 1 ); +* // returns +* +* var bool = ( ptr === xptr ); +* // returns true +* +* // Read out the results: +* var view = zeros( N, dtype ); +* sscal.read( xptr, view ); +* // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +setReadOnly( Module.prototype, 'main', function sscal( N, alpha, xptr, strideX ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point + this._instance.exports.c_sscal( N, alpha, xptr, strideX ); + return xptr; +}); + +/** +* Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics. +* +* @name ndarray +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - scalar +* @param {NonNegativeInteger} xptr - input array pointer (i.e., byte offset) +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @returns {NonNegativeInteger} input array pointer (i.e., byte offset) +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var ones = require( '@stdlib/array/ones' ); +* var zeros = require( '@stdlib/array/zeros' ); +* var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +* +* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB): +* var mem = new Memory({ +* 'initial': 10, +* 'maximum': 100 +* }); +* +* // Create a BLAS routine: +* var sscal = new Module( mem ); +* // returns +* +* // Initialize the routine: +* sscal.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float32'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointer (i.e., byte offsets) for storing input vectors: +* var xptr = 0; +* +* // Write vector values to module memory: +* sscal.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var ptr = sscal.ndarray( N, 5.0, xptr, 1, 0 ); +* // returns +* +* var bool = ( ptr === xptr ); +* // returns true +* +* // Read out the results: +* var view = zeros( N, dtype ); +* sscal.read( xptr, view ); +* // view => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +setReadOnly( Module.prototype, 'ndarray', function sscal( N, alpha, xptr, strideX, offsetX ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point + this._instance.exports.c_sscal_ndarray( N, alpha, xptr, strideX, offsetX ); + return xptr; +}); + + +// EXPORTS // + +module.exports = Module; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js new file mode 100644 index 000000000000..5edf41a636fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js @@ -0,0 +1,175 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-restricted-syntax, no-invalid-this */ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var inherits = require( '@stdlib/utils/inherit' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var readDataView = require( '@stdlib/strided/base/read-dataview' ).ndarray; +var Memory = require( '@stdlib/wasm/memory' ); +var arrays2ptrs = require( '@stdlib/wasm/base/arrays2ptrs' ); +var strided2object = require( '@stdlib/wasm/base/strided2object' ); +var Module = require( './module.js' ); + + +// MAIN // + +/** +* Routine constructor. +* +* @private +* @constructor +* @returns {Routine} routine instance +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Create a new routine: +* var sscal = new Routine(); +* +* // Initialize the module: +* sscal.initializeSync(); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.main( x.length, 5.0, x, 1 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Create a new routine: +* var sscal = new Routine(); +* +* // Initialize the module: +* sscal.initializeSync(); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.ndarray( x.length, 5.0, x, 1, 0 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +function Routine() { + if ( !( this instanceof Routine ) ) { + return new Routine(); + } + Module.call( this, new Memory({ + 'initial': 0 + })); + return this; +} + +// Inherit from the parent constructor: +inherits( Routine, Module ); + +/** +* Multiplies a vector `x` by a constant `alpha`. +* +* @name main +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - scalar +* @param {Float32Array} x - input array +* @param {integer} strideX - `x` stride length +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Create a new routine: +* var sscal = new Routine(); +* +* // Initialize the module: +* sscal.initializeSync(); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.main( x.length, 5.0, x, 1 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +setReadOnly( Routine.prototype, 'main', function sscal( N, alpha, x, strideX ) { + return this.ndarray( N, alpha, x, strideX, stride2offset( N, strideX ) ); +}); + +/** +* Multiplies a vector `x` by a constant `alpha` using alternative indexing semantics. +* +* @name ndarray +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {number} alpha - scalar +* @param {Float32Array} x - input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @returns {Float32Array} input array +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* // Create a new routine: +* var sscal = new Routine(); +* +* // Initialize the module: +* sscal.initializeSync(); +* +* // Define a strided array: +* var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* +* // Perform operation: +* sscal.ndarray( x.length, 5.0, x, 1, 0 ); +* // x => [ 5.0, 10.0, 15.0, 20.0, 25.0 ] +*/ +setReadOnly( Routine.prototype, 'ndarray', function sscal( N, alpha, x, strideX, offsetX ) { + var ptrs; + var p0; + + // Convert the input arrays to "pointers" in the module's memory: + ptrs = arrays2ptrs( this, [ + strided2object( N, x, strideX, offsetX ) + ]); + p0 = ptrs[0]; + + // Perform computation by calling the corresponding parent method: + Module.prototype.ndarray.call( this, N, alpha, p0.ptr, p0.stride, p0.offset ); // eslint-disable-line max-len + + // If the input array data had to be copied to module memory, copy the results to the provided input array... + if ( p0.copy ) { + readDataView( N, this.view, p0.stride*p0.BYTES_PER_ELEMENT, p0.ptr, x, strideX, offsetX, true ); // eslint-disable-line max-len + } + return x; +}); + + +// EXPORTS // + +module.exports = Routine; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/manifest.json b/lib/node_modules/@stdlib/blas/base/wasm/sscal/manifest.json new file mode 100644 index 000000000000..3314b7a22d63 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/sscal" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/package.json b/lib/node_modules/@stdlib/blas/base/wasm/sscal/package.json new file mode 100644 index 000000000000..d0d2253736a0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/package.json @@ -0,0 +1,80 @@ +{ + "name": "@stdlib/blas/base/wasm/sscal", + "version": "0.0.0", + "description": "Multiply a vector `x` by a scalar `alpha`.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": { + "./lib/binary.js": "./lib/binary.browser.js" + }, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "scripts": "./scripts", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 1", + "sscal", + "linear", + "algebra", + "subroutines", + "alpha", + "vector", + "array", + "ndarray", + "float32", + "float", + "float32array", + "webassembly", + "wasm" + ], + "__stdlib__": { + "wasm": true + } +} diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js new file mode 100644 index 000000000000..348354d7029c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js @@ -0,0 +1,63 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var readFile = require( '@stdlib/fs/read-file' ).sync; +var writeFile = require( '@stdlib/fs/write-file' ).sync; +var replace = require( '@stdlib/string/replace' ); + + +// VARIABLES // + +var wpath = resolve( __dirname, '..', 'src', 'main.wasm' ); +var tpath = resolve( __dirname, 'template.txt' ); +var opath = resolve( __dirname, '..', 'lib', 'binary.browser.js' ); + +var opts = { + 'encoding': 'utf8' +}; + +var PLACEHOLDER = '{{WASM_BASE64}}'; + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var wasm; + var tmpl; + + wasm = readFile( wpath ); + tmpl = readFile( tpath, opts ); + + tmpl = replace( tmpl, PLACEHOLDER, wasm.toString( 'base64' ) ); + + writeFile( opath, tmpl, opts ); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt new file mode 100644 index 000000000000..12996dd89e3b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var base64ToUint8Array = require( '@stdlib/string/base/base64-to-uint8array' ); + + +// MAIN // + +var wasm = base64ToUint8Array( '{{WASM_BASE64}}' ); + + +// EXPORTS // + +module.exports = wasm; diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile new file mode 100644 index 000000000000..eb51121eec4c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile @@ -0,0 +1,243 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +#/ +# To compile targets listed in this Makefile, use top-level project `make` +# commands rather than commands listed in this Makefile. The top-level project +# `make` commands will ensure that various environment variables and flags are +# appropriately set. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files to WebAssembly: +ifdef EMCC_COMPILER + EMCC := $(EMCC_COMPILER) +else + EMCC := emcc +endif + +# Define the program used for compiling WebAssembly files to the WebAssembly text format: +ifdef WASM2WAT + WASM_TO_WAT := $(WASM2WAT) +else + WASM_TO_WAT := wasm2wat +endif + +# Define the program used for compiling WebAssembly files to JavaScript: +ifdef WASM2JS + WASM_TO_JS := $(WASM2JS) +else + WASM_TO_JS := wasm2js +endif + +# Define the path to the Node.js executable: +ifdef NODE + NODEJS := $(NODE) +else + NODEJS := node +endif + +# Define the integer size: +ifdef CBLAS_INT + INT_TYPE := $(CBLAS_INT) +else + INT_TYPE := int32_t +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -flto \ + -Wall \ + -pedantic \ + -D CBLAS_INT=$(INT_TYPE) + +# Define the command-line options when compiling C files to WebAssembly and asm.js: +EMCCFLAGS ?= $(CFLAGS) + +# Define shared `emcc` flags: +EMCC_SHARED_FLAGS := \ + -Oz \ + -fwasm-exceptions \ + -s SUPPORT_LONGJMP=1 \ + -s SIDE_MODULE=2 \ + -s EXPORTED_FUNCTIONS="$(shell cat exports.json | tr -d ' \t\n' | sed s/\"/\'/g)" + +# Define WebAssembly `emcc` flags: +EMCC_WASM_FLAGS := $(EMCC_SHARED_FLAGS) \ + -s WASM=1 \ + -s WASM_BIGINT=0 + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of WebAssembly targets: +wasm_targets := main.wasm + +# List of WebAssembly WAT targets: +wat_targets := main.wat + +# List of WebAssembly JavaScript targets: +wasm_js_targets := main.wasm.js + +# List of other JavaScript targets: +browser_js_targets := ./../lib/binary.browser.js + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [EMCC_COMPILER] - EMCC compiler (e.g., `emcc`) +# @param {string} [EMCCFLAGS] - EMCC compiler options +# @param {string} [WASM2WAT] - WebAssembly text format compiler (e.g., `wasm2wat`) +# @param {string} [WASM2JS] - WebAssembly JavaScript compiler (e.g., `wasm2js`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: wasm + +.PHONY: all + +#/ +# Compiles source files to WebAssembly. +# +# @param {string} [EMCC_COMPILER] - EMCC compiler (e.g., `emcc`) +# @param {string} [EMCCFLAGS] - EMCC compiler options +# @param {string} [WASM2WAT] - WebAssembly text format compiler (e.g., `wasm2wat`) +# @param {string} [WASM2JS] - WebAssembly JavaScript compiler (e.g., `wasm2js`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make wasm +#/ +wasm: $(wasm_targets) $(wat_targets) $(browser_js_targets) + +.PHONY: wasm + +#/ +# Compiles C source files to WebAssembly binaries. +# +# @private +# @param {string} EMCC - EMCC compiler (e.g., `emcc`) +# @param {string} EMCCFLAGS - EMCC compiler options +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(wasm_targets): + $(QUIET) $(EMCC) $(EMCCFLAGS) $(EMCC_WASM_FLAGS) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) $(LIBRARIES) + +#/ +# Compiles WebAssembly binary files to the WebAssembly text format. +# +# @private +# @param {string} WASM2WAT - WAT compiler (e.g., `wasm2wat`) +#/ +$(wat_targets): %.wat: %.wasm + $(QUIET) $(WASM_TO_WAT) -o $@ $(wasm_targets) + +#/ +# Compiles WebAssembly binary files to JavaScript. +# +# @private +# @param {string} WASM2JS - JavaScript compiler (e.g., `wasm2js`) +#/ +$(wasm_js_targets): %.wasm.js: %.wasm + $(QUIET) $(WASM_TO_JS) -o $@ $(wasm_targets) + +#/ +# Generates an inline WebAssembly build for use in bundlers. +# +# @private +# @param {string} NODE - Node.js executable +#/ +$(browser_js_targets): $(wasm_targets) + $(QUIET) $(NODEJS) ./../scripts/build.js + +#/ +# Removes generated WebAssembly files. +# +# @example +# make clean-wasm +#/ +clean-wasm: + $(QUIET) -rm -f *.wasm *.wat *.wasm.js $(browser_js_targets) + +.PHONY: clean-wasm + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-wasm + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/exports.json b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/exports.json new file mode 100644 index 000000000000..4094366228c0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/exports.json @@ -0,0 +1,4 @@ +[ + "_c_sscal", + "_c_sscal_ndarray" +] diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wasm b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wasm new file mode 100755 index 0000000000000000000000000000000000000000..ba4544d724bf40bfb5425c23996fe734d89d18ac GIT binary patch literal 433 zcmZ{eyH3ME5Jm6oD-n*BAQ~hnCMhWpB^|L)0!99SV!d)w;5ZN25y%BHA3?{5(lXAY zL1LSkJ9p2WL8w*)dHwFZE?(Em+dDF?rVE_{scAl%2B~dJ1Jx(JSiiZ|Vznu21!$u| zsxvd^-oHzf&q7i7Y_};Z;PN;N+ig+%dDsPCE{aViRwwgSC4WKvW9QfNP?n*FI{Q{y zQlo1ym{_q+h_Pf{B#<7ntAUDsh*YD-4AD%Fz~{qD8Mi(?nXwjw?KD Date: Sat, 15 Feb 2025 13:06:55 +0000 Subject: [PATCH 2/4] chore: update copyright years --- lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md | 2 +- .../@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js | 2 +- .../@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js | 2 +- .../blas/base/wasm/sscal/benchmark/benchmark.module.main.js | 2 +- .../blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js | 2 +- .../@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts | 2 +- .../@stdlib/blas/base/wasm/sscal/docs/types/test.ts | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js | 2 +- .../blas/base/wasm/sscal/examples/little_endian_arrays.js | 2 +- .../@stdlib/blas/base/wasm/sscal/examples/module.js | 2 +- .../@stdlib/blas/base/wasm/sscal/lib/binary.browser.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js | 2 +- .../@stdlib/blas/base/wasm/sscal/scripts/template.txt | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js | 2 +- lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js | 2 +- .../@stdlib/blas/base/wasm/sscal/test/test.module.js | 2 +- .../@stdlib/blas/base/wasm/sscal/test/test.module.main.js | 2 +- .../@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js | 2 +- .../@stdlib/blas/base/wasm/sscal/test/test.ndarray.js | 2 +- .../@stdlib/blas/base/wasm/sscal/test/test.routine.js | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md index d60be003bafa..24801e5626ef 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js index 73e9a5839b09..098d14aa5c21 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js index 89ab57e10ea7..0b70c4b291c5 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js index 5dcf64347dec..aac35a492f78 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js index d9752bf8f32b..3e58f0820ac6 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js index ca594864aa08..790527a5b120 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts index c0b2abba5b76..72611eaf9322 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts index 8826a22d7d4d..77033ad02c39 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js index 7bec4764eb5f..fe105072cc87 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js index ea3dee32693e..f97a6a787f14 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js index 258641b69428..01579af92f76 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js index 72b4e984485c..96ec3a5366c8 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.browser.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js index 6f02393f96e5..2b83fe651780 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/binary.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js index 7d6d313627a8..bcb0aefcea9c 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js index 5fbd81bb096f..ff0806b6f5e5 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js index f4d38f59006a..e9a3c76da320 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js index 5edf41a636fe..a57bab451369 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js index 348354d7029c..9a7b4afb94bd 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/build.js @@ -3,7 +3,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt index 12996dd89e3b..554d4b2abe02 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/scripts/template.txt @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile index eb51121eec4c..1b1f35347760 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat index 2f4a18ee82de..1bedba72fe89 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/src/main.wat @@ -1,6 +1,6 @@ ;; @license Apache-2.0 ;; -;; Copyright (c) 2024 The Stdlib Authors. +;; Copyright (c) 2025 The Stdlib Authors. ;; ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js index 2b783edeaf18..45cf9b1d6753 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js index 26b0db4ad419..7a4278147dfe 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.js index 9adcb07e22fa..0cdcd97ef151 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.main.js index 3286188ab309..dcf674435a97 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.main.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js index 858a76f8f469..8171c4485a6f 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.module.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.ndarray.js index e30ab9b4d383..1b8584faf3ae 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.routine.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.routine.js index 56a4b67daaf0..d90a5804a8e1 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.routine.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/test/test.routine.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 40323a0e0a2bcbecc7be1f2996b9289cd51ff95a Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 15 Feb 2025 20:34:33 -0800 Subject: [PATCH 3/4] Apply suggestions from code review Signed-off-by: Athan --- .../@stdlib/blas/base/wasm/sscal/README.md | 4 ++-- .../base/wasm/sscal/benchmark/benchmark.module.main.js | 4 ++-- .../wasm/sscal/benchmark/benchmark.module.ndarray.js | 4 ++-- .../@stdlib/blas/base/wasm/sscal/docs/repl.txt | 6 +++--- .../@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts | 10 +++++----- .../@stdlib/blas/base/wasm/sscal/examples/index.js | 2 +- .../base/wasm/sscal/examples/little_endian_arrays.js | 2 +- .../@stdlib/blas/base/wasm/sscal/examples/module.js | 2 +- .../@stdlib/blas/base/wasm/sscal/lib/index.js | 2 +- .../@stdlib/blas/base/wasm/sscal/lib/module.js | 4 ++-- .../@stdlib/blas/base/wasm/sscal/lib/routine.js | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md index 24801e5626ef..d85204a3f4b5 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/README.md @@ -165,7 +165,7 @@ var dtype = 'float32'; // Specify a vector length: var N = 5; -// Define pointer (i.e., byte offsets) for storing input vector: +// Define a pointer (i.e., byte offset) for storing an input vector: var xptr = 0; // Write vector values to module memory: @@ -221,7 +221,7 @@ var dtype = 'float32'; // Specify a vector length: var N = 5; -// Define pointer (i.e., byte offsets) for storing input vector: +// Define a pointer (i.e., byte offset) for storing an input vector: var xptr = 0; // Write vector values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js index aac35a492f78..a3271329f31b 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.main.js @@ -77,11 +77,11 @@ function createBenchmark( len ) { // Initialize the module: mod.initializeSync(); // eslint-disable-line node/no-sync - // Reallocate the underlying memory to allow storing two vectors: + // Reallocate the underlying memory to allow storing one vector: nb = bytesPerElement( options.dtype ); mod.realloc( len*nb ); - // Define pointer (i.e., byte offsets) to the vector elements: + // Define a pointer (i.e., byte offset) to the first vector element: xptr = 0; // Write random values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js index 3e58f0820ac6..4e919fb41dd0 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/benchmark/benchmark.module.ndarray.js @@ -77,11 +77,11 @@ function createBenchmark( len ) { // Initialize the module: mod.initializeSync(); // eslint-disable-line node/no-sync - // Reallocate the underlying memory to allow storing two vectors: + // Reallocate the underlying memory to allow storing one vector: nb = bytesPerElement( options.dtype ); mod.realloc( len*nb ); - // Define pointers (i.e., byte offsets) to the first vector elements: + // Define a pointer (i.e., byte offset) to the first vector element: xptr = 0; // Write random values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt index 4468bb96ff79..529bae4d1a93 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/repl.txt @@ -2,7 +2,7 @@ {{alias}}.main( N, alpha, x, strideX ) Multiplies a vector `x` by a constant `alpha`. - The `N` and stride parameters determine which elements in the strided arrays + The `N` and stride parameters determine which elements in the strided array are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed @@ -55,8 +55,8 @@ semantics. While typed array views mandate a view offset based on the underlying - buffer, the offset parameters support indexing semantics based on starting - indices. + buffer, the offset parameter supports indexing semantics based on a starting + index. Parameters ---------- diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts index 72611eaf9322..1aee5b83bee8 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/docs/types/index.d.ts @@ -58,7 +58,7 @@ interface ModuleConstructor { * // Specify a vector length: * var N = 5; * - * // Define pointer (i.e., byte offsets) for storing input vector: + * // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: @@ -110,7 +110,7 @@ interface ModuleConstructor { * // Specify a vector length: * var N = 5; * - * // Define pointer (i.e., byte offsets) for storing input vectors: + * // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: @@ -170,7 +170,7 @@ interface Module extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointer (i.e., byte offsets) for storing input vector: + * // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: @@ -226,7 +226,7 @@ interface Module extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointer (i.e., byte offsets) for storing input vector: + * // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: @@ -322,7 +322,7 @@ interface Routine extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js index fe105072cc87..adcd21a2ce3c 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/index.js @@ -30,7 +30,7 @@ function main() { // Specify a vector length: var N = 5; - // Create input array: + // Create an input array: var x = oneTo( N, 'float32' ); // Perform computation: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js index f97a6a787f14..4d1314688dbf 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/little_endian_arrays.js @@ -46,7 +46,7 @@ function main() { // Specify a vector length: var N = 5; - // Define pointer (i.e., byte offsets) for storing input vector: + // Define a pointer (i.e., byte offset) for storing an input vector: var xptr = 0; // Create a typed array view over module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js index 01579af92f76..02e55b61add1 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/examples/module.js @@ -48,7 +48,7 @@ function main() { // Specify a vector length: var N = 5; - // Define pointer (i.e., byte offsets) for storing input vector: + // Define a pointer (i.e., byte offset) for storing an input vector: var xptr = 0; // Write vector values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js index bcb0aefcea9c..4aa43b8161ec 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/index.js @@ -72,7 +72,7 @@ * // Specify a vector length: * var N = 5; * -* // Define pointer (i.e., byte offsets) for storing input vectors: +* // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js index e9a3c76da320..f994aa58fb7f 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js @@ -143,7 +143,7 @@ inherits( Module, WasmModule ); * // Specify a vector length: * var N = 5; * -* // Define pointer (i.e., byte offsets) for storing input vector: +* // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: @@ -206,7 +206,7 @@ setReadOnly( Module.prototype, 'main', function sscal( N, alpha, xptr, strideX ) * // Specify a vector length: * var N = 5; * -* // Define pointer (i.e., byte offsets) for storing input vectors: +* // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js index a57bab451369..d4477f007df4 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/routine.js @@ -153,7 +153,7 @@ setReadOnly( Routine.prototype, 'ndarray', function sscal( N, alpha, x, strideX, var ptrs; var p0; - // Convert the input arrays to "pointers" in the module's memory: + // Convert the input array to a "pointer" in the module's memory: ptrs = arrays2ptrs( this, [ strided2object( N, x, strideX, offsetX ) ]); From 02217970b64a57ab06b1ccf94a96f1c3f68cc2a4 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 15 Feb 2025 20:38:01 -0800 Subject: [PATCH 4/4] docs: update description Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js index f994aa58fb7f..52af4cbb8783 100644 --- a/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js +++ b/lib/node_modules/@stdlib/blas/base/wasm/sscal/lib/module.js @@ -66,7 +66,7 @@ var wasmBinary = require( './binary.js' ); * // Specify a vector length: * var N = 5; * -* // Define pointer (i.e., byte offsets) for storing input vector: +* // Define a pointer (i.e., byte offset) for storing an input vector: * var xptr = 0; * * // Write vector values to module memory: