From f63b8ce25b7af4ba98e27e1d7ed164fed61dae10 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 21 Oct 2024 11:23:23 +0530 Subject: [PATCH 1/5] feat: add wasm support for drotm --- .../@stdlib/blas/base/drotm-wasm/README.md | 363 ++++++++ .../base/drotm-wasm/benchmark/benchmark.js | 108 +++ .../drotm-wasm/benchmark/benchmark.module.js | 66 ++ .../benchmark/benchmark.module.main.js | 142 +++ .../benchmark/benchmark.module.ndarray.js | 142 +++ .../drotm-wasm/benchmark/benchmark.ndarray.js | 108 +++ .../blas/base/drotm-wasm/docs/repl.txt | 591 +++++++++++++ .../base/drotm-wasm/docs/types/index.d.ts | 435 ++++++++++ .../blas/base/drotm-wasm/docs/types/test.ts | 614 +++++++++++++ .../blas/base/drotm-wasm/examples/index.js | 51 ++ .../examples/little_endian_arrays.js | 77 ++ .../blas/base/drotm-wasm/examples/module.js | 79 ++ .../base/drotm-wasm/lib/binary.browser.js | 33 + .../blas/base/drotm-wasm/lib/binary.js | 34 + .../@stdlib/blas/base/drotm-wasm/lib/index.js | 123 +++ .../@stdlib/blas/base/drotm-wasm/lib/main.js | 66 ++ .../blas/base/drotm-wasm/lib/module.js | 261 ++++++ .../blas/base/drotm-wasm/lib/routine.js | 201 +++++ .../blas/base/drotm-wasm/manifest.json | 36 + .../@stdlib/blas/base/drotm-wasm/package.json | 82 ++ .../blas/base/drotm-wasm/scripts/build.js | 63 ++ .../blas/base/drotm-wasm/scripts/template.txt | 33 + .../@stdlib/blas/base/drotm-wasm/src/Makefile | 232 +++++ .../blas/base/drotm-wasm/src/main.wasm | Bin 0 -> 1668 bytes .../@stdlib/blas/base/drotm-wasm/src/main.wat | 821 ++++++++++++++++++ .../@stdlib/blas/base/drotm-wasm/test/test.js | 53 ++ .../blas/base/drotm-wasm/test/test.main.js | 727 ++++++++++++++++ .../blas/base/drotm-wasm/test/test.module.js | 154 ++++ .../base/drotm-wasm/test/test.module.main.js | 590 +++++++++++++ .../drotm-wasm/test/test.module.ndarray.js | 698 +++++++++++++++ .../blas/base/drotm-wasm/test/test.ndarray.js | 802 +++++++++++++++++ .../blas/base/drotm-wasm/test/test.routine.js | 71 ++ 32 files changed, 7856 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/routine.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/scripts/build.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/scripts/template.txt create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile create mode 100755 lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wasm create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.main.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.routine.js diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md new file mode 100644 index 000000000000..e0542a24d4d6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md @@ -0,0 +1,363 @@ + + +# drotm + +> Apply a modified Givens plane rotation. + +
+ +## Usage + +```javascript +var drotm = require( '@stdlib/blas/base/drotm-wasm' ); +``` + +#### drotm.main( N, x, strideX, y, strideY, param ) + +Applies a modified Givens plane rotation. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + +drotm.main( 2, x, 2, y, 1, param ); +// x => [ ~-17.0, 2.0, ~-18.0, 4.0, 5.0 ] +// y => [ ~8.0, ~13.0, 8.0, 9.0, 10.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: index increment for `x`. +- **y**: input [`Float64Array`][@stdlib/array/float64]. +- **strideY**: index increment for `y`. +- **param**: parameters for the modified Givens transformation + +The `N` and stride parameters determine how values in the strided arrays are accessed at runtime. For example, to apply a modified Givens plane rotation to every other element, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + +drotm.main( 3, x, 2, y, 2, param ); +// x => [ ~-20.0, 2.0, ~-24.0, 4.0, ~-28.0, 6.0 ] +// y => [ ~9.0, 8.0, ~15.0, 10.0, ~21.0, 12.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y0 = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +var param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element + +drotm.main( 2, x1, 1, y1, 1, param ); +// x0 => [ 1.0, ~9.0, ~10.0, 4.0, 5.0 ] +// y0 => [ 6.0, 7.0, 8.0, ~-2.0, ~-3.0 ] +``` + +#### drotm.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, param ) + +Applies a modified Givens plane rotation using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + +drotm.ndarray( 2, x, 1, 0, y, 2, 1, param ); +// x => [ ~-20.0, ~-25.0, 3.0, 4.0, 5.0 ] +// y => [ 6.0, ~9.0, 8.0, ~13.0, 10.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetY**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to apply a modified Givens plane rotation to every other element starting from the second element, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var y = new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ); +var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + +drotm.ndarray( 3, x, 2, 1, y, 2, 1, param ); +// x => [ 1.0, ~-22.0, 3.0, ~-26.0, 5.0, ~-30.0 ] +// y => [ 7.0, ~12.0, 9.0, ~18.0, 11.0, ~24.0 ] +``` + +* * * + +### Module + +#### drotm.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 drotm.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); +``` + +#### drotm.Module.prototype.main( N, xp, sx, yp, sy, pp ) + +Applies a modified Givens plane rotation. + + + +```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 drotm.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float64'; + +// Specify a vector length: +var N = 5; + +// Define pointers (i.e., byte offsets) for storing three vectors: +var xptr = 0; +var yptr = N * bytesPerElement( dtype ); +var pptr = 2 * N * bytesPerElement( dtype ); + +// Write vector values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); +mod.write( yptr, ones( N, dtype ) ); +mod.write( pptr, zeros( 5, dtype ) ); + +// Perform computation: +mod.main( N, xptr, 1, yptr, 1, pptr ); + +// Read out the results: +var viewX = zeros( N, dtype ); +var viewY = zeros( N, dtype ); +mod.read( xptr, viewX ); +mod.read( yptr, viewY ); + +console.log( viewX ); +// => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + +console.log( viewY ); +// => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **xp**: input [`Float64Array`][@stdlib/array/float64] pointer (i.e., byte offset). +- **sx**: index increment for `x`. +- **yp**: input [`Float64Array`][@stdlib/array/float64] pointer (i.e., byte offset). +- **sy**: index increment for `y`. +- **pp**: parameter [`Float64Array`][@stdlib/array/float64] pointer (i.e., byte offset). + +#### drotm.Module.prototype.ndarray( N, xp, sx, ox, yp, sy, oy, pp ) + +Applies a modified Givens plane rotation 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 drotm.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float64'; + +// Specify a vector length: +var N = 5; + +// Define pointers (i.e., byte offsets) for storing three vectors: +var xptr = 0; +var yptr = N * bytesPerElement( dtype ); +var pptr = 2 * N * bytesPerElement( dtype ); + +// Write vector values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); +mod.write( yptr, ones( N, dtype ) ); +mod.write( pptr, zeros( 5, dtype ) ); + +// Perform computation: +mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); + +// Read out the results: +var viewX = zeros( N, dtype ); +var viewY = zeros( N, dtype ); +mod.read( xptr, viewX ); +mod.read( yptr, viewY ); + +console.log( viewX ); +// => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + +console.log( viewY ); +// => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. + +
+ + + +
+ +* * * + +## Notes + +- If `N <= 0`, both functions leave `x` and `y` unchanged. +- This package implements routines using WebAssembly. When provided arrays which are not allocated on a `drotm` 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/drotm`][@stdlib/blas/base/drotm]. 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/drotm`][@stdlib/blas/base/drotm]. 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. +- `drotm()` corresponds to the [BLAS][blas] level 1 function [`drotm`][drotm]. + +
+ + + +
+ +* * * + +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var drotm = require( '@stdlib/blas/base/drotm-wasm' ); + +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 10, 0, 100, opts ); +console.log( x ); + +var y = discreteUniform( x.length, 0, 10, opts ); +console.log( y ); + +var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + +drotm.ndarray( x.length, x, 1, 0, y, -1, y.length-1, param ); +console.log( y ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.js new file mode 100644 index 000000000000..f3ac6b3de43d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.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'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var zeros = require( '@stdlib/array/zeros' ); +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 drotm = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var param = zeros( 5 ); + var x = uniform( len, -100.0, 100.0, options ); + var y = uniform( len, -100.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + drotm.main( x.length, x, 1, y, 1, param ); + if ( isnan( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ i%y.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/drotm-wasm/benchmark/benchmark.module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.js new file mode 100644 index 000000000000..952517194c71 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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 drotm = 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 drotm.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/drotm-wasm/benchmark/benchmark.module.main.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.main.js new file mode 100644 index 000000000000..967425ef0339 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.main.js @@ -0,0 +1,142 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +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 drotm = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float64' +}; + + +// 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 pptr; + var view; + var xptr; + var yptr; + var mod; + var mem; + var nb; + var i; + + // Create a new BLAS routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new drotm.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 * 2 ) + 5 ) * nb ); + + // Define pointers (i.e., byte offsets) to the first vector elements: + xptr = 0; + yptr = len * nb; + pptr = 2 * len * nb; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -100.0, 100.0, options ) ); + mod.write( yptr, uniform( len, -100.0, 100.0, options ) ); + mod.write( pptr, zeros( 5 ) ); + + // Retrieve a DataView of module memory: + view = mod.view; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mod.main( len, xptr, 1, yptr, 1, pptr ); + byteOffset = yptr + ( (i%len)*nb ); + if ( isnan( view.getFloat64( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( view.getFloat64( 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/drotm-wasm/benchmark/benchmark.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.ndarray.js new file mode 100644 index 000000000000..84ea58da2a21 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.module.ndarray.js @@ -0,0 +1,142 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +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 drotm = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float64' +}; + + +// 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 pptr; + var view; + var xptr; + var yptr; + var mod; + var mem; + var nb; + var i; + + // Create a new BLAS routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new drotm.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 * 2 ) + 5 ) * nb ); + + // Define pointers (i.e., byte offsets) to the first vector elements: + xptr = 0; + yptr = len * nb; + pptr = 2 * len * nb; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -100.0, 100.0, options ) ); + mod.write( yptr, uniform( len, -100.0, 100.0, options ) ); + mod.write( pptr, zeros( 5 ) ); + + // Retrieve a DataView of module memory: + view = mod.view; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mod.ndarray( len, xptr, 1, 0, yptr, 1, 0, pptr ); + byteOffset = yptr + ( (i%len)*nb ); + if ( isnan( view.getFloat64( byteOffset, true ) ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( view.getFloat64( 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/drotm-wasm/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..6622ffec64a4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/benchmark/benchmark.ndarray.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'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var zeros = require( '@stdlib/array/zeros' ); +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 drotm = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasWebAssemblySupport() +}; +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var param = zeros( 5 ); + var x = uniform( len, -100.0, 100.0, options ); + var y = uniform( len, -100.0, 100.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); + if ( isnan( y[ i%y.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y[ i%y.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/drotm-wasm/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt new file mode 100644 index 000000000000..7c3e4e94ce77 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt @@ -0,0 +1,591 @@ + +{{alias}}.main( N, x, strideX, y, strideY, param ) + Applies a modified Givens plane rotation. + + The `N` and stride parameters determine how values 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` is less than or equal to `0`, the vectors are unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: Float64Array + First input array. + + strideX: integer + Index increment for `x`. + + y: Float64Array + Second input array. + + strideY: integer + Index increment for `y`. + + param: Float64Array + Parameters for the modified Givens transformation. + + Returns + ------- + y: Float64Array + Second input array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + > var param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + > {{alias}}.main( 2, x, 2, y, 1, param ); + > x + [ ~-17.0, 2.0, ~-18.0, 4.0, 5.0 ] + > y + [ ~8.0, ~13.0, 8.0, 9.0, 10.0 ] + + // Advanced Indexing: + > x = new {{alias:@stdlib/array/float64}}( [ 0.6, 0.1, -0.5, 0.8, 0.9 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 0.5, -0.9, 0.3, 0.7, -0.6 ] ); + > param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + > {{alias}}.main( 2, x, -2, y, 1, param ); + > x + [ ~3.3, 0.1, ~-2.0, 0.8, 0.9 ] + > y + [ ~-0.5, ~0.3, 0.3, 0.7, -0.6 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + > var y0 = new {{alias:@stdlib/array/float64}}( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + > param = new {{alias:@stdlib/array/float64}}( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); + > {{alias}}.main( 2, x1, 1, y1, 1, param ); + > x0 + [ 1.0, ~9.0, ~10.0, 4.0, 5.0 ] + > y0 + [ 6.0, 7.0, 8.0, ~-2.0, ~-3.0 ] + + +{{alias}}.ndarray( N, x, strideX, offsetX, y, strideY, offsetY, param ) + Applies a modified Givens plane rotation 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. + + x: Float64Array + First input array. + + strideX: integer + Index increment for `x`. + + offsetX: integer + Starting index for `x`. + + y: Float64Array + Second input array. + + strideY: integer + Index increment for `y`. + + offsetY: integer + Starting index for `y`. + + param: Float64Array + Parameters for the modified Givens transformation. + + Returns + ------- + y: Float64Array + Second input array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + > param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + > {{alias}}.ndarray( 2, x, 1, 0, y, 2, 1, param ); + > x + [ ~-20.0, ~-25.0, 3.0, 4.0, 5.0 ] + > y + [ 6.0, ~9.0, 8.0, ~13.0, 10.0 ] + + // Advanced Indexing: + > x = new {{alias:@stdlib/array/float64}}( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ); + > y = new {{alias:@stdlib/array/float64}}( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ); + > param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + > {{alias}}.ndarray( 2, x, -1, 1, y, -2, 2, param ); + > x + [ ~-0.9, ~-0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] + > y + [ ~1.7, -0.9, ~0.5, 0.7, -0.6, 0.2, 0.8 ] + + +{{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, yp, sy, pp ) + Applies a modified Givens plane rotation. + + Parameters + ---------- + N: integer + Number of indexed elements. + + xp: integer + First input array pointer (i.e., byte offset). + + sx: integer + Index increment for `x`. + + yp: integer + Second input array pointer (i.e., byte offset). + + sy: integer + Index increment for `y`. + + pp: integer + Parameters array pointer (i.e., byte offset). + + Returns + ------- + yp: number + Second input array pointer. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + + // Define "pointers" (i.e., byte offsets) into module memory: + > var xptr = 0; + > var yptr = 40; + > var pptr = 80; + + // Write data to module memory: + > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float64' ) ); + > mod.write( yptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); + > mod.write( pptr, {{alias:@stdlib/array/zeros}}( 5, 'float64' ) ); + + // Perform computation: + > mod.main( 5, xptr, 1, yptr, 1, pptr ); + + // Extract results from module memory: + > var viewX = {{alias:@stdlib/array/zeros}}( 5, 'float64' ); + > var viewY = {{alias:@stdlib/array/zeros}}( 5, 'float64' ); + > mod.read( xptr, viewX ); + > mod.read( yptr, viewY ); + > viewX + [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + > viewY + [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + + +{{alias}}.Module.prototype.ndarray( N, xp, sx, ox, yp, sy, oy, pp ) + Applies a modified Givens plane rotation, using alternative indexing + semantics. + + Parameters + ---------- + N: integer + Number of indexed elements. + + xp: integer + First input array pointer (i.e., byte offset). + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + yp: integer + Second input array pointer (i.e., byte offset). + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + pp: integer + Parameters array pointer (i.e., byte offset). + + Returns + ------- + yp: number + Second input array pointer. + + Examples + -------- + > var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); + > var mod = new {{alias}}.Module( mem ); + > mod.initializeSync(); + + // Define "pointers" (i.e., byte offsets) into module memory: + > var xptr = 0; + > var yptr = 40; + > var pptr = 80; + + // Write data to module memory: + > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float64' ) ); + > mod.write( yptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); + > mod.write( pptr, {{alias:@stdlib/array/zeros}}( 5, 'float64' ) ); + + // Perform computation: + > mod.ndarray( 5, xptr, 1, 0, yptr, 1, 0, pptr ); + + // Extract results from module memory: + > var viewX = {{alias:@stdlib/array/zeros}}( 5, 'float64' ); + > var viewY = {{alias:@stdlib/array/zeros}}( 5, 'float64' ); + > mod.read( xptr, viewX ); + > mod.read( yptr, viewY ); + > viewX + [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + > viewY + [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts new file mode 100644 index 000000000000..5d8dc3d50f09 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts @@ -0,0 +1,435 @@ +/* +* @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 drotm.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * var yptr = N * bytesPerElement( dtype ); + * var pptr = 2 * N * bytesPerElement( dtype ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * mod.write( yptr, ones( N, dtype ) ); + * mod.write( pptr, zeros( 5 ) ); + * + * // Perform computation: + * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); + * // returns + * + * var bool = ( ptr === yptr ); + * // returns true + * + * // Read out the results: + * var viewX = zeros( N, dtype ); + * var viewY = zeros( N, dtype ); + * mod.read( xptr, viewX ) + * mod.read( yptr, viewY ); + * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.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 = drotm.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * var yptr = N * bytesPerElement( dtype ); + * var pptr = 2 * N * bytesPerElement( dtype ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * mod.write( yptr, ones( N, dtype ) ); + * mod.write( pptr, zeros( 5 ) ); + * + * // Perform computation: + * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); + * // returns + * + * var bool = ( ptr === yptr ); + * // returns true + * + * // Read out the results: + * var viewX = zeros( N, dtype ); + * var viewY = zeros( N, dtype ); + * mod.read( xptr, viewX ) + * mod.read( yptr, viewY ); + * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + ( mem: Memory ): Module; // callable +} + +/** +* Interface describing a `drotm` WebAssembly module. +*/ +interface Module extends ModuleWrapper { + /** + * Applies a modified Givens plane rotation. + * + * @param N - number of indexed elements + * @param xptr - first input array pointer (i.e., byte offset) + * @param strideX - `x` stride length + * @param yptr - second input array pointer (i.e., byte offset) + * @param strideY - `y` stride length + * @param pptr - parameter array pointer (i.e., byte offset) + * @returns second 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 drotm.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * var yptr = N * bytesPerElement( dtype ); + * var pptr = 2 * N * bytesPerElement( dtype ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * mod.write( yptr, ones( N, dtype ) ); + * mod.write( pptr, zeros( 5 ) ); + * + * // Perform computation: + * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); + * // returns + * + * var bool = ( ptr === yptr ); + * // returns true + * + * // Read out the results: + * var viewX = zeros( N, dtype ); + * var viewY = zeros( N, dtype ); + * mod.read( xptr, viewX ) + * mod.read( yptr, viewY ); + * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + main( N: number, xptr: number, strideX: number, yptr: number, strideY: number, pptr: number ): number; + + /** + * Applies a modified Givens plane rotation using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param xptr - first input array pointer (i.e., byte offset) + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param yptr - second input array pointer (i.e., byte offset) + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @param pptr - parameter array pointer (i.e., byte offset) + * @returns second 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 drotm.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * var yptr = N * bytesPerElement( dtype ); + * var pptr = 2 * N * bytesPerElement( dtype ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * mod.write( yptr, ones( N, dtype ) ); + * mod.write( pptr, zeros( 5 ) ); + * + * // Perform computation: + * var ptr = mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); + * // returns + * + * var bool = ( ptr === yptr ); + * // returns true + * + * // Read out the results: + * var viewX = zeros( N, dtype ); + * var viewY = zeros( N, dtype ); + * mod.read( xptr, viewX ) + * mod.read( yptr, viewY ); + * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + ndarray( N: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number, pptr: number ): number; +} + +/** +* Interface describing `drotm`. +*/ +interface Routine extends ModuleWrapper { + /** + * Applies a modified Givens plane rotation. + * + * @param N - number of indexed elements + * @param x - first input array + * @param strideX - `x` stride length + * @param y - second input array + * @param strideY - `y` stride length + * @param param - parameters for the modified Givens transformation + * @returns second input array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + * var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + * var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + * + * drotm.main( x.length, x, 1, y, 1, param ); + * // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] + * // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + */ + main( N: number, x: Float64Array, strideX: number, y: Float64Array, strideY: number, param: Float64Array ): Float64Array; + + /** + * Applies a modified Givens plane rotation using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param y - second input array + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @param param - parameters for the modified Givens transformation + * @returns second input array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + * var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + * var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + * + * drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); + * // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] + * // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + */ + ndarray( N: number, x: Float64Array, strideX: number, offsetX: number, y: Float64Array, strideY: number, offsetY: number, param: Float64Array ): Float64Array; + + /** + * 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 drotm.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 5; + * + * // Define pointers (i.e., byte offsets) for storing two vectors: + * var xptr = 0; + * var yptr = N * bytesPerElement( dtype ); + * var pptr = 2 * N * bytesPerElement( dtype ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * mod.write( yptr, ones( N, dtype ) ); + * mod.write( pptr, zeros( 5 ) ); + * + * // Perform computation: + * var ptr = mod.main( N, xptr, 1, yptr, 1, param ); + * // returns + * + * var bool = ( ptr === yptr ); + * // returns true + * + * // Read out the results: + * var viewX = zeros( N, dtype ); + * var viewY = zeros( N, dtype ); + * mod.read( xptr, viewX ) + * mod.read( yptr, viewY ); + * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + Module: ModuleConstructor; +} + +/** +* Applies a modified Givens plane rotation. +* +* @param N - number of indexed elements +* @param x - first input array +* @param strideX - `x` stride length +* @param y - second input array +* @param strideY - `y` stride length +* @param param - parameters for the modified Givens transformation +* @returns second input array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* drotm.main( x.length, x, 1, y, 1, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +*/ +declare var drotm: Routine; + + +// EXPORTS // + +export = drotm; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts new file mode 100644 index 000000000000..ee555b61b206 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts @@ -0,0 +1,614 @@ +/* +* @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 drotm = require( './index' ); + + +// TESTS // + +// Attached to the main export is a `main` method which returns a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( x.length, x, 1, y, 1, param ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `main` method is provided a first argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( '10', x, 1, y, 1, param ); // $ExpectError + drotm.main( true, x, 1, y, 1, param ); // $ExpectError + drotm.main( false, x, 1, y, 1, param ); // $ExpectError + drotm.main( null, x, 1, y, 1, param ); // $ExpectError + drotm.main( undefined, x, 1, y, 1, param ); // $ExpectError + drotm.main( [], x, 1, y, 1, param ); // $ExpectError + drotm.main( {}, x, 1, y, 1, param ); // $ExpectError + drotm.main( ( x: number ): number => x, x, 1, y, 1, param ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a second argument which is not a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( x.length, 10, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, '10', 1, y, 1, param ); // $ExpectError + drotm.main( x.length, true, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, false, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, null, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, undefined, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, [], 1, y, 1, param ); // $ExpectError + drotm.main( x.length, {}, 1, y, 1, param ); // $ExpectError + drotm.main( x.length, ( x: number ): number => x, 1, y, 1, param ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a third argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( x.length, x, '10', y, 1, param ); // $ExpectError + drotm.main( x.length, x, true, y, 1, param ); // $ExpectError + drotm.main( x.length, x, false, y, 1, param ); // $ExpectError + drotm.main( x.length, x, null, y, 1, param ); // $ExpectError + drotm.main( x.length, x, undefined, y, 1, param ); // $ExpectError + drotm.main( x.length, x, [], y, 1, param ); // $ExpectError + drotm.main( x.length, x, {}, y, 1, param ); // $ExpectError + drotm.main( x.length, x, ( x: number ): number => x, y, 1, param ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a fourth argument which is not a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + + drotm.main( x.length, x, 1, 10, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, '10', 1, param ); // $ExpectError + drotm.main( x.length, x, 1, true, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, false, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, null, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, undefined, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, [], 1, param ); // $ExpectError + drotm.main( x.length, x, 1, {}, 1, param ); // $ExpectError + drotm.main( x.length, x, 1, ( x: number ): number => x, 1, param ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a fifth argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( x.length, x, 1, y, '10', param ); // $ExpectError + drotm.main( x.length, x, 1, y, true, param ); // $ExpectError + drotm.main( x.length, x, 1, y, false, param ); // $ExpectError + drotm.main( x.length, x, 1, y, null, param ); // $ExpectError + drotm.main( x.length, x, 1, y, undefined, param ); // $ExpectError + drotm.main( x.length, x, 1, y, [], param ); // $ExpectError + drotm.main( x.length, x, 1, y, {}, param ); // $ExpectError + drotm.main( x.length, x, 1, y, ( x: number ): number => x, param ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a sixth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main( x.length, x, 1, y, 1, 10 ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, '10' ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, true ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, false ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, null ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, undefined ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, [] ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, {} ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided an unsupported number of arguments... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.main(); // $ExpectError + drotm.main( x.length ); // $ExpectError + drotm.main( x.length, x ); // $ExpectError + drotm.main( x.length, x, 1 ); // $ExpectError + drotm.main( x.length, x, 1, y ); // $ExpectError + drotm.main( x.length, x, 1, y, 1 ); // $ExpectError + drotm.main( x.length, x, 1, y, 1, param, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( '10', x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( true, x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( false, x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( null, x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( undefined, x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( [], x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( {}, x, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, 10, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, '10', 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, true, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, false, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, null, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, undefined, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, [], 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, {}, 1, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, ( x: number ): number => x, 1, 0, y, 1, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, '10', 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, true, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, false, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, null, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, undefined, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, [], 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, {}, 0, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, '10', y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, true, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, false, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, null, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, undefined, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, [], y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, {}, y, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a Float64Array... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, 0, 10, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, '10', 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, true, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, false, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, null, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, undefined, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, [], 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, {}, 1, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, ( x: number ): number => x, 1, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, 0, y, '10', 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, true, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, false, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, null, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, undefined, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, [], 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, {}, 0, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, 0, y, 1, '10', param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, true, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, false, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, null, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, undefined, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, [], param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, {}, param ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x, param ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a eighth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, 10 ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, '10' ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, true ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, false ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, null ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, undefined ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, [] ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, {} ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const param = new Float64Array( 5 ); + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + drotm.ndarray(); // $ExpectError + drotm.ndarray( x.length ); // $ExpectError + drotm.ndarray( x.length, x ); // $ExpectError + drotm.ndarray( x.length, x, 1 ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0 ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectError + drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param, 10 ); // $ExpectError +} + +// Attached to the main export is a `Module` constructor which returns a module... +{ + const mem = new Memory({ + 'initial': 0 + }); + + drotm.Module( mem ); // $ExpectType Module +} + +// The compiler throws an error if the `Module` constructor is not provided a WebAssembly memory instance... +{ + drotm.Module( '10' ); // $ExpectError + drotm.Module( true ); // $ExpectError + drotm.Module( false ); // $ExpectError + drotm.Module( null ); // $ExpectError + drotm.Module( undefined ); // $ExpectError + drotm.Module( [] ); // $ExpectError + drotm.Module( {} ); // $ExpectError + drotm.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 = drotm.Module( mem ); + + mod.main( 10, 0, 1, 80, 1, 120 ); // $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 = drotm.Module( mem ); + + mod.main( '10', 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( true, 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( false, 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( null, 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( undefined, 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( [], 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( {}, 10, 1, 80, 1, 120 ); // $ExpectError + mod.main( ( x: number ): number => x, 10, 1, 80, 1, 120 ); // $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 = drotm.Module( mem ); + + mod.main( 10, '10', 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, true, 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, false, 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, null, 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, undefined, 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, [], 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, {}, 1, 80, 1, 120 ); // $ExpectError + mod.main( 10, ( x: number ): number => x, 1, 80, 1, 120 ); // $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 = drotm.Module( mem ); + + mod.main( 10, 0, '10', 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, true, 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, false, 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, null, 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, undefined, 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, [], 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, {}, 80, 1, 120 ); // $ExpectError + mod.main( 10, 0, ( x: number ): number => x, 80, 1, 120 ); // $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 = drotm.Module( mem ); + + mod.main( 10, 0, 1, '10', 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, true, 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, false, 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, null, 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, undefined, 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, [], 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, {}, 1, 120 ); // $ExpectError + mod.main( 10, 0, 1, ( x: number ): number => x, 1, 120 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a fifth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = drotm.Module( mem ); + + mod.main( 10, 0, 1, 80, '10', 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, true, 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, false, 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, null, 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, undefined, 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, [], 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, {}, 120 ); // $ExpectError + mod.main( 10, 0, 1, 80, ( x: number ): number => x, 120 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a sixth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = drotm.Module( mem ); + + mod.main( 10, 0, 1, 80, 1, '10'); // $ExpectError + mod.main( 10, 0, 1, 80, 1, true); // $ExpectError + mod.main( 10, 0, 1, 80, 1, false); // $ExpectError + mod.main( 10, 0, 1, 80, 1, null); // $ExpectError + mod.main( 10, 0, 1, 80, 1, undefined); // $ExpectError + mod.main( 10, 0, 1, 80, 1, []); // $ExpectError + mod.main( 10, 0, 1, 80, 1, {}); // $ExpectError + mod.main( 10, 0, 1, 80, 1, ( 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 = drotm.Module( mem ); + + mod.main(); // $ExpectError + mod.main( 10 ); // $ExpectError + mod.main( 10, 0 ); // $ExpectError + mod.main( 10, 0, 1 ); // $ExpectError + mod.main( 10, 0, 1, 80 ); // $ExpectError + mod.main( 10, 0, 1, 80, 1 ); // $ExpectError + mod.main( 10, 0, 1, 80, 1, 120, 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 = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, 120 ); // $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 = drotm.Module( mem ); + + mod.ndarray( '10', 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( true, 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( false, 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( null, 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( undefined, 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( [], 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( {}, 0, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( ( x: number ): number => x, 0, 1, 0, 80, 1, 0, 120 ); // $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 = drotm.Module( mem ); + + mod.ndarray( 10, '10', 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, true, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, false, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, null, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, undefined, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, [], 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, {}, 1, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, ( x: number ): number => x, 1, 0, 80, 1, 0, 120 ); // $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 = drotm.Module( mem ); + + mod.ndarray( 10, 0, '10', 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, true, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, false, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, null, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, undefined, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, [], 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, {}, 0, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, ( x: number ): number => x, 0, 80, 1, 0, 120 ); // $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 = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, '10', 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, true, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, false, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, null, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, undefined, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, [], 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, {}, 80, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, ( x: number ): number => x, 80, 1, 0, 120 ); // $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 = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, 0, '10', 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, true, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, false, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, null, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, undefined, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, [], 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, {}, 1, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, ( x: number ): number => x, 1, 0, 120 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a sixth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, 0, 80, '10', 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, true, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, false, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, null, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, undefined, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, [], 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, {}, 0, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, ( x: number ): number => x, 0, 120 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a seventh argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, 0, 80, 1, '10', 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, true, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, false, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, null, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, undefined, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, [], 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, {}, 120 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, ( x: number ): number => x, 120 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided an eighth argument which is not a number... +{ + const mem = new Memory({ + 'initial': 1 + }); + const mod = drotm.Module( mem ); + + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, '10' ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, true ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, false ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, null ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, undefined ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, [] ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, {} ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, ( 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 = drotm.Module( mem ); + + mod.ndarray(); // $ExpectError + mod.ndarray( 10 ); // $ExpectError + mod.ndarray( 10, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 80, 1, 0, 120, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/index.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/index.js new file mode 100644 index 000000000000..9b56b8828d70 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/index.js @@ -0,0 +1,51 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var oneTo = require( '@stdlib/array/one-to' ); +var ones = require( '@stdlib/array/ones' ); +var drotm = require( './../lib' ); + +function main() { + if ( !hasWebAssemblySupport() ) { + console.error( 'Environment does not support WebAssembly.' ); + return; + } + // Specify a vector length: + var N = 5; + + // Create input arrays: + var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + var x = oneTo( N, 'float64' ); + var y = ones( N, 'float64' ); + + // Perform computation: + drotm.ndarray( N, x, 1, 0, y, 1, 0, param ); + + // Print the results: + console.log( x ); + // => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] + + console.log( y ); + // => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js new file mode 100644 index 000000000000..c042da94a976 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js @@ -0,0 +1,77 @@ +/** +* @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 gfill = require( '@stdlib/blas/ext/base/gfill' ); +var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); +var drotm = 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 drotm.Module( mem ); + // returns + + // Initialize the routine: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Define a vector data type: + var dtype = 'float64'; + + // Specify a vector length: + var N = 5; + + // Define pointers (i.e., byte offsets) for storing three vectors: + var xptr = 0; + var yptr = N * bytesPerElement( dtype ); + var pptr = 2 * N * bytesPerElement( dtype ); + + // Create typed array views over module memory: + var x = new Float64ArrayLE( mod.memory.buffer, xptr, N ); + var y = new Float64ArrayLE( mod.memory.buffer, yptr, N ); + var param = new Float64ArrayLE( mod.memory.buffer, pptr, 5 ); + + // Write values to module memory: + gfillBy( N, x, 1, discreteUniform( -10.0, 10.0 ) ); + gfill( N, 1.0, y, 1 ); + gfill( 5, 0.0, param, 1 ); + + // Perform computation: + mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); + + // Print the results: + console.log( 'x[:] = [%s]', x.toString() ); + console.log( 'y[:] = [%s]', y.toString() ); +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js new file mode 100644 index 000000000000..d744290a8761 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js @@ -0,0 +1,79 @@ +/** +* @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 ones = require( '@stdlib/array/ones' ); +var zeros = require( '@stdlib/array/zeros' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var drotm = 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 drotm.Module( mem ); + // returns + + // Initialize the routine: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Define a vector data type: + var dtype = 'float64'; + + // Specify a vector length: + var N = 5; + + // Define pointers (i.e., byte offsets) for storing three vectors: + var xptr = 0; + var yptr = N * bytesPerElement( dtype ); + var pptr = 2 * N * bytesPerElement( dtype ); + + // Write vector values to module memory: + mod.write( xptr, oneTo( N, dtype ) ); + mod.write( yptr, ones( N, dtype ) ); + mod.write( pptr, zeros( 5, dtype ) ); + + // Perform computation: + mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); + + // Read out the results: + var viewX = zeros( N, dtype ); + var viewY = zeros( N, dtype ); + mod.read( xptr, viewX ); + mod.read( yptr, viewY ); + + console.log( viewX ); + // => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + + console.log( viewY ); + // => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js new file mode 100644 index 000000000000..4fff4a05bc53 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEYA2AAAGAGf39/f39/AGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBAMAAQIHTAQRX193YXNtX2NhbGxfY3RvcnMAABhfX3dhc21fYXBwbHlfZGF0YV9yZWxvY3MAAAdjX2Ryb3RtAAEPY19kcm90bV9uZGFycmF5AAIK6QsDAwABCz0BAn4gACABIAIgAqwiBkIBIACsIgd9fkIAIAZCAFcbpyADIAQgBKwiBkIBIAd9fkIAIAZCAFcbpyAFEAILpAsCBnwFfwJAIABBAEwNACAHKwMAIgpEAAAAAAAAAMBhDQACQCACQQBMDQAgAiAFRw0AIApEAAAAAAAAAABjBEAgBysDICEKIAcrAxAhCSAHKwMYIQggBysDCCELIABBAUcEQCAAQf7///8HcSEFQQAhBgNAIAEgA0EDdCIHaiIOIA4rAwAiDCALoiAIIAQgB2oiBysDACINoqA5AwAgByAMIAmiIAogDaKgOQMAIAEgAiADaiIDQQN0IgdqIg4gDisDACIMIAuiIAggBCAHaiIHKwMAIg2ioDkDACAHIAwgCaIgCiANoqA5AwAgAiADaiEDIAZBAmoiBiAFRw0ACwsgAEEBcUUNAiABIANBA3QiAGoiASABKwMAIgwgC6IgCCAAIARqIgArAwAiCKKgOQMAIAAgDCAJoiAKIAiioDkDAA8LIApEAAAAAAAAAABhBEAgBysDECEKIAcrAxghCSAAQQFHBEAgAEH+////B3EhBUEAIQYDQCABIANBA3QiB2oiDiAEIAdqIgcrAwAiCCAJoiAOKwMAIgugOQMAIAcgCCALIAqioDkDACABIAIgA2oiA0EDdCIHaiIOIAQgB2oiBysDACIIIAmiIA4rAwAiC6A5AwAgByAIIAsgCqKgOQMAIAIgA2ohAyAGQQJqIgYgBUcNAAsLIABBAXFFDQIgASADQQN0IgBqIgEgACAEaiIAKwMAIgggCaIgASsDACIJoDkDACAAIAggCSAKoqA5AwAPCyAHKwMgIQogBysDCCEJIABBAUcEQCAAQf7///8HcSEFQQAhBgNAIAEgA0EDdCIHaiIOIA4rAwAiCCAJoiAEIAdqIgcrAwAiC6A5AwAgByALIAqiIAihOQMAIAEgAiADaiIDQQN0IgdqIg4gDisDACIIIAmiIAQgB2oiBysDACILoDkDACAHIAsgCqIgCKE5AwAgAiADaiEDIAZBAmoiBiAFRw0ACwsgAEEBcUUNASABIANBA3QiAGoiASABKwMAIgggCaIgACAEaiIAKwMAIgmgOQMAIAAgCSAKoiAIoTkDAA8LIApEAAAAAAAAAABjBEAgBysDICEKIAcrAxAhCSAHKwMYIQggBysDCCELQQAhBwNAIAEgA0EDdGoiDiAOKwMAIgwgC6IgCCAEIAZBA3RqIg4rAwAiDaKgOQMAIA4gDCAJoiAKIA2ioDkDACAFIAZqIQYgAiADaiEDIAdBAWoiByAARw0ACwwBCyAKRAAAAAAAAAAAYQRAIAcrAxAhCiAHKwMYIQkgAEEBRwRAIABB/v///wdxIQ4gBSAFaiEQIAIgAmohEUEAIQcDQCABIANBA3RqIg8gBCAGQQN0aiISKwMAIgggCaIgDysDACILoDkDACASIAggCyAKoqA5AwAgASACIANqQQN0aiIPIAQgBSAGakEDdGoiEisDACIIIAmiIA8rAwAiC6A5AwAgEiAIIAsgCqKgOQMAIAYgEGohBiADIBFqIQMgB0ECaiIHIA5HDQALCyAAQQFxRQ0BIAEgA0EDdGoiACAEIAZBA3RqIgErAwAiCCAJoiAAKwMAIgmgOQMAIAEgCCAJIAqioDkDAA8LIAcrAyAhCiAHKwMIIQkgAEEBRwRAIABB/v///wdxIQ4gBSAFaiEQIAIgAmohEUEAIQcDQCABIANBA3RqIg8gDysDACIIIAmiIAQgBkEDdGoiDysDACILoDkDACAPIAsgCqIgCKE5AwAgASACIANqQQN0aiIPIA8rAwAiCCAJoiAEIAUgBmpBA3RqIg8rAwAiC6A5AwAgDyALIAqiIAihOQMAIAYgEGohBiADIBFqIQMgB0ECaiIHIA5HDQALCyAAQQFxRQ0AIAEgA0EDdGoiACAAKwMAIgggCaIgBCAGQQN0aiIAKwMAIgmgOQMAIAAgCSAKoiAIoTkDAAsL' ); + + +// EXPORTS // + +module.exports = wasm; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.js new file mode 100644 index 000000000000..6f02393f96e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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/drotm-wasm/lib/index.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js new file mode 100644 index 000000000000..0b2351028903 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js @@ -0,0 +1,123 @@ +/** +* @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 apply a modified Givens plane rotation. +* +* @module @stdlib/blas/base/drotm-wasm +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var drotm = require( '@stdlib/blas/base/drotm-wasm' ); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.main( x.length, x, 1, y, 1, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var drotm = require( '@stdlib/blas/base/drotm-wasm' ); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.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 drotm = require( '@stdlib/blas/base/drotm-wasm' ); +* +* // 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 drotm.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointers (i.e., byte offsets) for storing three vectors: +* var xptr = 0; +* var yptr = N * bytesPerElement( dtype ); +* var pptr = 2 * N * bytesPerElement( dtype ); +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* mod.write( yptr, ones( N, dtype ) ); +* mod.write( pptr, zeros( 5, dtype ) ); +* +* // Perform computation: +* mod.main( N, xptr, 1, yptr, 1, pptr ); +* +* // Read out the results: +* var viewX = zeros( N, dtype ); +* var viewY = zeros( N, dtype ); +* mod.read( xptr, viewX ); +* mod.read( yptr, viewY ); +* +* console.log( viewX ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* +* console.log( viewY ); +* // => [ 1.0, 1.0, 1.0, 1.0, 1.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/drotm-wasm/lib/main.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/main.js new file mode 100644 index 000000000000..eb901136046c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/main.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 Routine = require( './routine.js' ); + + +// MAIN // + +/** +* WebAssembly module to apply a modified Givens plane rotation. +* +* @name drotm +* @type {Routine} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.main( x.length, x, 1, y, 1, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +*/ +var drotm = new Routine(); +drotm.initializeSync(); // eslint-disable-line node/no-sync + + +// EXPORTS // + +module.exports = drotm; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js new file mode 100644 index 000000000000..b4370bcff24c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js @@ -0,0 +1,261 @@ +/** +* @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 drotm = new Module( mem ); +* // returns +* +* // Initialize the routine: +* drotm.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointers (i.e., byte offsets) for storing three vectors: +* var xptr = 0; +* var yptr = N * bytesPerElement( dtype ); +* var pptr = 2 * N * bytesPerElement( dtype ); +* +* // Write vector values to module memory: +* drotm.write( xptr, oneTo( N, dtype ) ); +* drotm.write( yptr, ones( N, dtype ) ); +* drotm.write( pptr, zeros( 5, dtype ) ); +* +* // Perform computation: +* var ptr = drotm.main( N, xptr, 1, yptr, 1, pptr ); +* // returns +* +* var bool = ( ptr === yptr ); +* // returns true +* +* // Read out the results: +* var viewX = zeros( N, dtype ); +* var viewY = zeros( N, dtype ); +* drotm.read( xptr, viewX ); +* drotm.read( yptr, viewY ); +* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.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 ); + +/** +* Applies a modified Givens plane rotation. +* +* @name main +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset) +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset) +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} pptr - parameter array pointer (i.e., byte offset) +* @returns {NonNegativeInteger} second 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 drotm = new Module( mem ); +* // returns +* +* // Initialize the routine: +* drotm.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointers (i.e., byte offsets) for storing two vectors: +* var xptr = 0; +* var yptr = N * bytesPerElement( dtype ); +* var pptr = 2 * N * bytesPerElement( dtype ); +* +* // Write vector values to module memory: +* drotm.write( xptr, oneTo( N, dtype ) ); +* drotm.write( yptr, ones( N, dtype ) ); +* drotm.write( pptr, zeros( 5, dtype ) ); +* +* // Perform computation: +* var ptr = drotm.main( N, xptr, 1, yptr, 1, pptr ); +* // returns +* +* var bool = ( ptr === yptr ); +* // returns true +* +* // Read out the results: +* var viewX = zeros( N, dtype ); +* var viewY = zeros( N, dtype ); +* drotm.read( xptr, viewX ); +* drotm.read( yptr, viewY ); +* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, strideY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point + this._instance.exports.c_drotm( N, xptr, strideX, yptr, strideY, pptr ); + return yptr; +}); + +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +* +* @name ndarray +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset) +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset) +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting `y` index +* @param {NonNegativeInteger} pptr - parameter array pointer (i.e., byte offset) +* @returns {NonNegativeInteger} second 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 drotm = new Module( mem ); +* // returns +* +* // Initialize the routine: +* drotm.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 5; +* +* // Define pointers (i.e., byte offsets) for storing two vectors: +* var xptr = 0; +* var yptr = N * bytesPerElement( dtype ); +* var pptr = 2 * N * bytesPerElement( dtype ); +* +* // Write vector values to module memory: +* drotm.write( xptr, oneTo( N, dtype ) ); +* drotm.write( yptr, ones( N, dtype ) ); +* drotm.write( pptr, zeros( 5, dtype ) ); +* +* // Perform computation: +* var ptr = drotm.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); +* // returns +* +* var bool = ( ptr === yptr ); +* // returns true +* +* // Read out the results: +* var viewX = zeros( N, dtype ); +* var viewY = zeros( N, dtype ); +* drotm.read( xptr, viewX ); +* drotm.read( yptr, viewY ); +* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +setReadOnly( Module.prototype, 'ndarray', function drotm( N, xptr, strideX, offsetX, yptr, strideY, offsetY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point + this._instance.exports.c_drotm_ndarray( N, xptr, strideX, offsetX, yptr, strideY, offsetY, pptr ); // eslint-disable-line max-len + return yptr; +}); + + +// EXPORTS // + +module.exports = Module; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/routine.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/routine.js new file mode 100644 index 000000000000..ffb9afcec4f0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/routine.js @@ -0,0 +1,201 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var drotm = new Routine(); +* +* // Initialize the module: +* drotm.initializeSync(); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.main( x.length, x, 1, y, 1, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var drotm = new Routine(); +* +* // Initialize the module: +* drotm.initializeSync(); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.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 ); + +/** +* Applies a modified Givens plane rotation. +* +* @name main +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {Float64Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {Float64Array} param - parameters for the modified Givens transformation +* @returns {Float64Array} second input array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var drotm = new Routine(); +* +* // Initialize the module: +* drotm.initializeSync(); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.main( x.length, x, 1, y, 1, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +*/ +setReadOnly( Routine.prototype, 'main', function drotm( N, x, strideX, y, strideY, param ) { + return this.ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ), param ); // eslint-disable-line max-len +}); + +/** +* Applies a modified Givens plane rotation using alternative indexing semantics. +* +* @name ndarray +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float64Array} param - parameters for the modified Givens transformation +* @returns {Float64Array} second input array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var drotm = new Routine(); +* +* // Initialize the module: +* drotm.initializeSync(); +* +* // Define strided arrays: +* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); +* var param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); +* +* // Perform operation: +* drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); +* // x => [ -2.0, -1.0, 0.0, 1.0, 2.0 ] +* // y => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] +*/ +setReadOnly( Routine.prototype, 'ndarray', function drotm( N, x, strideX, offsetX, y, strideY, offsetY, param ) { + var ptrs; + var p0; + var p1; + var p2; + + // Convert the input arrays to "pointers" in the module's memory: + ptrs = arrays2ptrs( this, [ + strided2object( N, x, strideX, offsetX ), + strided2object( N, y, strideY, offsetY ), + strided2object( 5, param, 1, 0 ) + ]); + p0 = ptrs[ 0 ]; + p1 = ptrs[ 1 ]; + p2 = ptrs[ 2 ]; + + // Perform computation by calling the corresponding parent method: + Module.prototype.ndarray.call( this, N, p0.ptr, p0.stride, p0.offset, p1.ptr, p1.stride, p1.offset, p2.ptr ); // eslint-disable-line max-len + + // If the arrays data had to be copied to module memory, copy the results to the provided corresponding output arrays... + if ( p0.copy ) { + readDataView( N, this.view, p0.stride*p0.BYTES_PER_ELEMENT, p0.ptr, x, strideX, offsetX, true ); // eslint-disable-line max-len + } + if ( p1.copy ) { + readDataView( N, this.view, p1.stride*p1.BYTES_PER_ELEMENT, p1.ptr, y, strideY, offsetY, true ); // eslint-disable-line max-len + } + return y; +}); + + +// EXPORTS // + +module.exports = Routine; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/manifest.json b/lib/node_modules/@stdlib/blas/base/drotm-wasm/manifest.json new file mode 100644 index 000000000000..b84c8e6dac7d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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/drotm" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/package.json b/lib/node_modules/@stdlib/blas/base/drotm-wasm/package.json new file mode 100644 index 000000000000..8cd19f8aeb9b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/package.json @@ -0,0 +1,82 @@ +{ + "name": "@stdlib/blas/base/drotm-wasm", + "version": "0.0.0", + "description": "Apply a modified Givens transformation.", + "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", + "drotm", + "modified", + "givens", + "rotation", + "linear", + "algebra", + "subroutines", + "vector", + "array", + "ndarray", + "float64", + "double", + "float64array", + "webassembly", + "wasm" + ], + "__stdlib__": { + "wasm": true + } +} diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/scripts/build.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/scripts/build.js new file mode 100644 index 000000000000..348354d7029c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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/drotm-wasm/scripts/template.txt b/lib/node_modules/@stdlib/blas/base/drotm-wasm/scripts/template.txt new file mode 100644 index 000000000000..12996dd89e3b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/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/drotm-wasm/src/Makefile b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile new file mode 100644 index 000000000000..77377aee65fa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile @@ -0,0 +1,232 @@ +#/ +# @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 command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic \ + -D CBLAS_INT=int32_t + +# Define the command-line options when compiling C files to WebAssembly and asm.js: +EMCCFLAGS ?= $(CFLAGS) + +# Define shared `emcc` flags: +EMCC_SHARED_FLAGS := \ + -s SIDE_MODULE=2 \ + -s WASM_BIGINT=0 \ + -s EXPORTED_FUNCTIONS="['_c_drotm','_c_drotm_ndarray']" + +# Define WebAssembly `emcc` flags: +EMCC_WASM_FLAGS := $(EMCC_SHARED_FLAGS) \ + -s WASM=1 + +# 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 + +.PHONY: clean-wasm + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-wasm + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wasm b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wasm new file mode 100755 index 0000000000000000000000000000000000000000..2e8c28b45eef9e0318551270934f2ea447eb2422 GIT binary patch literal 1668 zcmbW1&2G~`6ov21_%E3xPP&T3=Gt2%#Fhn89f7*(o~2_YSzz+hx)CT6G_L{?5}Q5* zuft0a?wzp{rx7H@8+&Ga$LG7}j3K+537{(s#;fW3`G*%Tg~MafS3`iIw>B3H1N*RE zgA9e5%s+aw$!t-qB!F@h2vK7eYFRf@-{aVO-1QaMyKE&QYAUwqWm-_*rH-LA~exO1J z9lLZe?{=mBuBG?cUCT>^1g_hF{&NL!^9|VRXVwN1Jcd)}BY@yy@KssrPY9VfKzP?hV z23y$JU=zzRQ>r}v&uXrX6ncrwW6!W?qw)4_TUMGNj|GaFCO{{TfhPj12`Wu?9O_y_ zGTV@@ZAhOQa!w2O*a6d;j_8sYy0fussI0?up<#3YnbRnB5HML(dLEpK zXqXJ$UUY@XfEavZzmE{ltosKdxoOk3ch>0G!&Zn4XmuQTdLrZ$X@3{#<3M{9begSY zx>Mz+%(RPM9(g9%6iz=8bOaFSpy`%)TDCgqqMJuu{uSg=?~$^Qj+a$)VbaVNhx}xH zxFCxkMa@X(GL~otrz<_|GL6C>A2pwknvWf(sg7D@2%V~(A`>-h3oEjYh^K_^6uTiU q18BQYV-F4aK?Y0qdfBcEf2%yr&I#wA7qi=c3cFDGVrGuhsP!M5lL@i_ literal 0 HcmV?d00001 diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat new file mode 100644 index 000000000000..eee6bfcb0481 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat @@ -0,0 +1,821 @@ +;; @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. + +(module + (type (;0;) (func)) + (type (;1;) (func (param i32 i32 i32 i32 i32 i32))) + (type (;2;) (func (param i32 i32 i32 i32 i32 i32 i32 i32))) + (import "env" "memory" (memory (;0;) 0)) + (func (;0;) (type 0) + nop) + (func (;1;) (type 1) (param i32 i32 i32 i32 i32 i32) + (local i64 i64) + local.get 0 + local.get 1 + local.get 2 + local.get 2 + i64.extend_i32_s + local.tee 6 + i64.const 1 + local.get 0 + i64.extend_i32_s + local.tee 7 + i64.sub + i64.mul + i64.const 0 + local.get 6 + i64.const 0 + i64.le_s + select + i32.wrap_i64 + local.get 3 + local.get 4 + local.get 4 + i64.extend_i32_s + local.tee 6 + i64.const 1 + local.get 7 + i64.sub + i64.mul + i64.const 0 + local.get 6 + i64.const 0 + i64.le_s + select + i32.wrap_i64 + local.get 5 + call 2) + (func (;2;) (type 2) (param i32 i32 i32 i32 i32 i32 i32 i32) + (local f64 f64 f64 f64 f64 f64 i32 i32 i32 i32 i32) + block ;; label = @1 + local.get 0 + i32.const 0 + i32.le_s + br_if 0 (;@1;) + local.get 7 + f64.load + local.tee 10 + f64.const -0x1p+1 (;=-2;) + f64.eq + br_if 0 (;@1;) + block ;; label = @2 + local.get 2 + i32.const 0 + i32.le_s + br_if 0 (;@2;) + local.get 2 + local.get 5 + i32.ne + br_if 0 (;@2;) + local.get 10 + f64.const 0x0p+0 (;=0;) + f64.lt + if ;; label = @3 + local.get 7 + f64.load offset=32 + local.set 10 + local.get 7 + f64.load offset=16 + local.set 9 + local.get 7 + f64.load offset=24 + local.set 8 + local.get 7 + f64.load offset=8 + local.set 11 + local.get 0 + i32.const 1 + i32.ne + if ;; label = @4 + local.get 0 + i32.const 2147483646 + i32.and + local.set 5 + i32.const 0 + local.set 6 + loop ;; label = @5 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 12 + local.get 11 + f64.mul + local.get 8 + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 13 + f64.mul + f64.add + f64.store + local.get 7 + local.get 12 + local.get 9 + f64.mul + local.get 10 + local.get 13 + f64.mul + f64.add + f64.store + local.get 1 + local.get 2 + local.get 3 + i32.add + local.tee 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 12 + local.get 11 + f64.mul + local.get 8 + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 13 + f64.mul + f64.add + f64.store + local.get 7 + local.get 12 + local.get 9 + f64.mul + local.get 10 + local.get 13 + f64.mul + f64.add + f64.store + local.get 2 + local.get 3 + i32.add + local.set 3 + local.get 6 + i32.const 2 + i32.add + local.tee 6 + local.get 5 + i32.ne + br_if 0 (;@5;) + end + end + local.get 0 + i32.const 1 + i32.and + i32.eqz + br_if 2 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 0 + i32.add + local.tee 1 + local.get 1 + f64.load + local.tee 12 + local.get 11 + f64.mul + local.get 8 + local.get 0 + local.get 4 + i32.add + local.tee 0 + f64.load + local.tee 8 + f64.mul + f64.add + f64.store + local.get 0 + local.get 12 + local.get 9 + f64.mul + local.get 10 + local.get 8 + f64.mul + f64.add + f64.store + return + end + local.get 10 + f64.const 0x0p+0 (;=0;) + f64.eq + if ;; label = @3 + local.get 7 + f64.load offset=16 + local.set 10 + local.get 7 + f64.load offset=24 + local.set 9 + local.get 0 + i32.const 1 + i32.ne + if ;; label = @4 + local.get 0 + i32.const 2147483646 + i32.and + local.set 5 + i32.const 0 + local.set 6 + loop ;; label = @5 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 14 + f64.load + local.tee 11 + f64.add + f64.store + local.get 7 + local.get 8 + local.get 11 + local.get 10 + f64.mul + f64.add + f64.store + local.get 1 + local.get 2 + local.get 3 + i32.add + local.tee 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 14 + f64.load + local.tee 11 + f64.add + f64.store + local.get 7 + local.get 8 + local.get 11 + local.get 10 + f64.mul + f64.add + f64.store + local.get 2 + local.get 3 + i32.add + local.set 3 + local.get 6 + i32.const 2 + i32.add + local.tee 6 + local.get 5 + i32.ne + br_if 0 (;@5;) + end + end + local.get 0 + i32.const 1 + i32.and + i32.eqz + br_if 2 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 0 + i32.add + local.tee 1 + local.get 0 + local.get 4 + i32.add + local.tee 0 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 1 + f64.load + local.tee 9 + f64.add + f64.store + local.get 0 + local.get 8 + local.get 9 + local.get 10 + f64.mul + f64.add + f64.store + return + end + local.get 7 + f64.load offset=32 + local.set 10 + local.get 7 + f64.load offset=8 + local.set 9 + local.get 0 + i32.const 1 + i32.ne + if ;; label = @3 + local.get 0 + i32.const 2147483646 + i32.and + local.set 5 + i32.const 0 + local.set 6 + loop ;; label = @4 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 11 + f64.add + f64.store + local.get 7 + local.get 11 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + local.get 1 + local.get 2 + local.get 3 + i32.add + local.tee 3 + i32.const 3 + i32.shl + local.tee 7 + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 4 + local.get 7 + i32.add + local.tee 7 + f64.load + local.tee 11 + f64.add + f64.store + local.get 7 + local.get 11 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + local.get 2 + local.get 3 + i32.add + local.set 3 + local.get 6 + i32.const 2 + i32.add + local.tee 6 + local.get 5 + i32.ne + br_if 0 (;@4;) + end + end + local.get 0 + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 0 + i32.add + local.tee 1 + local.get 1 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 0 + local.get 4 + i32.add + local.tee 0 + f64.load + local.tee 9 + f64.add + f64.store + local.get 0 + local.get 9 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + return + end + local.get 10 + f64.const 0x0p+0 (;=0;) + f64.lt + if ;; label = @2 + local.get 7 + f64.load offset=32 + local.set 10 + local.get 7 + f64.load offset=16 + local.set 9 + local.get 7 + f64.load offset=24 + local.set 8 + local.get 7 + f64.load offset=8 + local.set 11 + i32.const 0 + local.set 7 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 12 + local.get 11 + f64.mul + local.get 8 + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 14 + f64.load + local.tee 13 + f64.mul + f64.add + f64.store + local.get 14 + local.get 12 + local.get 9 + f64.mul + local.get 10 + local.get 13 + f64.mul + f64.add + f64.store + local.get 5 + local.get 6 + i32.add + local.set 6 + local.get 2 + local.get 3 + i32.add + local.set 3 + local.get 7 + i32.const 1 + i32.add + local.tee 7 + local.get 0 + i32.ne + br_if 0 (;@3;) + end + br 1 (;@1;) + end + local.get 10 + f64.const 0x0p+0 (;=0;) + f64.eq + if ;; label = @2 + local.get 7 + f64.load offset=16 + local.set 10 + local.get 7 + f64.load offset=24 + local.set 9 + local.get 0 + i32.const 1 + i32.ne + if ;; label = @3 + local.get 0 + i32.const 2147483646 + i32.and + local.set 14 + local.get 5 + local.get 5 + i32.add + local.set 16 + local.get 2 + local.get 2 + i32.add + local.set 17 + i32.const 0 + local.set 7 + loop ;; label = @4 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 15 + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 18 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 15 + f64.load + local.tee 11 + f64.add + f64.store + local.get 18 + local.get 8 + local.get 11 + local.get 10 + f64.mul + f64.add + f64.store + local.get 1 + local.get 2 + local.get 3 + i32.add + i32.const 3 + i32.shl + i32.add + local.tee 15 + local.get 4 + local.get 5 + local.get 6 + i32.add + i32.const 3 + i32.shl + i32.add + local.tee 18 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 15 + f64.load + local.tee 11 + f64.add + f64.store + local.get 18 + local.get 8 + local.get 11 + local.get 10 + f64.mul + f64.add + f64.store + local.get 6 + local.get 16 + i32.add + local.set 6 + local.get 3 + local.get 17 + i32.add + local.set 3 + local.get 7 + i32.const 2 + i32.add + local.tee 7 + local.get 14 + i32.ne + br_if 0 (;@4;) + end + end + local.get 0 + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 0 + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 1 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 0 + f64.load + local.tee 9 + f64.add + f64.store + local.get 1 + local.get 8 + local.get 9 + local.get 10 + f64.mul + f64.add + f64.store + return + end + local.get 7 + f64.load offset=32 + local.set 10 + local.get 7 + f64.load offset=8 + local.set 9 + local.get 0 + i32.const 1 + i32.ne + if ;; label = @2 + local.get 0 + i32.const 2147483646 + i32.and + local.set 14 + local.get 5 + local.get 5 + i32.add + local.set 16 + local.get 2 + local.get 2 + i32.add + local.set 17 + i32.const 0 + local.set 7 + loop ;; label = @3 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 15 + local.get 15 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 15 + f64.load + local.tee 11 + f64.add + f64.store + local.get 15 + local.get 11 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + local.get 1 + local.get 2 + local.get 3 + i32.add + i32.const 3 + i32.shl + i32.add + local.tee 15 + local.get 15 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 4 + local.get 5 + local.get 6 + i32.add + i32.const 3 + i32.shl + i32.add + local.tee 15 + f64.load + local.tee 11 + f64.add + f64.store + local.get 15 + local.get 11 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + local.get 6 + local.get 16 + i32.add + local.set 6 + local.get 3 + local.get 17 + i32.add + local.set 3 + local.get 7 + i32.const 2 + i32.add + local.tee 7 + local.get 14 + i32.ne + br_if 0 (;@3;) + end + end + local.get 0 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 0 + local.get 0 + f64.load + local.tee 8 + local.get 9 + f64.mul + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 0 + f64.load + local.tee 9 + f64.add + f64.store + local.get 0 + local.get 9 + local.get 10 + f64.mul + local.get 8 + f64.sub + f64.store + end) + (export "__wasm_call_ctors" (func 0)) + (export "__wasm_apply_data_relocs" (func 0)) + (export "c_drotm" (func 1)) + (export "c_drotm_ndarray" (func 2))) diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.js new file mode 100644 index 000000000000..6e2c9ba1e610 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.js @@ -0,0 +1,53 @@ +/** +* @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 tape = require( 'tape' ); +var drotm = require( './../lib' ); + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotm, 'object', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `main` method', function test( t ) { + t.strictEqual( typeof drotm.main, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is an `ndarray` method', function test( t ) { + t.strictEqual( typeof drotm.ndarray, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `Module` constructor', function test( t ) { + t.strictEqual( typeof drotm.Module, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the main export is a `Module` instance', function test( t ) { + t.strictEqual( drotm instanceof drotm.Module, true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js new file mode 100644 index 000000000000..5dc3be28eaba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js @@ -0,0 +1,727 @@ +/** +* @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 tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var drotm = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotm, 'object', 'main export is an object' ); + t.end(); +}); + +tape( 'the `main` method has an arity of 6', function test( t ) { + t.strictEqual( drotm.main.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'the `main` method applies a modified Givens plane rotation (sx=1, sy=1)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 2.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 2.8, -1.4, -1.3, 0.9, -0.3, -0.4 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.7, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.7, -0.7, 2.3, -0.6, 0.2, 0.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.main( N[ i ], x, 1, y, 1, param ); + isApprox( t, x, xe[ i ], 5.0 ); + isApprox( t, y, ye[ i ], 5.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `main` method applies a modified Givens plane rotation (sx=2, sy=-2)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + param = [ 1.0, 5.0, 2.0, 0.0, -4.0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.5, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.3, 0.1, -2.0, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.8, 0.1, -3.1, 0.8, 4.8, -0.3, -1.5 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -2.6, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -1.5, -0.9, -1.8, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -1.6, -0.9, -2.1, 0.7, 2.9, 0.2, -3.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.main( N[ i ], x, 2, y, -2, param ); + isApprox( t, x, xe[ i ], 10.0 ); + isApprox( t, y, ye[ i ], 10.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `main` method applies a modified Givens plane rotation (sx=-2, sy=1)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.3, 0.1, -2.0, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -1.5, 0.1, -1.4, 0.8, 3.6, -0.3, -1.9 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -0.5, 0.3, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -0.3, 0.9, -0.7, 1.9, -0.6, 0.2, 0.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.main( N[ i ], x, -2, y, 1, param ); + isApprox( t, x, xe[ i ], 10.0 ); + isApprox( t, y, ye[ i ], 10.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `main` method applies a plane rotation (sx=-1, sy=-2)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, -0.8, 1.3, -1.6, 0.9, -0.3, -0.4 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -1.6, 0.2, 2.4 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.main( N[ i ], x, -1, y, -2, param ); + isApprox( t, x, xe[ i ], 4.0 ); + isApprox( t, y, ye[ i ], 4.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `main` method applies a plane rotation', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 3, x, 2, y, 2, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm.main( 2, x, 3, y, 3, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `main` method supports an `x` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, 2, y, 1, param ); + + xe = new Float64Array( [ + -17.0, // 0 + 2.0, + -18.0, // 1 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 13.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, 3, y, 1, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `main` method supports a negative `x` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, -2, y, 1, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 3, x, -2, y, 1, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + t.end(); +}); + +tape( 'the `main` method supports a `y` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 3, x, 1, y, 2, param ); + + xe = new Float64Array( [ + -17.0, // 0 + -22.0, // 1 + -27.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 7.0, + 12.0, // 1 + 9.0, + 16.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, 1, y, 3, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `main` method supports a negative `y` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, 1, y, -2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 3, x, 1, y, -2, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + t.end(); +}); + +tape( 'the `main` method returns a reference to the second input array', function test( t ) { + var param; + var out; + var x; + var y; + + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + out = drotm.main( x.length, x, 1, y, 1, param ); + + t.strictEqual( out, y, 'same reference' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the `main` method leaves both input arrays unchanged', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + + // drotm.main( -1, x, 1, y, 1, param ); + // t.deepEqual( x, xe, 'returns expected value' ); + // t.deepEqual( y, ye, 'returns expected value' ); + + drotm.main( 0, x, 1, y, 1, param ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `main` method supports complex access patterns', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 0.6, // 1 + 0.1, // 0 + -0.5, + 0.8, + 0.9, + -0.3, + -0.4 + ]); + y = new Float64Array([ + 0.5, // 1 + -0.9, + 0.3, // 0 + 0.7, + -0.6, + 0.2, + 0.8 + ]); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.main( 2, x, -1, y, -2, param ); + + xe = new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ); + ye = new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ); + + isApprox( t, x, xe, 5.0 ); + isApprox( t, y, ye, 5.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.js new file mode 100644 index 000000000000..9adcb07e22fa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.js @@ -0,0 +1,154 @@ +/** +* @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 tape = require( 'tape' ); +var Memory = require( '@stdlib/wasm/memory' ); +var ModuleWrapper = require( '@stdlib/wasm/module-wrapper' ); +var Module = require( './../lib' ).Module; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Module, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + t.strictEqual( mod instanceof Module, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor which does not require `new`', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = Module( mem ); // eslint-disable-line new-cap + t.strictEqual( mod instanceof Module, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the module constructor throws an error if provided a first argument which is not a WebAssembly memory instance (new)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return new Module( value ); + }; + } +}); + +tape( 'the module constructor throws an error if provided a first argument which is not a WebAssembly memory instance (no new)', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + return Module( value ); // eslint-disable-line new-cap + }; + } +}); + +tape( 'the module instance returned by the module constructor inherits from a module wrapper', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + + t.strictEqual( mod instanceof ModuleWrapper, true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to a module instance is a `main` method', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + + t.strictEqual( typeof mod.main, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to a module instance is an `ndarray` method', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + + t.strictEqual( typeof mod.ndarray, 'function', 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.main.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.main.js new file mode 100644 index 000000000000..59e7eaadeea0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.main.js @@ -0,0 +1,590 @@ +/** +* @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 node/no-sync */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Memory = require( '@stdlib/wasm/memory' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Module = require( './../lib' ).Module; + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Module, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a module instance has a `main` method which has an arity of 6', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + t.strictEqual( mod.main.length, 6, 'returns expected value' ); + t.end(); +}); + +tape( 'a module instance has a `main` method applies a modified Givens plane rotation (sx=1, sy=1)', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 32; + pp = 64; + + mod.write( xp, new Float64Array( [ 0.6, 0.1, -0.5, 0.8 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9, 0.3, 0.7 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + xe = new Float64Array( [ -0.9, 2.8, -1.4, -1.3 ] ); + ye = new Float64Array( [ 1.7, -0.7, -0.7, 2.3 ] ); + + mod.main( 4, xp, 1, yp, 1, pp ); + + actualX = new Float64Array( 4 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 4 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + // Short datasets: + xp = 0; + yp = 16; + pp = 32; + + mod.write( xp, new Float64Array( [ 0.6, 0.1 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + mod.main( 2, xp, 1, yp, 1, pp ); + + xe = new Float64Array( [ -0.9, 2.8 ] ); + ye = new Float64Array( [ 1.7, -0.7 ] ); + + actualX = new Float64Array( 2 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 2 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method applies a modified Givens plane rotation (sx=2, sy=-2)', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 56; + pp = 112; + + mod.write( xp, new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ) ); + mod.write( pp, new Float64Array( [ 1.0, 5.0, 2.0, 0.0, -4.0 ] ) ); + + xe = new Float64Array( [ 3.8, 0.1, -3.1, 0.8, 4.8, -0.3, -1.5 ] ); + ye = new Float64Array( [ -1.6, -0.9, -2.1, 0.7, 2.9, 0.2, -3.8 ] ); + + mod.main( 4, xp, 2, yp, -2, pp ); + + actualX = new Float64Array( 7 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 7 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports an `x` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.main( 2, xp, 2, yp, 1, pp ); + + xe = new Float64Array( [ + -17.0, // 0 + 2.0, + -18.0, // 1 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 13.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports a negative `x` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.main( 2, xp, -2, yp, 1, pp ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports a `y` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.main( 3, xp, 1, yp, 2, pp ); + + xe = new Float64Array( [ + -17.0, // 0 + -22.0, // 1 + -27.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 7.0, + 12.0, // 1 + 9.0, + 16.0 // 2 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports a negative `y` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.main( 2, xp, 1, yp, -2, pp ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which returns a pointer to the second input array', function test( t ) { + var out; + var mem; + var mod; + var pp; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) ); + mod.write( yp, new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + out = mod.main( 5, xp, 1, yp, 1, pp ); + + t.strictEqual( out, yp, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, a module instance has a `main` method which leaves both the input arrays unchanged', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) ); + mod.write( yp, new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + + mod.main( -1, xp, 1, yp, 1, pp ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + t.deepEqual( actualX, xe, 'returns expected value' ); + t.deepEqual( actualY, ye, 'returns expected value' ); + + mod.main( 0, xp, 1, yp, 1, pp ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + t.deepEqual( actualX, xe, 'returns expected value' ); + t.deepEqual( actualY, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports complex access patterns', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 56; + pp = 112; + + mod.write( xp, new Float64Array([ + 0.6, // 1 + 0.1, // 0 + -0.5, + 0.8, + 0.9, + -0.3, + -0.4 + ])); + mod.write( yp, new Float64Array([ + 0.5, // 1 + -0.9, + 0.3, // 0 + 0.7, + -0.6, + 0.2, + 0.8 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.main( 2, xp, -1, yp, -2, pp ); + + xe = new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ); + ye = new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ); + + actualX = new Float64Array( 7 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 7 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.ndarray.js new file mode 100644 index 000000000000..f220d81e468e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.module.ndarray.js @@ -0,0 +1,698 @@ +/** +* @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 node/no-sync */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Memory = require( '@stdlib/wasm/memory' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Module = require( './../lib' ).Module; + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Module, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which has an arity of 8', function test( t ) { + var mem; + var mod; + + mem = new Memory({ + 'initial': 0 + }); + mod = new Module( mem ); + t.strictEqual( mod.ndarray.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'a module instance has an `ndarray` method applies a modified Givens plane rotation (sx=1, sy=1)', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 32; + pp = 64; + + mod.write( xp, new Float64Array( [ 0.6, 0.1, -0.5, 0.8 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9, 0.3, 0.7 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + xe = new Float64Array( [ -0.9, 2.8, -1.4, -1.3 ] ); + ye = new Float64Array( [ 1.7, -0.7, -0.7, 2.3 ] ); + + mod.ndarray( 4, xp, 1, 0, yp, 1, 0, pp ); + + actualX = new Float64Array( 4 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 4 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + // Short datasets: + xp = 0; + yp = 16; + pp = 32; + + mod.write( xp, new Float64Array( [ 0.6, 0.1 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + mod.ndarray( 2, xp, 1, 0, yp, 1, 0, pp ); + + xe = new Float64Array( [ -0.9, 2.8 ] ); + ye = new Float64Array( [ 1.7, -0.7 ] ); + + actualX = new Float64Array( 2 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 2 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method applies a modified Givens plane rotation (sx=2, sy=-2)', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 56; + pp = 112; + + mod.write( xp, new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ) ); + mod.write( yp, new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ) ); + mod.write( pp, new Float64Array( [ 1.0, 5.0, 2.0, 0.0, -4.0 ] ) ); + + xe = new Float64Array( [ 3.8, 0.1, -3.1, 0.8, 4.8, -0.3, -1.5 ] ); + ye = new Float64Array( [ -1.6, -0.9, -2.1, 0.7, 2.9, 0.2, -3.8 ] ); + + mod.ndarray( 4, xp, 2, 0, yp, -2, 6, pp ); + + actualX = new Float64Array( 7 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 7 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports an `x` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, 2, 0, yp, 1, 0, pp ); + + xe = new Float64Array( [ + -17.0, // 0 + 2.0, + -18.0, // 1 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 13.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a negative `x` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, -2, 2, yp, 1, 0, pp ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports an `x` offset', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, 1, 1, yp, 2, 0, pp ); + + xe = new Float64Array( [ 1.0, -16.0, -21.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 10.0, 7.0, 14.0, 9.0, 10.0 ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a `y` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 3, xp, 1, 0, yp, 2, 0, pp ); + + xe = new Float64Array( [ + -17.0, // 0 + -22.0, // 1 + -27.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 7.0, + 12.0, // 1 + 9.0, + 16.0 // 2 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a negative `y` stride', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ])); + mod.write( pp, new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, 1, 0, yp, -2, 2, pp ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a `y` offset', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ])); + mod.write( yp, new Float64Array([ + 6.0, + 7.0, // 0 + 8.0, + 9.0, // 1 + 10.0 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, 1, 0, yp, 2, 1, pp ); + + xe = new Float64Array( [ -20.0, -25.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 9.0, 8.0, 13.0, 10.0 ] ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which returns a pointer to the second input array', function test( t ) { + var out; + var mem; + var mod; + var pp; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) ); + mod.write( yp, new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + out = mod.ndarray( 5, xp, 1, 0, yp, 1, 0, pp ); + + t.strictEqual( out, yp, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, a module instance has an `ndarray` method which leaves both the input arrays unchanged', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 40; + pp = 80; + + mod.write( xp, new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ) ); + mod.write( yp, new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ) ); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ) ); + + xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + + mod.ndarray( -1, xp, 1, 0, yp, 1, 0, pp ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + t.deepEqual( actualX, xe, 'returns expected value' ); + t.deepEqual( actualY, ye, 'returns expected value' ); + + mod.ndarray( 0, xp, 1, 0, yp, 1, 0, pp ); + + actualX = new Float64Array( 5 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 5 ); + mod.read( yp, actualY ); + + t.deepEqual( actualX, xe, 'returns expected value' ); + t.deepEqual( actualY, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports complex access patterns', function test( t ) { + var actualX; + var actualY; + var mem; + var mod; + var pp; + var xe; + var ye; + var xp; + var yp; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + yp = 56; + pp = 112; + + mod.write( xp, new Float64Array([ + 0.6, // 1 + 0.1, // 0 + -0.5, + 0.8, + 0.9, + -0.3, + -0.4 + ])); + mod.write( yp, new Float64Array([ + 0.5, // 1 + -0.9, + 0.3, // 0 + 0.7, + -0.6, + 0.2, + 0.8 + ])); + mod.write( pp, new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] )); + + mod.ndarray( 2, xp, -1, 1, yp, -2, 2, pp ); + + xe = new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ); + ye = new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ); + + actualX = new Float64Array( 7 ); + mod.read( xp, actualX ); + + actualY = new Float64Array( 7 ); + mod.read( yp, actualY ); + + isApprox( t, actualX, xe, 2.0 ); + isApprox( t, actualY, ye, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js new file mode 100644 index 000000000000..1cb754fe67b4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js @@ -0,0 +1,802 @@ +/** +* @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 tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var drotm = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof drotm, 'object', 'main export is an object' ); + t.end(); +}); + +tape( 'the `ndarray` method has an arity of 8', function test( t ) { + t.strictEqual( drotm.ndarray.length, 8, 'returns expected value' ); + t.end(); +}); + +tape( 'the `ndarray` method applies a modified Givens plane rotation (sx=1, sy=1)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var ox; + var oy; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + ox = [ 0, 0, 0, 0 ]; + oy = [ 0, 0, 0, 0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 2.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 2.8, -1.4, -1.3, 0.9, -0.3, -0.4 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.7, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.7, -0.7, 2.3, -0.6, 0.2, 0.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.ndarray( N[ i ], x, 1, ox[ i ], y, 1, oy[ i ], param ); + isApprox( t, x, xe[ i ], 5.0 ); + isApprox( t, y, ye[ i ], 5.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `ndarray` method applies a modified Givens plane rotation (sx=2, sy=-2)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var ox; + var oy; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + + param = [ 1.0, 5.0, 2.0, 0.0, -4.0 ]; + + ox = [ 0, 0, 0, 0 ]; + oy = [ 0, 0, 2, 6 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.5, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.3, 0.1, -2.0, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.8, 0.1, -3.1, 0.8, 4.8, -0.3, -1.5 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -2.6, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -1.5, -0.9, -1.8, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -1.6, -0.9, -2.1, 0.7, 2.9, 0.2, -3.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.ndarray( N[ i ], x, 2, ox[ i ], y, -2, oy[ i ], param ); + isApprox( t, x, xe[ i ], 10.0 ); + isApprox( t, y, ye[ i ], 10.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `ndarray` method applies a modified Givens plane rotation (sx=-2, sy=1)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var ox; + var oy; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + ox = [ 0, 0, 2, 6 ]; + oy = [ 0, 0, 0, 0 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ 3.3, 0.1, -2.0, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -1.5, 0.1, -1.4, 0.8, 3.6, -0.3, -1.9 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -0.5, 0.3, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ -0.3, 0.9, -0.7, 1.9, -0.6, 0.2, 0.8 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.ndarray( N[ i ], x, -2, ox[ i ], y, 1, oy[ i ], param ); + isApprox( t, x, xe[ i ], 10.0 ); + isApprox( t, y, ye[ i ], 10.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `ndarray` method applies a plane rotation (sx=-1, sy=-2)', function test( t ) { + var param; + var xbuf; + var ybuf; + var out; + var ox; + var oy; + var xe; + var ye; + var N; + var x; + var y; + var i; + + N = [ 0, 1, 2, 4 ]; + + xbuf = [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ]; + ybuf = [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ]; + + param = [ 0.0, 0.0, 2.0, -3.0, 0.0 ]; + + ox = [ 0, 0, 1, 3 ]; + oy = [ 0, 0, 2, 6 ]; + + xe = [ + new Float64Array( [ 0.6, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, 0.1, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ), + new Float64Array( [ -0.9, -0.8, 1.3, -1.6, 0.9, -0.3, -0.4 ] ) + ]; + ye = [ + new Float64Array( [ 0.5, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.3, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ), + new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -1.6, 0.2, 2.4 ] ) + ]; + + for ( i = 0; i < N.length; i++ ) { + x = new Float64Array( xbuf ); + y = new Float64Array( ybuf ); + out = drotm.ndarray( N[ i ], x, -1, ox[ i ], y, -2, oy[ i ], param ); + isApprox( t, x, xe[ i ], 4.0 ); + isApprox( t, y, ye[ i ], 4.0 ); + t.strictEqual( out, y, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the `ndarray` method applies a plane rotation', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 2 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 3, x, 2, 0, y, 2, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + -24.0, // 1 + 4.0, + -30.0 // 2 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 6.0, // 1 + 9.0, + 10.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, 3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 3, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + 6.0, // 0 + 2.0, + 3.0, + 9.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + -1.0, // 0 + 7.0, + 8.0, + -4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `ndarray` method supports an `x` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, // 1 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 2, 0, y, 1, 0, param ); + + xe = new Float64Array( [ + -17.0, // 0 + 2.0, + -18.0, // 1 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 13.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 3.0, + 4.0, // 1 + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 3, 0, y, 1, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + 2.0, + 3.0, + -21.0, // 1 + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 8.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `ndarray` method supports an `x` offset', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, + 2.0, // 0 + 3.0, // 1 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 + ]); + + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 1, 1, y, 2, 0, param ); + + xe = new Float64Array( [ 1.0, -16.0, -21.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 10.0, 7.0, 14.0, 9.0, 10.0 ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 1 + 2.0, + 3.0, // 0 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, + 9.0, + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, -2, 2, y, 1, 0, param ); + + xe = new Float64Array( [ + -21.0, // 1 + 2.0, + -18.0, // 0 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 0 + 2.0, // 1 + 8.0, + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 2 + 2.0, + 3.0, // 1 + 4.0, + 5.0 // 0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, // 1 + 8.0, // 2 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 3, x, -2, 4, y, 1, 0, param ); + + xe = new Float64Array( [ + 8.0, // 2 + 2.0, + 7.0, // 1 + 4.0, + 6.0 // 0 + ] ); + ye = new Float64Array( [ + -5.0, // 0 + -3.0, // 1 + -1.0, // 2 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + t.end(); +}); + +tape( 'the `ndarray` method supports a `y` stride', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 2 + ]); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 3, x, 1, 0, y, 2, 0, param ); + + xe = new Float64Array( [ + -17.0, // 0 + -22.0, // 1 + -27.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 8.0, // 0 + 7.0, + 12.0, // 1 + 9.0, + 16.0 // 2 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 0 + 7.0, + 8.0, + 9.0, // 1 + 10.0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 1, 0, y, 3, 0, param ); + + xe = new Float64Array( [ + -18.0, // 0 + -27.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 2.0, // 0 + 7.0, + 8.0, + 4.0, // 1 + 10.0 + ] ); + + isApprox( t, x, xe, 1.0 ); + isApprox( t, y, ye, 1.0 ); + + t.end(); +}); + +tape( 'the `ndarray` method supports a `y` offset', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, + 7.0, // 0 + 8.0, + 9.0, // 1 + 10.0 + ]); + + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 1, 0, y, 2, 1, param ); + + xe = new Float64Array( [ -20.0, -25.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 9.0, 8.0, 13.0, 10.0 ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 1 + 7.0, + 8.0, // 0 + 9.0, + 10.0 + ]); + param = new Float64Array( [ 1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, 1, 0, y, -2, 2, param ); + + xe = new Float64Array( [ + 8.0, // 0 + 6.0, // 1 + 3.0, + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + -2.0, // 1 + 7.0, + -1.0, // 0 + 9.0, + 10.0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + x = new Float64Array([ + 1.0, // 0 + 2.0, // 1 + 3.0, // 2 + 4.0, + 5.0 + ]); + y = new Float64Array([ + 6.0, // 2 + 7.0, + 8.0, // 1 + 9.0, + 10.0 // 0 + ]); + param = new Float64Array( [ -1.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 3, x, 1, 0, y, -2, 4, param ); + + xe = new Float64Array( [ + -30.0, // 0 + -24.0, // 1 + -18.0, // 2 + 4.0, + 5.0 + ] ); + ye = new Float64Array( [ + 6.0, // 2 + 7.0, + 4.0, // 1 + 9.0, + 2.0 // 0 + ] ); + + isApprox( t, x, xe, 2.0 ); + isApprox( t, y, ye, 2.0 ); + + t.end(); +}); + +tape( 'the `ndarray` method returns a reference to the second input array', function test( t ) { + var param; + var out; + var x; + var y; + + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + out = drotm.ndarray( x.length, x, 1, 0, y, 1, 0, param ); + + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, a module instance has an `ndarray` method which leaves both the input arrays unchanged', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + y = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + + // drotm.ndarray( -1, x, 1, 0, y, 1, 0, param ); + // t.deepEqual( x, xe, 'returns expected value' ); + // t.deepEqual( y, ye, 'returns expected value' ); + + drotm.ndarray( 0, x, 1, 0, y, 1, 0, param ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `ndarray` method supports complex access patterns', function test( t ) { + var param; + var xe; + var ye; + var x; + var y; + + x = new Float64Array([ + 0.6, // 1 + 0.1, // 0 + -0.5, + 0.8, + 0.9, + -0.3, + -0.4 + ]); + y = new Float64Array([ + 0.5, // 1 + -0.9, + 0.3, // 0 + 0.7, + -0.6, + 0.2, + 0.8 + ]); + param = new Float64Array( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + + drotm.ndarray( 2, x, -1, 1, y, -2, 2, param ); + + xe = new Float64Array( [ -0.9, -0.8, -0.5, 0.8, 0.9, -0.3, -0.4 ] ); + ye = new Float64Array( [ 1.7, -0.9, 0.5, 0.7, -0.6, 0.2, 0.8 ] ); + + isApprox( t, x, xe, 5.0 ); + isApprox( t, y, ye, 5.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.routine.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.routine.js new file mode 100644 index 000000000000..56a4b67daaf0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.routine.js @@ -0,0 +1,71 @@ +/** +* @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 tape = require( 'tape' ); +var ModuleWrapper = require( '@stdlib/wasm/module-wrapper' ); +var Module = require( './../lib/module.js' ); +var Routine = require( './../lib/routine.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof Routine, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor', function test( t ) { + var mod = new Routine(); + t.strictEqual( mod instanceof Routine, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function is a constructor which does not require `new`', function test( t ) { + var mod = Routine(); // eslint-disable-line new-cap + t.strictEqual( mod instanceof Routine, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the module instance returned by the constructor inherits from a module wrapper', function test( t ) { + var mod = new Routine(); + t.strictEqual( mod instanceof ModuleWrapper, true, 'returns expected value' ); + t.end(); +}); + +tape( 'the module instance returned by the constructor inherits from a BLAS routine module', function test( t ) { + var mod = new Routine(); + t.strictEqual( mod instanceof Module, true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to a module instance is a `main` method', function test( t ) { + var mod = new Routine(); + t.strictEqual( typeof mod.main, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to a module instance is an `ndarray` method', function test( t ) { + var mod = new Routine(); + t.strictEqual( typeof mod.ndarray, 'function', 'returns expected value' ); + t.end(); +}); From 131446e1ba3e3c34381fb90995436eea42f9ffad Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 5 Nov 2024 15:40:55 +0530 Subject: [PATCH 2/5] refactor: updated strided2object --- .../@stdlib/blas/base/drotm-wasm/test/test.main.js | 6 +++--- .../@stdlib/blas/base/drotm-wasm/test/test.ndarray.js | 6 +++--- .../@stdlib/strided/base/strided2object/lib/main.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js index 5dc3be28eaba..4cd909ae17a5 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.main.js @@ -677,9 +677,9 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the `main` method xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); - // drotm.main( -1, x, 1, y, 1, param ); - // t.deepEqual( x, xe, 'returns expected value' ); - // t.deepEqual( y, ye, 'returns expected value' ); + drotm.main( -1, x, 1, y, 1, param ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); drotm.main( 0, x, 1, y, 1, param ); t.deepEqual( x, xe, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js index 1cb754fe67b4..c1a200c0d2e8 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/test/test.ndarray.js @@ -752,9 +752,9 @@ tape( 'if provided an `N` parameter less than or equal to `0`, a module instance xe = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); ye = new Float64Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); - // drotm.ndarray( -1, x, 1, 0, y, 1, 0, param ); - // t.deepEqual( x, xe, 'returns expected value' ); - // t.deepEqual( y, ye, 'returns expected value' ); + drotm.ndarray( -1, x, 1, 0, y, 1, 0, param ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); drotm.ndarray( 0, x, 1, 0, y, 1, 0, param ); t.deepEqual( x, xe, 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/strided/base/strided2object/lib/main.js b/lib/node_modules/@stdlib/strided/base/strided2object/lib/main.js index 8c96d6c6774e..4704abbc9674 100644 --- a/lib/node_modules/@stdlib/strided/base/strided2object/lib/main.js +++ b/lib/node_modules/@stdlib/strided/base/strided2object/lib/main.js @@ -73,7 +73,7 @@ var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); */ function strided2object( N, x, stride, offset ) { var obj = arraylike2object( x ); - obj.length = N; + obj.length = ( N > 0 ) ? N : 0; obj.stride = stride; obj.offset = offset; return obj; From 83ba8fec828e172f1eeb1cd3f940ac4c5ad8b1c0 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 5 Nov 2024 15:49:40 +0530 Subject: [PATCH 3/5] chore: apply review changes --- .../base/drotm-wasm/lib/binary.browser.js | 2 +- .../@stdlib/blas/base/drotm-wasm/src/Makefile | 21 +- .../blas/base/drotm-wasm/src/exports.json | 4 + .../blas/base/drotm-wasm/src/main.wasm | Bin 1668 -> 960 bytes .../@stdlib/blas/base/drotm-wasm/src/main.wat | 852 +++++------------- 5 files changed, 256 insertions(+), 623 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/drotm-wasm/src/exports.json diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js index 4fff4a05bc53..861bd3a5e1c4 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/binary.browser.js @@ -25,7 +25,7 @@ var base64ToUint8Array = require( '@stdlib/string/base/base64-to-uint8array' ); // MAIN // -var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEYA2AAAGAGf39/f39/AGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBAMAAQIHTAQRX193YXNtX2NhbGxfY3RvcnMAABhfX3dhc21fYXBwbHlfZGF0YV9yZWxvY3MAAAdjX2Ryb3RtAAEPY19kcm90bV9uZGFycmF5AAIK6QsDAwABCz0BAn4gACABIAIgAqwiBkIBIACsIgd9fkIAIAZCAFcbpyADIAQgBKwiBkIBIAd9fkIAIAZCAFcbpyAFEAILpAsCBnwFfwJAIABBAEwNACAHKwMAIgpEAAAAAAAAAMBhDQACQCACQQBMDQAgAiAFRw0AIApEAAAAAAAAAABjBEAgBysDICEKIAcrAxAhCSAHKwMYIQggBysDCCELIABBAUcEQCAAQf7///8HcSEFQQAhBgNAIAEgA0EDdCIHaiIOIA4rAwAiDCALoiAIIAQgB2oiBysDACINoqA5AwAgByAMIAmiIAogDaKgOQMAIAEgAiADaiIDQQN0IgdqIg4gDisDACIMIAuiIAggBCAHaiIHKwMAIg2ioDkDACAHIAwgCaIgCiANoqA5AwAgAiADaiEDIAZBAmoiBiAFRw0ACwsgAEEBcUUNAiABIANBA3QiAGoiASABKwMAIgwgC6IgCCAAIARqIgArAwAiCKKgOQMAIAAgDCAJoiAKIAiioDkDAA8LIApEAAAAAAAAAABhBEAgBysDECEKIAcrAxghCSAAQQFHBEAgAEH+////B3EhBUEAIQYDQCABIANBA3QiB2oiDiAEIAdqIgcrAwAiCCAJoiAOKwMAIgugOQMAIAcgCCALIAqioDkDACABIAIgA2oiA0EDdCIHaiIOIAQgB2oiBysDACIIIAmiIA4rAwAiC6A5AwAgByAIIAsgCqKgOQMAIAIgA2ohAyAGQQJqIgYgBUcNAAsLIABBAXFFDQIgASADQQN0IgBqIgEgACAEaiIAKwMAIgggCaIgASsDACIJoDkDACAAIAggCSAKoqA5AwAPCyAHKwMgIQogBysDCCEJIABBAUcEQCAAQf7///8HcSEFQQAhBgNAIAEgA0EDdCIHaiIOIA4rAwAiCCAJoiAEIAdqIgcrAwAiC6A5AwAgByALIAqiIAihOQMAIAEgAiADaiIDQQN0IgdqIg4gDisDACIIIAmiIAQgB2oiBysDACILoDkDACAHIAsgCqIgCKE5AwAgAiADaiEDIAZBAmoiBiAFRw0ACwsgAEEBcUUNASABIANBA3QiAGoiASABKwMAIgggCaIgACAEaiIAKwMAIgmgOQMAIAAgCSAKoiAIoTkDAA8LIApEAAAAAAAAAABjBEAgBysDICEKIAcrAxAhCSAHKwMYIQggBysDCCELQQAhBwNAIAEgA0EDdGoiDiAOKwMAIgwgC6IgCCAEIAZBA3RqIg4rAwAiDaKgOQMAIA4gDCAJoiAKIA2ioDkDACAFIAZqIQYgAiADaiEDIAdBAWoiByAARw0ACwwBCyAKRAAAAAAAAAAAYQRAIAcrAxAhCiAHKwMYIQkgAEEBRwRAIABB/v///wdxIQ4gBSAFaiEQIAIgAmohEUEAIQcDQCABIANBA3RqIg8gBCAGQQN0aiISKwMAIgggCaIgDysDACILoDkDACASIAggCyAKoqA5AwAgASACIANqQQN0aiIPIAQgBSAGakEDdGoiEisDACIIIAmiIA8rAwAiC6A5AwAgEiAIIAsgCqKgOQMAIAYgEGohBiADIBFqIQMgB0ECaiIHIA5HDQALCyAAQQFxRQ0BIAEgA0EDdGoiACAEIAZBA3RqIgErAwAiCCAJoiAAKwMAIgmgOQMAIAEgCCAJIAqioDkDAA8LIAcrAyAhCiAHKwMIIQkgAEEBRwRAIABB/v///wdxIQ4gBSAFaiEQIAIgAmohEUEAIQcDQCABIANBA3RqIg8gDysDACIIIAmiIAQgBkEDdGoiDysDACILoDkDACAPIAsgCqIgCKE5AwAgASACIANqQQN0aiIPIA8rAwAiCCAJoiAEIAUgBmpBA3RqIg8rAwAiC6A5AwAgDyALIAqiIAihOQMAIAYgEGohBiADIBFqIQMgB0ECaiIHIA5HDQALCyAAQQFxRQ0AIAEgA0EDdGoiACAAKwMAIgggCaIgBCAGQQN0aiIAKwMAIgmgOQMAIAAgCSAKoiAIoTkDAAsL' ); +var wasm = base64ToUint8Array( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEYA2AAAGAGf39/f39/AGAIf39/f39/f38AAg8BA2VudgZtZW1vcnkCAAADBAMAAQIHTAQRX193YXNtX2NhbGxfY3RvcnMAABhfX3dhc21fYXBwbHlfZGF0YV9yZWxvY3MAAAdjX2Ryb3RtAAEPY19kcm90bV9uZGFycmF5AAIKpQYDAwABCy8AIAAgASACQQEgAGsiACACbEEAIAJBAEwbIAMgBCAAIARsQQAgBEEATBsgBRACC+4FAgZ8An8CQCAAQQBMDQAgBysDACIIRAAAAAAAAADAYQ0AIAIgBUcgAkEATHJFBEAgCEQAAAAAAAAAAGMEQCAHKwMgIQggBysDECEJIAcrAxghCiAHKwMIIQtBACEGA0AgACAGRg0DIAEgA0EDdCIFaiIHIAcrAwAiDCALoiAKIAQgBWoiBSsDACINoqA5AwAgBSAMIAmiIAggDaKgOQMAIAZBAWohBiACIANqIQMMAAsACyAIRAAAAAAAAAAAYQRAIAcrAxAhCCAHKwMYIQlBACEGA0AgACAGRg0DIAEgA0EDdCIFaiIHIAQgBWoiBSsDACIKIAmiIAcrAwAiC6A5AwAgBSAKIAsgCKKgOQMAIAZBAWohBiACIANqIQMMAAsACyAHKwMgIQggBysDCCEJQQAhBgNAIAAgBkYNAiABIANBA3QiBWoiByAHKwMAIgogCaIgBCAFaiIFKwMAIgugOQMAIAUgCyAIoiAKoTkDACAGQQFqIQYgAiADaiEDDAALAAsgCEQAAAAAAAAAAGMEQCAHKwMgIQggBysDECEJIAcrAxghCiAHKwMIIQtBACEHA0AgACAHRg0CIAEgA0EDdGoiDiAOKwMAIgwgC6IgCiAEIAZBA3RqIg4rAwAiDaKgOQMAIA4gDCAJoiAIIA2ioDkDACAHQQFqIQcgBSAGaiEGIAIgA2ohAwwACwALIAhEAAAAAAAAAABhBEAgBysDECEIIAcrAxghCUEAIQcDQCAAIAdGDQIgASADQQN0aiIOIAQgBkEDdGoiDysDACIKIAmiIA4rAwAiC6A5AwAgDyAKIAsgCKKgOQMAIAdBAWohByAFIAZqIQYgAiADaiEDDAALAAsgBysDICEIIAcrAwghCUEAIQcDQCAAIAdGDQEgASADQQN0aiIOIA4rAwAiCiAJoiAEIAZBA3RqIg4rAwAiC6A5AwAgDiALIAiiIAqhOQMAIAdBAWohByAFIAZqIQYgAiADaiEDDAALAAsL' ); // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile index 77377aee65fa..eb51121eec4c 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/Makefile @@ -80,26 +80,37 @@ 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=int32_t + -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 WASM_BIGINT=0 \ - -s EXPORTED_FUNCTIONS="['_c_drotm','_c_drotm_ndarray']" + -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=1 \ + -s WASM_BIGINT=0 # List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): INCLUDE ?= @@ -217,7 +228,7 @@ $(browser_js_targets): $(wasm_targets) # make clean-wasm #/ clean-wasm: - $(QUIET) -rm -f *.wasm *.wat *.wasm.js + $(QUIET) -rm -f *.wasm *.wat *.wasm.js $(browser_js_targets) .PHONY: clean-wasm diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/exports.json b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/exports.json new file mode 100644 index 000000000000..32b4ba13dbab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/exports.json @@ -0,0 +1,4 @@ +[ + "_c_drotm", + "_c_drotm_ndarray" +] diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wasm b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wasm index 2e8c28b45eef9e0318551270934f2ea447eb2422..93aeaf8fa91bfefd1786fc6d758d8a8f41abf672 100755 GIT binary patch literal 960 zcmb7>O>V+45QWEf;)DbU-63@|$+lA4ZFh~-(hYYAR>GnXeiTqEq)J?+Me03zqMo5+ zCxoBE0xx3wjrG2n7f_1{16qNbt@79D`1YPz`p&vy05FhivtZzshxHnGz{GI+CMUzm ztXOdXVF_T|>04Jx@=kt9s`5NZm$PC4(5*BzpXaM2Q%jW;!+e%f$w`x}m@Oy3g6fn^ zGgTC71>F0Vf?WMOKtP5(W(ea5kmoUdV(4F^K#OXY7Azy!9q#|yTz>F1e?%ay1?b!e zh}l&nVqvsg9dh3J@y>&xRZ*J(v5K2M5D0?kIJ&9N>BYPA% zx(-nj{SA856G^rfTAR-Y0cc|r8yj@7y33f2LP<@CQ7D?=gTL2;DqHB3Ep)@idFT%0 zX@Ap$UlBbd(-MCIM^CF6-9rHXKb7&`p|${RkKUJ_?*!nINF5WY(`#+vqo|GTgFqz( zP3m5z?W0T`ovA}n%gdrY3Abn@4Gc8U%x}=;=mGuWI@|Nu`dZ Krpov%$o~T^T8vEq literal 1668 zcmbW1&2G~`6ov21_%E3xPP&T3=Gt2%#Fhn89f7*(o~2_YSzz+hx)CT6G_L{?5}Q5* zuft0a?wzp{rx7H@8+&Ga$LG7}j3K+537{(s#;fW3`G*%Tg~MafS3`iIw>B3H1N*RE zgA9e5%s+aw$!t-qB!F@h2vK7eYFRf@-{aVO-1QaMyKE&QYAUwqWm-_*rH-LA~exO1J z9lLZe?{=mBuBG?cUCT>^1g_hF{&NL!^9|VRXVwN1Jcd)}BY@yy@KssrPY9VfKzP?hV z23y$JU=zzRQ>r}v&uXrX6ncrwW6!W?qw)4_TUMGNj|GaFCO{{TfhPj12`Wu?9O_y_ zGTV@@ZAhOQa!w2O*a6d;j_8sYy0fussI0?up<#3YnbRnB5HML(dLEpK zXqXJ$UUY@XfEavZzmE{ltosKdxoOk3ch>0G!&Zn4XmuQTdLrZ$X@3{#<3M{9begSY zx>Mz+%(RPM9(g9%6iz=8bOaFSpy`%)TDCgqqMJuu{uSg=?~$^Qj+a$)VbaVNhx}xH zxFCxkMa@X(GL~otrz<_|GL6C>A2pwknvWf(sg7D@2%V~(A`>-h3oEjYh^K_^6uTiU q18BQYV-F4aK?Y0qdfBcEf2%yr&I#wA7qi=c3cFDGVrGuhsP!M5lL@i_ diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat index eee6bfcb0481..ccb75590f7be 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/src/main.wat @@ -22,44 +22,34 @@ (func (;0;) (type 0) nop) (func (;1;) (type 1) (param i32 i32 i32 i32 i32 i32) - (local i64 i64) local.get 0 local.get 1 local.get 2 - local.get 2 - i64.extend_i32_s - local.tee 6 - i64.const 1 + i32.const 1 local.get 0 - i64.extend_i32_s - local.tee 7 - i64.sub - i64.mul - i64.const 0 - local.get 6 - i64.const 0 - i64.le_s + i32.sub + local.tee 0 + local.get 2 + i32.mul + i32.const 0 + local.get 2 + i32.const 0 + i32.le_s select - i32.wrap_i64 local.get 3 local.get 4 + local.get 0 + local.get 4 + i32.mul + i32.const 0 local.get 4 - i64.extend_i32_s - local.tee 6 - i64.const 1 - local.get 7 - i64.sub - i64.mul - i64.const 0 - local.get 6 - i64.const 0 - i64.le_s + i32.const 0 + i32.le_s select - i32.wrap_i64 local.get 5 call 2) (func (;2;) (type 2) (param i32 i32 i32 i32 i32 i32 i32 i32) - (local f64 f64 f64 f64 f64 f64 i32 i32 i32 i32 i32) + (local f64 f64 f64 f64 f64 f64 i32 i32) block ;; label = @1 local.get 0 i32.const 0 @@ -67,427 +57,216 @@ br_if 0 (;@1;) local.get 7 f64.load - local.tee 10 + local.tee 8 f64.const -0x1p+1 (;=-2;) f64.eq br_if 0 (;@1;) - block ;; label = @2 - local.get 2 - i32.const 0 - i32.le_s - br_if 0 (;@2;) - local.get 2 - local.get 5 - i32.ne - br_if 0 (;@2;) - local.get 10 + local.get 2 + local.get 5 + i32.ne + local.get 2 + i32.const 0 + i32.le_s + i32.or + i32.eqz + if ;; label = @2 + local.get 8 f64.const 0x0p+0 (;=0;) f64.lt if ;; label = @3 local.get 7 f64.load offset=32 - local.set 10 + local.set 8 local.get 7 f64.load offset=16 local.set 9 local.get 7 f64.load offset=24 - local.set 8 + local.set 10 local.get 7 f64.load offset=8 local.set 11 - local.get 0 - i32.const 1 - i32.ne - if ;; label = @4 - local.get 0 - i32.const 2147483646 - i32.and - local.set 5 - i32.const 0 - local.set 6 - loop ;; label = @5 - local.get 1 - local.get 3 - i32.const 3 - i32.shl - local.tee 7 - i32.add - local.tee 14 - local.get 14 - f64.load - local.tee 12 - local.get 11 - f64.mul - local.get 8 - local.get 4 - local.get 7 - i32.add - local.tee 7 - f64.load - local.tee 13 - f64.mul - f64.add - f64.store - local.get 7 - local.get 12 - local.get 9 - f64.mul - local.get 10 - local.get 13 - f64.mul - f64.add - f64.store - local.get 1 - local.get 2 - local.get 3 - i32.add - local.tee 3 - i32.const 3 - i32.shl - local.tee 7 - i32.add - local.tee 14 - local.get 14 - f64.load - local.tee 12 - local.get 11 - f64.mul - local.get 8 - local.get 4 - local.get 7 - i32.add - local.tee 7 - f64.load - local.tee 13 - f64.mul - f64.add - f64.store - local.get 7 - local.get 12 - local.get 9 - f64.mul - local.get 10 - local.get 13 - f64.mul - f64.add - f64.store - local.get 2 - local.get 3 - i32.add - local.set 3 - local.get 6 - i32.const 2 - i32.add - local.tee 6 - local.get 5 - i32.ne - br_if 0 (;@5;) - end - end - local.get 0 - i32.const 1 - i32.and - i32.eqz - br_if 2 (;@1;) - local.get 1 - local.get 3 - i32.const 3 - i32.shl - local.tee 0 - i32.add - local.tee 1 - local.get 1 - f64.load - local.tee 12 - local.get 11 - f64.mul - local.get 8 - local.get 0 - local.get 4 - i32.add - local.tee 0 - f64.load - local.tee 8 - f64.mul - f64.add - f64.store - local.get 0 - local.get 12 - local.get 9 - f64.mul - local.get 10 - local.get 8 - f64.mul - f64.add - f64.store - return - end - local.get 10 - f64.const 0x0p+0 (;=0;) - f64.eq - if ;; label = @3 - local.get 7 - f64.load offset=16 - local.set 10 - local.get 7 - f64.load offset=24 - local.set 9 - local.get 0 - i32.const 1 - i32.ne - if ;; label = @4 - local.get 0 - i32.const 2147483646 - i32.and - local.set 5 - i32.const 0 - local.set 6 - loop ;; label = @5 - local.get 1 - local.get 3 - i32.const 3 - i32.shl - local.tee 7 - i32.add - local.tee 14 - local.get 4 - local.get 7 - i32.add - local.tee 7 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 14 - f64.load - local.tee 11 - f64.add - f64.store - local.get 7 - local.get 8 - local.get 11 - local.get 10 - f64.mul - f64.add - f64.store - local.get 1 - local.get 2 - local.get 3 - i32.add - local.tee 3 - i32.const 3 - i32.shl - local.tee 7 - i32.add - local.tee 14 - local.get 4 - local.get 7 - i32.add - local.tee 7 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 14 - f64.load - local.tee 11 - f64.add - f64.store - local.get 7 - local.get 8 - local.get 11 - local.get 10 - f64.mul - f64.add - f64.store - local.get 2 - local.get 3 - i32.add - local.set 3 - local.get 6 - i32.const 2 - i32.add - local.tee 6 - local.get 5 - i32.ne - br_if 0 (;@5;) - end - end - local.get 0 - i32.const 1 - i32.and - i32.eqz - br_if 2 (;@1;) - local.get 1 - local.get 3 - i32.const 3 - i32.shl - local.tee 0 - i32.add - local.tee 1 - local.get 0 - local.get 4 - i32.add - local.tee 0 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 1 - f64.load - local.tee 9 - f64.add - f64.store - local.get 0 - local.get 8 - local.get 9 - local.get 10 - f64.mul - f64.add - f64.store - return - end - local.get 7 - f64.load offset=32 - local.set 10 - local.get 7 - f64.load offset=8 - local.set 9 - local.get 0 - i32.const 1 - i32.ne - if ;; label = @3 - local.get 0 - i32.const 2147483646 - i32.and - local.set 5 i32.const 0 local.set 6 loop ;; label = @4 + local.get 0 + local.get 6 + i32.eq + br_if 3 (;@1;) local.get 1 local.get 3 i32.const 3 i32.shl - local.tee 7 + local.tee 5 i32.add - local.tee 14 - local.get 14 + local.tee 7 + local.get 7 f64.load - local.tee 8 - local.get 9 + local.tee 12 + local.get 11 f64.mul + local.get 10 local.get 4 - local.get 7 + local.get 5 i32.add - local.tee 7 + local.tee 5 f64.load - local.tee 11 + local.tee 13 + f64.mul f64.add f64.store - local.get 7 - local.get 11 - local.get 10 + local.get 5 + local.get 12 + local.get 9 f64.mul local.get 8 - f64.sub + local.get 13 + f64.mul + f64.add f64.store - local.get 1 + local.get 6 + i32.const 1 + i32.add + local.set 6 local.get 2 local.get 3 i32.add - local.tee 3 + local.set 3 + br 0 (;@4;) + end + unreachable + end + local.get 8 + f64.const 0x0p+0 (;=0;) + f64.eq + if ;; label = @3 + local.get 7 + f64.load offset=16 + local.set 8 + local.get 7 + f64.load offset=24 + local.set 9 + i32.const 0 + local.set 6 + loop ;; label = @4 + local.get 0 + local.get 6 + i32.eq + br_if 3 (;@1;) + local.get 1 + local.get 3 i32.const 3 i32.shl + local.tee 5 + i32.add local.tee 7 + local.get 4 + local.get 5 i32.add - local.tee 14 - local.get 14 + local.tee 5 f64.load - local.tee 8 + local.tee 10 local.get 9 f64.mul - local.get 4 local.get 7 - i32.add - local.tee 7 f64.load local.tee 11 f64.add f64.store - local.get 7 - local.get 11 + local.get 5 local.get 10 - f64.mul + local.get 11 local.get 8 - f64.sub + f64.mul + f64.add f64.store + local.get 6 + i32.const 1 + i32.add + local.set 6 local.get 2 local.get 3 i32.add local.set 3 - local.get 6 - i32.const 2 - i32.add - local.tee 6 - local.get 5 - i32.ne - br_if 0 (;@4;) + br 0 (;@4;) end + unreachable end - local.get 0 - i32.const 1 - i32.and - i32.eqz - br_if 1 (;@1;) - local.get 1 - local.get 3 - i32.const 3 - i32.shl - local.tee 0 - i32.add - local.tee 1 - local.get 1 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 0 - local.get 4 - i32.add - local.tee 0 - f64.load - local.tee 9 - f64.add - f64.store - local.get 0 - local.get 9 - local.get 10 - f64.mul - local.get 8 - f64.sub - f64.store - return + local.get 7 + f64.load offset=32 + local.set 8 + local.get 7 + f64.load offset=8 + local.set 9 + i32.const 0 + local.set 6 + loop ;; label = @3 + local.get 0 + local.get 6 + i32.eq + br_if 2 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + local.tee 5 + i32.add + local.tee 7 + local.get 7 + f64.load + local.tee 10 + local.get 9 + f64.mul + local.get 4 + local.get 5 + i32.add + local.tee 5 + f64.load + local.tee 11 + f64.add + f64.store + local.get 5 + local.get 11 + local.get 8 + f64.mul + local.get 10 + f64.sub + f64.store + local.get 6 + i32.const 1 + i32.add + local.set 6 + local.get 2 + local.get 3 + i32.add + local.set 3 + br 0 (;@3;) + end + unreachable end - local.get 10 + local.get 8 f64.const 0x0p+0 (;=0;) f64.lt if ;; label = @2 local.get 7 f64.load offset=32 - local.set 10 + local.set 8 local.get 7 f64.load offset=16 local.set 9 local.get 7 f64.load offset=24 - local.set 8 + local.set 10 local.get 7 f64.load offset=8 local.set 11 i32.const 0 local.set 7 loop ;; label = @3 + local.get 0 + local.get 7 + i32.eq + br_if 2 (;@1;) local.get 1 local.get 3 i32.const 3 @@ -499,7 +278,7 @@ local.tee 12 local.get 11 f64.mul - local.get 8 + local.get 10 local.get 4 local.get 6 i32.const 3 @@ -515,11 +294,15 @@ local.get 12 local.get 9 f64.mul - local.get 10 + local.get 8 local.get 13 f64.mul f64.add f64.store + local.get 7 + i32.const 1 + i32.add + local.set 7 local.get 5 local.get 6 i32.add @@ -528,193 +311,33 @@ local.get 3 i32.add local.set 3 - local.get 7 - i32.const 1 - i32.add - local.tee 7 - local.get 0 - i32.ne - br_if 0 (;@3;) + br 0 (;@3;) end - br 1 (;@1;) + unreachable end - local.get 10 + local.get 8 f64.const 0x0p+0 (;=0;) f64.eq if ;; label = @2 local.get 7 f64.load offset=16 - local.set 10 + local.set 8 local.get 7 f64.load offset=24 local.set 9 - local.get 0 - i32.const 1 - i32.ne - if ;; label = @3 - local.get 0 - i32.const 2147483646 - i32.and - local.set 14 - local.get 5 - local.get 5 - i32.add - local.set 16 - local.get 2 - local.get 2 - i32.add - local.set 17 - i32.const 0 - local.set 7 - loop ;; label = @4 - local.get 1 - local.get 3 - i32.const 3 - i32.shl - i32.add - local.tee 15 - local.get 4 - local.get 6 - i32.const 3 - i32.shl - i32.add - local.tee 18 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 15 - f64.load - local.tee 11 - f64.add - f64.store - local.get 18 - local.get 8 - local.get 11 - local.get 10 - f64.mul - f64.add - f64.store - local.get 1 - local.get 2 - local.get 3 - i32.add - i32.const 3 - i32.shl - i32.add - local.tee 15 - local.get 4 - local.get 5 - local.get 6 - i32.add - i32.const 3 - i32.shl - i32.add - local.tee 18 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 15 - f64.load - local.tee 11 - f64.add - f64.store - local.get 18 - local.get 8 - local.get 11 - local.get 10 - f64.mul - f64.add - f64.store - local.get 6 - local.get 16 - i32.add - local.set 6 - local.get 3 - local.get 17 - i32.add - local.set 3 - local.get 7 - i32.const 2 - i32.add - local.tee 7 - local.get 14 - i32.ne - br_if 0 (;@4;) - end - end - local.get 0 - i32.const 1 - i32.and - i32.eqz - br_if 1 (;@1;) - local.get 1 - local.get 3 - i32.const 3 - i32.shl - i32.add - local.tee 0 - local.get 4 - local.get 6 - i32.const 3 - i32.shl - i32.add - local.tee 1 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 0 - f64.load - local.tee 9 - f64.add - f64.store - local.get 1 - local.get 8 - local.get 9 - local.get 10 - f64.mul - f64.add - f64.store - return - end - local.get 7 - f64.load offset=32 - local.set 10 - local.get 7 - f64.load offset=8 - local.set 9 - local.get 0 - i32.const 1 - i32.ne - if ;; label = @2 - local.get 0 - i32.const 2147483646 - i32.and - local.set 14 - local.get 5 - local.get 5 - i32.add - local.set 16 - local.get 2 - local.get 2 - i32.add - local.set 17 i32.const 0 local.set 7 loop ;; label = @3 + local.get 0 + local.get 7 + i32.eq + br_if 2 (;@1;) local.get 1 local.get 3 i32.const 3 i32.shl i32.add - local.tee 15 - local.get 15 - f64.load - local.tee 8 - local.get 9 - f64.mul + local.tee 14 local.get 4 local.get 6 i32.const 3 @@ -722,98 +345,93 @@ i32.add local.tee 15 f64.load - local.tee 11 - f64.add - f64.store - local.get 15 - local.get 11 - local.get 10 - f64.mul - local.get 8 - f64.sub - f64.store - local.get 1 - local.get 2 - local.get 3 - i32.add - i32.const 3 - i32.shl - i32.add - local.tee 15 - local.get 15 - f64.load - local.tee 8 + local.tee 10 local.get 9 f64.mul - local.get 4 - local.get 5 - local.get 6 - i32.add - i32.const 3 - i32.shl - i32.add - local.tee 15 + local.get 14 f64.load local.tee 11 f64.add f64.store local.get 15 - local.get 11 local.get 10 - f64.mul + local.get 11 local.get 8 - f64.sub + f64.mul + f64.add f64.store + local.get 7 + i32.const 1 + i32.add + local.set 7 + local.get 5 local.get 6 - local.get 16 i32.add local.set 6 + local.get 2 local.get 3 - local.get 17 i32.add local.set 3 - local.get 7 - i32.const 2 - i32.add - local.tee 7 - local.get 14 - i32.ne - br_if 0 (;@3;) + br 0 (;@3;) end + unreachable end - local.get 0 - i32.const 1 - i32.and - i32.eqz - br_if 0 (;@1;) - local.get 1 - local.get 3 - i32.const 3 - i32.shl - i32.add - local.tee 0 - local.get 0 - f64.load - local.tee 8 - local.get 9 - f64.mul - local.get 4 - local.get 6 - i32.const 3 - i32.shl - i32.add - local.tee 0 - f64.load - local.tee 9 - f64.add - f64.store - local.get 0 - local.get 9 - local.get 10 - f64.mul - local.get 8 - f64.sub - f64.store + local.get 7 + f64.load offset=32 + local.set 8 + local.get 7 + f64.load offset=8 + local.set 9 + i32.const 0 + local.set 7 + loop ;; label = @2 + local.get 0 + local.get 7 + i32.eq + br_if 1 (;@1;) + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 14 + local.get 14 + f64.load + local.tee 10 + local.get 9 + f64.mul + local.get 4 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.tee 14 + f64.load + local.tee 11 + f64.add + f64.store + local.get 14 + local.get 11 + local.get 8 + f64.mul + local.get 10 + f64.sub + f64.store + local.get 7 + i32.const 1 + i32.add + local.set 7 + local.get 5 + local.get 6 + i32.add + local.set 6 + local.get 2 + local.get 3 + i32.add + local.set 3 + br 0 (;@2;) + end + unreachable end) (export "__wasm_call_ctors" (func 0)) (export "__wasm_apply_data_relocs" (func 0)) From ae124c94bb86937f6adad22ee41d21aeff3a9ca8 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 5 Nov 2024 16:19:44 +0530 Subject: [PATCH 4/5] chore: update examples --- .../@stdlib/blas/base/drotm-wasm/README.md | 12 ++++---- .../blas/base/drotm-wasm/docs/repl.txt | 12 ++++---- .../base/drotm-wasm/docs/types/index.d.ts | 30 +++++++++---------- .../examples/little_endian_arrays.js | 2 +- .../blas/base/drotm-wasm/examples/module.js | 2 +- .../@stdlib/blas/base/drotm-wasm/lib/index.js | 6 ++-- .../blas/base/drotm-wasm/lib/module.js | 18 +++++------ 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md index e0542a24d4d6..b9f184a0b84b 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md @@ -192,7 +192,7 @@ var pptr = 2 * N * bytesPerElement( dtype ); // Write vector values to module memory: mod.write( xptr, oneTo( N, dtype ) ); mod.write( yptr, ones( N, dtype ) ); -mod.write( pptr, zeros( 5, dtype ) ); +mod.write( pptr, ones( 5, dtype ) ); // Perform computation: mod.main( N, xptr, 1, yptr, 1, pptr ); @@ -204,10 +204,10 @@ mod.read( xptr, viewX ); mod.read( yptr, viewY ); console.log( viewX ); -// => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +// => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] console.log( viewY ); -// => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +// => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] ``` The function has the following parameters: @@ -259,7 +259,7 @@ var pptr = 2 * N * bytesPerElement( dtype ); // Write vector values to module memory: mod.write( xptr, oneTo( N, dtype ) ); mod.write( yptr, ones( N, dtype ) ); -mod.write( pptr, zeros( 5, dtype ) ); +mod.write( pptr, ones( 5, dtype ) ); // Perform computation: mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); @@ -271,10 +271,10 @@ mod.read( xptr, viewX ); mod.read( yptr, viewY ); console.log( viewX ); -// => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +// => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] console.log( viewY ); -// => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +// => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] ``` The function has the following additional parameters: diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt index 7c3e4e94ce77..91fe57521692 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt @@ -505,7 +505,7 @@ // Write data to module memory: > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float64' ) ); > mod.write( yptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); - > mod.write( pptr, {{alias:@stdlib/array/zeros}}( 5, 'float64' ) ); + > mod.write( pptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); // Perform computation: > mod.main( 5, xptr, 1, yptr, 1, pptr ); @@ -516,9 +516,9 @@ > mod.read( xptr, viewX ); > mod.read( yptr, viewY ); > viewX - [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + [ 2.0, 3.0, 4.0, 5.0, 6.0 ] > viewY - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + [ 0.0, -1.0, -2.0, -3.0, -4.0 ] {{alias}}.Module.prototype.ndarray( N, xp, sx, ox, yp, sy, oy, pp ) @@ -570,7 +570,7 @@ // Write data to module memory: > mod.write( xptr, {{alias:@stdlib/array/one-to}}( 5, 'float64' ) ); > mod.write( yptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); - > mod.write( pptr, {{alias:@stdlib/array/zeros}}( 5, 'float64' ) ); + > mod.write( pptr, {{alias:@stdlib/array/ones}}( 5, 'float64' ) ); // Perform computation: > mod.ndarray( 5, xptr, 1, 0, yptr, 1, 0, pptr ); @@ -581,9 +581,9 @@ > mod.read( xptr, viewX ); > mod.read( yptr, viewY ); > viewX - [ 1.0, 2.0, 3.0, 4.0, 5.0 ] + [ 2.0, 3.0, 4.0, 5.0, 6.0 ] > viewY - [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + [ 0.0, -1.0, -2.0, -3.0, -4.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts index 5d8dc3d50f09..cffb7a4025dc 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts @@ -66,7 +66,7 @@ interface ModuleConstructor { * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); - * mod.write( pptr, zeros( 5 ) ); + * mod.write( pptr, oneTo( N, dtype ) ); * * // Perform computation: * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); @@ -80,8 +80,8 @@ interface ModuleConstructor { * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] - * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ new( mem: Memory ): Module; // newable @@ -125,7 +125,7 @@ interface ModuleConstructor { * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); - * mod.write( pptr, zeros( 5 ) ); + * mod.write( pptr, oneTo( 5, dtype ) ); * * // Perform computation: * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); @@ -139,8 +139,8 @@ interface ModuleConstructor { * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] - * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ ( mem: Memory ): Module; // callable } @@ -194,7 +194,7 @@ interface Module extends ModuleWrapper { * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); - * mod.write( pptr, zeros( 5 ) ); + * mod.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * var ptr = mod.main( N, xptr, 1, yptr, 1, pptr ); @@ -208,8 +208,8 @@ interface Module extends ModuleWrapper { * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] - * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] + * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ main( N: number, xptr: number, strideX: number, yptr: number, strideY: number, pptr: number ): number; @@ -260,7 +260,7 @@ interface Module extends ModuleWrapper { * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); - * mod.write( pptr, zeros( 5 ) ); + * mod.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * var ptr = mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); @@ -274,8 +274,8 @@ interface Module extends ModuleWrapper { * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] - * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] + * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ ndarray( N: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number, pptr: number ): number; } @@ -374,7 +374,7 @@ interface Routine extends ModuleWrapper { * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); - * mod.write( pptr, zeros( 5 ) ); + * mod.write( pptr, oneTo( 5, dtype ) ); * * // Perform computation: * var ptr = mod.main( N, xptr, 1, yptr, 1, param ); @@ -388,8 +388,8 @@ interface Routine extends ModuleWrapper { * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] - * // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ Module: ModuleConstructor; } diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js index c042da94a976..76d145d2ec51 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/little_endian_arrays.js @@ -64,7 +64,7 @@ function main() { // Write values to module memory: gfillBy( N, x, 1, discreteUniform( -10.0, 10.0 ) ); gfill( N, 1.0, y, 1 ); - gfill( 5, 0.0, param, 1 ); + gfill( 5, 1.0, param, 1 ); // Perform computation: mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js index d744290a8761..b5d6566a2fd8 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/examples/module.js @@ -58,7 +58,7 @@ function main() { // Write vector values to module memory: mod.write( xptr, oneTo( N, dtype ) ); mod.write( yptr, ones( N, dtype ) ); - mod.write( pptr, zeros( 5, dtype ) ); + mod.write( pptr, ones( 5, dtype ) ); // Perform computation: mod.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js index 0b2351028903..5b0264c1e06b 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/index.js @@ -86,7 +86,7 @@ * // Write vector values to module memory: * mod.write( xptr, oneTo( N, dtype ) ); * mod.write( yptr, ones( N, dtype ) ); -* mod.write( pptr, zeros( 5, dtype ) ); +* mod.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * mod.main( N, xptr, 1, yptr, 1, pptr ); @@ -98,10 +98,10 @@ * mod.read( yptr, viewY ); * * console.log( viewX ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] +* // => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] * * console.log( viewY ); -* // => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* // => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js index b4370bcff24c..898fbe4a0d7e 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js @@ -74,7 +74,7 @@ var wasmBinary = require( './binary.js' ); * // Write vector values to module memory: * drotm.write( xptr, oneTo( N, dtype ) ); * drotm.write( yptr, ones( N, dtype ) ); -* drotm.write( pptr, zeros( 5, dtype ) ); +* drotm.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * var ptr = drotm.main( N, xptr, 1, yptr, 1, pptr ); @@ -88,8 +88,8 @@ var wasmBinary = require( './binary.js' ); * var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); * drotm.read( yptr, viewY ); -* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ function Module( memory ) { if ( !( this instanceof Module ) ) { @@ -160,7 +160,7 @@ inherits( Module, WasmModule ); * // Write vector values to module memory: * drotm.write( xptr, oneTo( N, dtype ) ); * drotm.write( yptr, ones( N, dtype ) ); -* drotm.write( pptr, zeros( 5, dtype ) ); +* drotm.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * var ptr = drotm.main( N, xptr, 1, yptr, 1, pptr ); @@ -174,8 +174,8 @@ inherits( Module, WasmModule ); * var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); * drotm.read( yptr, viewY ); -* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, strideY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point this._instance.exports.c_drotm( N, xptr, strideX, yptr, strideY, pptr ); @@ -233,7 +233,7 @@ setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, s * // Write vector values to module memory: * drotm.write( xptr, oneTo( N, dtype ) ); * drotm.write( yptr, ones( N, dtype ) ); -* drotm.write( pptr, zeros( 5, dtype ) ); +* drotm.write( pptr, ones( 5, dtype ) ); * * // Perform computation: * var ptr = drotm.ndarray( N, xptr, 1, 0, yptr, 1, 0, pptr ); @@ -247,8 +247,8 @@ setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, s * var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); * drotm.read( yptr, viewY ); -* // viewX => [ 1.0, 2.0, 3.0, 4.0, 5.0 ] -* // viewY => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ setReadOnly( Module.prototype, 'ndarray', function drotm( N, xptr, strideX, offsetX, yptr, strideY, offsetY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point this._instance.exports.c_drotm_ndarray( N, xptr, strideX, offsetX, yptr, strideY, offsetY, pptr ); // eslint-disable-line max-len From 62269f67358c368ebef9e1a7ec06208b927a3915 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 15 Nov 2024 02:02:25 -0800 Subject: [PATCH 5/5] chore: clean-up --- .../@stdlib/blas/base/drotm-wasm/README.md | 2 +- .../blas/base/drotm-wasm/docs/repl.txt | 2 +- .../base/drotm-wasm/docs/types/index.d.ts | 35 +++++++++++-------- .../blas/base/drotm-wasm/docs/types/test.ts | 2 +- .../blas/base/drotm-wasm/lib/module.js | 15 ++++---- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md index b9f184a0b84b..bda4dcbfb039 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/README.md @@ -292,7 +292,7 @@ The function has the following additional parameters: ## Notes -- If `N <= 0`, both functions leave `x` and `y` unchanged. +- If `N <= 0`, `x` and `y` are left unchanged. - This package implements routines using WebAssembly. When provided arrays which are not allocated on a `drotm` 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/drotm`][@stdlib/blas/base/drotm]. 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/drotm`][@stdlib/blas/base/drotm]. 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. - `drotm()` corresponds to the [BLAS][blas] level 1 function [`drotm`][drotm]. diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt index 91fe57521692..e204d87c7936 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/repl.txt @@ -114,7 +114,7 @@ // Standard Usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); > var y = new {{alias:@stdlib/array/float64}}( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); - > param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); + > var param = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 2.0, -3.0, 0.0 ] ); > {{alias}}.ndarray( 2, x, 1, 0, y, 2, 1, param ); > x [ ~-20.0, ~-25.0, 3.0, 4.0, 5.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts index cffb7a4025dc..fa1a85df9f65 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/index.d.ts @@ -58,7 +58,7 @@ interface ModuleConstructor { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define pointers (i.e., byte offsets) for storing three vectors: * var xptr = 0; * var yptr = N * bytesPerElement( dtype ); * var pptr = 2 * N * bytesPerElement( dtype ); @@ -77,10 +77,11 @@ interface ModuleConstructor { * * // Read out the results: * var viewX = zeros( N, dtype ); + * mod.read( xptr, viewX ); + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * * var viewY = zeros( N, dtype ); - * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ new( mem: Memory ): Module; // newable @@ -117,7 +118,7 @@ interface ModuleConstructor { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define pointers (i.e., byte offsets) for storing three vectors: * var xptr = 0; * var yptr = N * bytesPerElement( dtype ); * var pptr = 2 * N * bytesPerElement( dtype ); @@ -136,10 +137,11 @@ interface ModuleConstructor { * * // Read out the results: * var viewX = zeros( N, dtype ); + * mod.read( xptr, viewX ); + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * * var viewY = zeros( N, dtype ); - * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ ( mem: Memory ): Module; // callable @@ -186,7 +188,7 @@ interface Module extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define pointers (i.e., byte offsets) for storing three vectors: * var xptr = 0; * var yptr = N * bytesPerElement( dtype ); * var pptr = 2 * N * bytesPerElement( dtype ); @@ -205,10 +207,11 @@ interface Module extends ModuleWrapper { * * // Read out the results: * var viewX = zeros( N, dtype ); + * mod.read( xptr, viewX ); + * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] + * * var viewY = zeros( N, dtype ); - * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ main( N: number, xptr: number, strideX: number, yptr: number, strideY: number, pptr: number ): number; @@ -252,7 +255,7 @@ interface Module extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define pointers (i.e., byte offsets) for storing three vectors: * var xptr = 0; * var yptr = N * bytesPerElement( dtype ); * var pptr = 2 * N * bytesPerElement( dtype ); @@ -271,10 +274,11 @@ interface Module extends ModuleWrapper { * * // Read out the results: * var viewX = zeros( N, dtype ); + * mod.read( xptr, viewX ); + * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] + * * var viewY = zeros( N, dtype ); - * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ ndarray( N: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number, pptr: number ): number; @@ -366,7 +370,7 @@ interface Routine extends ModuleWrapper { * // Specify a vector length: * var N = 5; * - * // Define pointers (i.e., byte offsets) for storing two vectors: + * // Define pointers (i.e., byte offsets) for storing three vectors: * var xptr = 0; * var yptr = N * bytesPerElement( dtype ); * var pptr = 2 * N * bytesPerElement( dtype ); @@ -385,10 +389,11 @@ interface Routine extends ModuleWrapper { * * // Read out the results: * var viewX = zeros( N, dtype ); + * mod.read( xptr, viewX ); + * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] + * * var viewY = zeros( N, dtype ); - * mod.read( xptr, viewX ) * mod.read( yptr, viewY ); - * // viewX => [ 3.0, 5.0, 7.0, 9.0, 11.0 ] * // viewY => [ 4.0, 3.0, 2.0, 1.0, 0.0 ] */ Module: ModuleConstructor; diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts index ee555b61b206..fcc044293b15 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/docs/types/test.ts @@ -267,7 +267,7 @@ import drotm = require( './index' ); drotm.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x, param ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a eighth argument which is not a Float64Array... +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a Float64Array... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); diff --git a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js index 898fbe4a0d7e..33655922eed2 100644 --- a/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js +++ b/lib/node_modules/@stdlib/blas/base/drotm-wasm/lib/module.js @@ -85,10 +85,11 @@ var wasmBinary = require( './binary.js' ); * * // Read out the results: * var viewX = zeros( N, dtype ); -* var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); -* drotm.read( yptr, viewY ); * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* +* var viewY = zeros( N, dtype ); +* drotm.read( yptr, viewY ); * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ function Module( memory ) { @@ -171,10 +172,11 @@ inherits( Module, WasmModule ); * * // Read out the results: * var viewX = zeros( N, dtype ); -* var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); -* drotm.read( yptr, viewY ); * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* +* var viewY = zeros( N, dtype ); +* drotm.read( yptr, viewY ); * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, strideY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point @@ -244,10 +246,11 @@ setReadOnly( Module.prototype, 'main', function drotm( N, xptr, strideX, yptr, s * * // Read out the results: * var viewX = zeros( N, dtype ); -* var viewY = zeros( N, dtype ); * drotm.read( xptr, viewX ); -* drotm.read( yptr, viewY ); * // viewX => [ 2.0, 3.0, 4.0, 5.0, 6.0 ] +* +* var viewY = zeros( N, dtype ); +* drotm.read( yptr, viewY ); * // viewY => [ 0.0, -1.0, -2.0, -3.0, -4.0 ] */ setReadOnly( Module.prototype, 'ndarray', function drotm( N, xptr, strideX, offsetX, yptr, strideY, offsetY, pptr ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point