From 7b3aa304bff944368800330e0b400f320ffce85d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 21 Oct 2024 23:44:57 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 3 ++- CONTRIBUTORS | 4 ++++ dist/index.js.map | 2 +- docs/repl.txt | 8 ++++---- docs/types/index.d.ts | 15 ++++++++++----- lib/routine.js | 2 +- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6aa63e..14c18c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@
-## Unreleased (2024-10-03) +## Unreleased (2024-10-21)
@@ -22,6 +22,7 @@
+- [`420e21c`](https://github.com/stdlib-js/stdlib/commit/420e21cbeb53062caad324e14b8ea8ca53d51755) - **docs:** fix examples and notes _(by Athan Reines)_ - [`5d79f98`](https://github.com/stdlib-js/stdlib/commit/5d79f98fcf24be0adf5ab357964d8afaa6707b86) - **feat:** add `blas/base/drot-wasm` [(#2979)](https://github.com/stdlib-js/stdlib/pull/2979) _(by Aman Bhansali, Athan Reines)_
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d74d10f..b211f96 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -28,6 +28,7 @@ EuniceSim142 <77243938+EuniceSim142@users.noreply.github.com> Frank Kovacs Golden Kumar <103646877+AuenKr@users.noreply.github.com> Gunj Joshi +Gururaj Gurram <143020143+gururaj1512@users.noreply.github.com> HarshaNP <96897754+GittyHarsha@users.noreply.github.com> Harshita Kalani Hridyanshu <124202756+HRIDYANSHU054@users.noreply.github.com> @@ -44,6 +45,7 @@ Justin Dennison Kaif Mohd Karthik Prakash <116057817+skoriop@users.noreply.github.com> Khaldon +Kohantika Nath <145763549+kohantikanath@users.noreply.github.com> Krishnendu Das <86651039+itskdhere@users.noreply.github.com> Lovelin <100030865+lovelindhoni@users.noreply.github.com> Manik Sharma @@ -67,6 +69,7 @@ Praneki <97080887+PraneGIT@users.noreply.github.com> Pratik <97464067+Pratik772846@users.noreply.github.com> Priyansh <88396544+itsspriyansh@users.noreply.github.com> Pushpendra Chandravanshi +RISHAV <115060907+rishav2404@users.noreply.github.com> Raunak Kumar Gupta Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Ricky Reusser @@ -94,6 +97,7 @@ Tudor Pagu <104032457+tudor-pagu@users.noreply.github.com> Tufailahmed Bargir <142114244+Tufailahmed-Bargir@users.noreply.github.com> Utkarsh Utkarsh Raj +UtkershBasnet <119008923+UtkershBasnet@users.noreply.github.com> Vaibhav Patel <98279986+noobCoderVP@users.noreply.github.com> Varad Gupta Xiaochuan Ye diff --git a/dist/index.js.map b/dist/index.js.map index cd49992..c0a3e9d 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/binary.js", "../lib/module.js", "../lib/routine.js", "../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolve = require( 'path' ).resolve;\nvar readWASM = require( '@stdlib/fs-read-wasm' ).sync;\n\n\n// MAIN //\n\nvar wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );\n\n\n// EXPORTS //\n\nmodule.exports = wasm;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isWebAssemblyMemory = require( '@stdlib/assert-is-wasm-memory' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar WasmModule = require( '@stdlib/wasm-module-wrapper' );\nvar format = require( '@stdlib/string-format' );\nvar wasmBinary = require( './binary.js' );\n\n\n// MAIN //\n\n/**\n* BLAS routine WebAssembly module wrapper constructor.\n*\n* @constructor\n* @param {Object} memory - WebAssembly memory instance\n* @throws {TypeError} must provide a WebAssembly memory instance\n* @returns {Module} module instance\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nfunction Module( memory ) {\n\tif ( !( this instanceof Module ) ) {\n\t\treturn new Module( memory );\n\t}\n\tif ( !isWebAssemblyMemory( memory ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a WebAssembly memory instance. Value: `%s`.', memory ) );\n\t}\n\t// Call the parent constructor:\n\tWasmModule.call( this, wasmBinary, memory, {\n\t\t'env': {\n\t\t\t'memory': memory\n\t\t}\n\t});\n\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Module, WasmModule );\n\n/**\n* Applies a plane rotation.\n*\n* @name main\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {NonNegativeInteger} second input array pointer (i.e., byte offset)\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Module.prototype, 'main', function drot( N, xptr, strideX, yptr, strideY, c, s ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\tthis._instance.exports.c_drot( N, xptr, strideX, yptr, strideY, c, s );\n\treturn yptr;\n});\n\n/**\n* Applies a plane rotation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {NonNegativeInteger} second input array pointer (i.e., byte offset)\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.ndarray( N, xptr, 1, 0, yptr, 1, 0, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Module.prototype, 'ndarray', function drot( N, xptr, strideX, offsetX, yptr, strideY, offsetY, c, s ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\tthis._instance.exports.c_drot_ndarray( N, xptr, strideX, offsetX, yptr, strideY, offsetY, c, s ); // eslint-disable-line max-len\n\treturn yptr;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Module;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar readDataView = require( '@stdlib/strided-base-read-dataview' ).ndarray;\nvar Memory = require( '@stdlib/wasm-memory' );\nvar arrays2ptrs = require( '@stdlib/wasm-base-arrays2ptrs' );\nvar strided2object = require( '@stdlib/wasm-base-strided2object' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* Routine constructor.\n*\n* @private\n* @constructor\n* @returns {Routine} routine instance\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nfunction Routine() {\n\tif ( !( this instanceof Routine ) ) {\n\t\treturn new Routine();\n\t}\n\tModule.call( this, new Memory({\n\t\t'initial': 0\n\t}));\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Routine, Module );\n\n/**\n* Applies a plane rotation.\n*\n* @name main\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {Float64Array} second input array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Routine.prototype, 'main', function drot( N, x, strideX, y, strideY, c, s ) {\n\treturn this.ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ), c, s ); // eslint-disable-line max-len\n});\n\n/**\n* Applies a plane rotation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {Float64Array} second input array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Routine.prototype, 'ndarray', function drot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) {\n\tvar ptrs;\n\tvar p0;\n\tvar p1;\n\n\t// Convert the input arrays to \"pointers\" in the module's memory:\n\tptrs = arrays2ptrs( this, [\n\t\tstrided2object( N, x, strideX, offsetX ),\n\t\tstrided2object( N, y, strideY, offsetY )\n\t]);\n\tp0 = ptrs[ 0 ];\n\tp1 = ptrs[ 1 ];\n\n\t// Perform computation by calling the corresponding parent method:\n\tModule.prototype.ndarray.call( this, N, p0.ptr, p0.stride, p0.offset, p1.ptr, p1.stride, p1.offset, c, s ); // eslint-disable-line max-len\n\n\t// If the output arrays data had to be copied to module memory, copy the results to the provided output arrays...\n\tif ( p0.copy ) {\n\t\treadDataView( N, this.view, p0.stride*p0.BYTES_PER_ELEMENT, p0.ptr, x, strideX, offsetX, true ); // eslint-disable-line max-len\n\t}\n\tif ( p1.copy ) {\n\t\treadDataView( N, this.view, p1.stride*p1.BYTES_PER_ELEMENT, p1.ptr, y, strideY, offsetY, true ); // eslint-disable-line max-len\n\t}\n\treturn y;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Routine;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Routine = require( './routine.js' );\n\n\n// MAIN //\n\n/**\n* WebAssembly module to apply a plane rotation.\n*\n* @name drot\n* @type {Routine}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nvar drot = new Routine();\ndrot.initializeSync(); // eslint-disable-line node/no-sync\n\n\n// EXPORTS //\n\nmodule.exports = drot;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* WebAssembly routine to apply a plane rotation.\n*\n* @module @stdlib/blas-base-drot-wasm\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var mod = new drot.Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* mod.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* mod.write( xptr, oneTo( N, dtype ) );\n* mod.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* mod.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* mod.read( xptr, viewX );\n* mod.read( yptr, viewY );\n*\n* console.log( viewX );\n* // => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* console.log( viewY );\n* // => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'Module', Module );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"Module\": \"main.Module\" }\n"], + "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolve = require( 'path' ).resolve;\nvar readWASM = require( '@stdlib/fs-read-wasm' ).sync;\n\n\n// MAIN //\n\nvar wasm = readWASM( resolve( __dirname, '..', 'src', 'main.wasm' ) );\n\n\n// EXPORTS //\n\nmodule.exports = wasm;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar isWebAssemblyMemory = require( '@stdlib/assert-is-wasm-memory' );\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar WasmModule = require( '@stdlib/wasm-module-wrapper' );\nvar format = require( '@stdlib/string-format' );\nvar wasmBinary = require( './binary.js' );\n\n\n// MAIN //\n\n/**\n* BLAS routine WebAssembly module wrapper constructor.\n*\n* @constructor\n* @param {Object} memory - WebAssembly memory instance\n* @throws {TypeError} must provide a WebAssembly memory instance\n* @returns {Module} module instance\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nfunction Module( memory ) {\n\tif ( !( this instanceof Module ) ) {\n\t\treturn new Module( memory );\n\t}\n\tif ( !isWebAssemblyMemory( memory ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a WebAssembly memory instance. Value: `%s`.', memory ) );\n\t}\n\t// Call the parent constructor:\n\tWasmModule.call( this, wasmBinary, memory, {\n\t\t'env': {\n\t\t\t'memory': memory\n\t\t}\n\t});\n\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Module, WasmModule );\n\n/**\n* Applies a plane rotation.\n*\n* @name main\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {NonNegativeInteger} second input array pointer (i.e., byte offset)\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Module.prototype, 'main', function drot( N, xptr, strideX, yptr, strideY, c, s ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\tthis._instance.exports.c_drot( N, xptr, strideX, yptr, strideY, c, s );\n\treturn yptr;\n});\n\n/**\n* Applies a plane rotation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Module.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {NonNegativeInteger} xptr - first input array pointer (i.e., byte offset)\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {NonNegativeInteger} yptr - second input array pointer (i.e., byte offset)\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {NonNegativeInteger} second input array pointer (i.e., byte offset)\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var drot = new Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* drot.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* drot.write( xptr, oneTo( N, dtype ) );\n* drot.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* var ptr = drot.ndarray( N, xptr, 1, 0, yptr, 1, 0, 0.0, 1.0 );\n* // returns \n*\n* var bool = ( ptr === yptr );\n* // returns true\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* drot.read( xptr, viewX );\n* // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* drot.read( yptr, viewY );\n* // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Module.prototype, 'ndarray', function drot( N, xptr, strideX, offsetX, yptr, strideY, offsetY, c, s ) { // eslint-disable-line stdlib/jsdoc-doctest-decimal-point\n\tthis._instance.exports.c_drot_ndarray( N, xptr, strideX, offsetX, yptr, strideY, offsetY, c, s ); // eslint-disable-line max-len\n\treturn yptr;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Module;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable no-restricted-syntax, no-invalid-this */\n\n'use strict';\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar inherits = require( '@stdlib/utils-inherit' );\nvar stride2offset = require( '@stdlib/strided-base-stride2offset' );\nvar readDataView = require( '@stdlib/strided-base-read-dataview' ).ndarray;\nvar Memory = require( '@stdlib/wasm-memory' );\nvar arrays2ptrs = require( '@stdlib/wasm-base-arrays2ptrs' );\nvar strided2object = require( '@stdlib/wasm-base-strided2object' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\n/**\n* Routine constructor.\n*\n* @private\n* @constructor\n* @returns {Routine} routine instance\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nfunction Routine() {\n\tif ( !( this instanceof Routine ) ) {\n\t\treturn new Routine();\n\t}\n\tModule.call( this, new Memory({\n\t\t'initial': 0\n\t}));\n\treturn this;\n}\n\n// Inherit from the parent constructor:\ninherits( Routine, Module );\n\n/**\n* Applies a plane rotation.\n*\n* @name main\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {Float64Array} second input array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Routine.prototype, 'main', function drot( N, x, strideX, y, strideY, c, s ) {\n\treturn this.ndarray( N, x, strideX, stride2offset( N, strideX ), y, strideY, stride2offset( N, strideY ), c, s ); // eslint-disable-line max-len\n});\n\n/**\n* Applies a plane rotation using alternative indexing semantics.\n*\n* @name ndarray\n* @memberof Routine.prototype\n* @readonly\n* @type {Function}\n* @param {PositiveInteger} N - number of indexed elements\n* @param {Float64Array} x - first input array\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Float64Array} y - second input array\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @param {number} c - cosine of the angle of rotation\n* @param {number} s - sine of the angle of rotation\n* @returns {Float64Array} second input array\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Create a new routine:\n* var drot = new Routine();\n*\n* // Initialize the module:\n* drot.initializeSync();\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nsetReadOnly( Routine.prototype, 'ndarray', function drot( N, x, strideX, offsetX, y, strideY, offsetY, c, s ) {\n\tvar ptrs;\n\tvar p0;\n\tvar p1;\n\n\t// Convert the input arrays to \"pointers\" in the module's memory:\n\tptrs = arrays2ptrs( this, [\n\t\tstrided2object( N, x, strideX, offsetX ),\n\t\tstrided2object( N, y, strideY, offsetY )\n\t]);\n\tp0 = ptrs[ 0 ];\n\tp1 = ptrs[ 1 ];\n\n\t// Perform computation by calling the corresponding parent method:\n\tModule.prototype.ndarray.call( this, N, p0.ptr, p0.stride, p0.offset, p1.ptr, p1.stride, p1.offset, c, s ); // eslint-disable-line max-len\n\n\t// If output array data had to be copied to module memory, copy the results to the provided output arrays...\n\tif ( p0.copy ) {\n\t\treadDataView( N, this.view, p0.stride*p0.BYTES_PER_ELEMENT, p0.ptr, x, strideX, offsetX, true ); // eslint-disable-line max-len\n\t}\n\tif ( p1.copy ) {\n\t\treadDataView( N, this.view, p1.stride*p1.BYTES_PER_ELEMENT, p1.ptr, y, strideY, offsetY, true ); // eslint-disable-line max-len\n\t}\n\treturn y;\n});\n\n\n// EXPORTS //\n\nmodule.exports = Routine;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar Routine = require( './routine.js' );\n\n\n// MAIN //\n\n/**\n* WebAssembly module to apply a plane rotation.\n*\n* @name drot\n* @type {Routine}\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\nvar drot = new Routine();\ndrot.initializeSync(); // eslint-disable-line node/no-sync\n\n\n// EXPORTS //\n\nmodule.exports = drot;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* WebAssembly routine to apply a plane rotation.\n*\n* @module @stdlib/blas-base-drot-wasm\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.main( x.length, x, 1, y, 1, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Define strided arrays:\n* var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );\n* var y = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] );\n*\n* // Perform operation:\n* drot.ndarray( x.length, x, 1, 0, y, 1, 0, 0.0, 1.0 );\n* // x => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n* // y => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*\n* @example\n* var Memory = require( '@stdlib/wasm-memory' );\n* var oneTo = require( '@stdlib/array-one-to' );\n* var ones = require( '@stdlib/array-ones' );\n* var zeros = require( '@stdlib/array-zeros' );\n* var bytesPerElement = require( '@stdlib/ndarray-base-bytes-per-element' );\n* var drot = require( '@stdlib/blas-base-drot-wasm' );\n*\n* // Create a new memory instance with an initial size of 10 pages (640KiB) and a maximum size of 100 pages (6.4MiB):\n* var mem = new Memory({\n* 'initial': 10,\n* 'maximum': 100\n* });\n*\n* // Create a BLAS routine:\n* var mod = new drot.Module( mem );\n* // returns \n*\n* // Initialize the routine:\n* mod.initializeSync();\n*\n* // Define a vector data type:\n* var dtype = 'float64';\n*\n* // Specify a vector length:\n* var N = 5;\n*\n* // Define pointers (i.e., byte offsets) for storing two vectors:\n* var xptr = 0;\n* var yptr = N * bytesPerElement( dtype );\n*\n* // Write vector values to module memory:\n* mod.write( xptr, oneTo( N, dtype ) );\n* mod.write( yptr, ones( N, dtype ) );\n*\n* // Perform computation:\n* mod.main( N, xptr, 1, yptr, 1, 0.0, 1.0 );\n*\n* // Read out the results:\n* var viewX = zeros( N, dtype );\n* var viewY = zeros( N, dtype );\n* mod.read( xptr, viewX );\n* mod.read( yptr, viewY );\n*\n* console.log( viewX );\n* // => [ 1.0, 1.0, 1.0, 1.0, 1.0 ]\n*\n* console.log( viewY );\n* // => [ -1.0, -2.0, -3.0, -4.0, -5.0 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar Module = require( './module.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'Module', Module );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n\n// exports: { \"Module\": \"main.Module\" }\n"], "mappings": "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", "names": ["require_binary", "__commonJSMin", "exports", "module", "resolve", "readWASM", "wasm", "require_module", "__commonJSMin", "exports", "module", "isWebAssemblyMemory", "setReadOnly", "inherits", "WasmModule", "format", "wasmBinary", "Module", "memory", "N", "xptr", "strideX", "yptr", "strideY", "c", "s", "offsetX", "offsetY", "require_routine", "__commonJSMin", "exports", "module", "setReadOnly", "inherits", "stride2offset", "readDataView", "Memory", "arrays2ptrs", "strided2object", "Module", "Routine", "N", "x", "strideX", "y", "strideY", "c", "s", "offsetX", "offsetY", "ptrs", "p0", "p1", "require_main", "__commonJSMin", "exports", "module", "Routine", "drot", "setReadOnly", "main", "Module"] } diff --git a/docs/repl.txt b/docs/repl.txt index 21ab20c..abc3d6f 100644 --- a/docs/repl.txt +++ b/docs/repl.txt @@ -83,7 +83,7 @@ Number of indexed elements. x: Float64Array - Input array. + First input array. strideX: integer Index increment for `x`. @@ -300,9 +300,9 @@ 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. + 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 diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index ab7eb86..d74e508 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -77,8 +77,9 @@ interface ModuleConstructor { * var viewX = zeros( N, dtype ); * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ); - * mod.read( yptr, viewY ); * // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * + * mod.read( yptr, viewY ); * // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ] */ new( mem: Memory ): Module; // newable @@ -134,8 +135,9 @@ interface ModuleConstructor { * var viewX = zeros( N, dtype ); * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ); - * mod.read( yptr, viewY ); * // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * + * mod.read( yptr, viewY ); * // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ] */ ( mem: Memory ): Module; // callable @@ -202,8 +204,9 @@ interface Module extends ModuleWrapper { * var viewX = zeros( N, dtype ); * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ); - * mod.read( yptr, viewY ); * // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * + * mod.read( yptr, viewY ); * // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ] */ main( N: number, xptr: number, strideX: number, yptr: number, strideY: number, c: number, s: number ): number; @@ -267,8 +270,9 @@ interface Module extends ModuleWrapper { * var viewX = zeros( N, dtype ); * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ); - * mod.read( yptr, viewY ); * // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * + * mod.read( yptr, viewY ); * // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ] */ ndarray( N: number, xptr: number, strideX: number, offsetX: number, yptr: number, strideY: number, offsetY: number, c: number, s: number ): number; @@ -379,8 +383,9 @@ interface Routine extends ModuleWrapper { * var viewX = zeros( N, dtype ); * var viewY = zeros( N, dtype ); * mod.read( xptr, viewX ); - * mod.read( yptr, viewY ); * // viewX => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + * + * mod.read( yptr, viewY ); * // viewY => [ -1.0, -2.0, -3.0, -4.0, -5.0 ] */ Module: ModuleConstructor; diff --git a/lib/routine.js b/lib/routine.js index 9234706..61e0d13 100644 --- a/lib/routine.js +++ b/lib/routine.js @@ -180,7 +180,7 @@ setReadOnly( Routine.prototype, 'ndarray', function drot( N, x, strideX, offsetX // 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, c, s ); // eslint-disable-line max-len - // If the output arrays data had to be copied to module memory, copy the results to the provided output arrays... + // If output array data had to be copied to module memory, copy the results to the provided 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 }