diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json index 090d0bc750de..ef608a7ea324 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], @@ -47,6 +49,7 @@ }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], @@ -62,6 +65,23 @@ }, { "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/shared" + ] + }, + { + "task": "build", + "wasm": true, "src": [ "./src/main.c" ], diff --git a/lib/node_modules/@stdlib/stats/strided/dmeanvar/examples/index.js b/lib/node_modules/@stdlib/stats/strided/dmeanvar/examples/index.js index 964785eb4239..b198fcc0d4fb 100644 --- a/lib/node_modules/@stdlib/stats/strided/dmeanvar/examples/index.js +++ b/lib/node_modules/@stdlib/stats/strided/dmeanvar/examples/index.js @@ -28,5 +28,6 @@ var x = discreteUniform( 10, -50, 50, { console.log( x ); var out = new Float64Array( 2 ); -dmeanvar( x.length, 1, x, 1, out, 1 ); +var y = dmeanvar( x.length, 1, x, 1, out, 1 ); console.log( out ); +console.log(y); diff --git a/lib/node_modules/@stdlib/stats/strided/dmeanvar/manifest.json b/lib/node_modules/@stdlib/stats/strided/dmeanvar/manifest.json index 614ac0a007a0..022525f175cf 100644 --- a/lib/node_modules/@stdlib/stats/strided/dmeanvar/manifest.json +++ b/lib/node_modules/@stdlib/stats/strided/dmeanvar/manifest.json @@ -83,7 +83,7 @@ ] }, { - "task": "", + "task": "build", "wasm": true, "src": [ "./src/main.c" diff --git a/lib/node_modules/@stdlib/stats/strided/dmeanvarpn/manifest.json b/lib/node_modules/@stdlib/stats/strided/dmeanvarpn/manifest.json index 02e992690462..9f99aa877a62 100644 --- a/lib/node_modules/@stdlib/stats/strided/dmeanvarpn/manifest.json +++ b/lib/node_modules/@stdlib/stats/strided/dmeanvarpn/manifest.json @@ -86,7 +86,7 @@ ] }, { - "task": "", + "task": "build", "wasm": true, "src": [ "./src/main.c" diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/README.md b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/README.md new file mode 100644 index 000000000000..a4abb7ef280f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/README.md @@ -0,0 +1,398 @@ + + +# dmeanvar + +> Calculate the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array. + +
+ +The population [variance][variance] of a finite size population of size `N` is given by + + + +```math +\sigma^2 = \frac{1}{N} \sum_{i=0}^{N-1} (x_i - \mu)^2 +``` + + + + + +where the population mean is given by + + + +```math +\mu = \frac{1}{N} \sum_{i=0}^{N-1} x_i +``` + + + + + +Often in the analysis of data, the true population [variance][variance] is not known _a priori_ and must be estimated from a sample drawn from the population distribution. If one attempts to use the formula for the population [variance][variance], the result is biased and yields a **biased sample variance**. To compute an **unbiased sample variance** for a sample of size `n`, + + + +```math +s^2 = \frac{1}{n-1} \sum_{i=0}^{n-1} (x_i - \bar{x})^2 +``` + + + + + +where the sample mean is given by + + + +```math +\bar{x} = \frac{1}{n} \sum_{i=0}^{n-1} x_i +``` + + + + + +The use of the term `n-1` is commonly referred to as Bessel's correction. Note, however, that applying Bessel's correction can increase the mean squared error between the sample variance and population variance. Depending on the characteristics of the population distribution, other correction factors (e.g., `n-1.5`, `n+1`, etc) can yield better estimators. + +
+ + + +
+ +## Usage + +```javascript +var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +``` + +#### dmeanvar.main( N, correction, x, strideX, out, strideOut ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +var out = new Float64Array( 2 ); + +var v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); +// returns [ ~0.3333, ~4.3333 ] + +var bool = ( v === out ); +// returns true +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [variance][variance] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [variance][variance] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the unbiased sample [variance][variance], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction). +- **x**: input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: stride length for `x`. +- **out**: output [`Float64Array`][@stdlib/array/float64] for storing results. +- **strideOut**: stride length for `out`. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [mean][arithmetic-mean] and [variance][variance] of every other element in `x`, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); +var out = new Float64Array( 2 ); + +var v = dmeanvar.main( 4, 1, x, 2, out, 1 ); +// returns [ 1.25, 6.25 ] +``` + +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' ); + +var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var out0 = new Float64Array( 4 ); +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at 3rd element + +var v = dmeanvar.main( 4, 1, x1, 2, out1, 1 ); +// returns [ 1.25, 6.25 ] +``` + +#### dmeanvar.ndarray( N, correction, x, strideX, offsetX, out, strideOut, offsetOut ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +var out = new Float64Array( 2 ); + +var v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); +// returns [ ~0.3333, ~4.3333 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetOut**: starting index for `out`. + +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 calculate the [mean][arithmetic-mean] and [variance][variance] for every other element in `x` starting from the second element + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +var out = new Float64Array( 4 ); + +var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 2, 1 ); +// returns [ 1.25, 6.25 ] +``` + +* * * + +### Module + +#### dmeanvar.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 new routine: +var mod = new dmeanvar.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); +``` + +#### dmeanvar.Module.prototype.main( N, correction, xp, sx, outp, sout ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array. + + + +```javascript +var Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var zeros = require( '@stdlib/array/zeros' ); + +// 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 new routine: +var mod = new dmeanvar.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float64'; + +// Specify a vector length: +var N = 3; + +// Define pointers (i.e., byte offsets) for storing the input and output vectors: +var xptr = 0; +var outptr = N * 8; // 8 bytes per float64 + +// Write input values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); + +// Perform computation: +var out = zeros( 2, dtype ); +mod.write( outptr, out ); +mod.main( N, 1, xptr, 1, outptr, 1 ); + +// Read the results: +var results = mod.read( outptr, 2 ); +// returns [ 2.0, 1.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **correction**: degrees of freedom adjustment. +- **xp**: input [`Float64Array`][@stdlib/array/float64] pointer (i.e., byte offset). +- **sx**: stride length for `x`. +- **outp**: output [`Float64Array`][@stdlib/array/float64] pointer (i.e., byte offset). +- **sout**: stride length for `out`. + +#### dmeanvar.Module.prototype.ndarray( N, correction, xp, sx, ox, outp, sout, oout ) + +Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using alternative indexing semantics. + + + +```javascript +var Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var zeros = require( '@stdlib/array/zeros' ); + +// 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 new routine: +var mod = new dmeanvar.Module( mem ); +// returns + +// Initialize the routine: +mod.initializeSync(); + +// Define a vector data type: +var dtype = 'float64'; + +// Specify a vector length: +var N = 3; + +// Define pointers (i.e., byte offsets) for storing the input and output vectors: +var xptr = 0; +var outptr = N * 8; // 8 bytes per float64 + +// Write input values to module memory: +mod.write( xptr, oneTo( N, dtype ) ); + +// Perform computation: +var out = zeros( 2, dtype ); +mod.write( outptr, out ); +mod.ndarray( N, 1, xptr, 1, 0, outptr, 1, 0 ); + +// Read the results: +var results = mod.read( outptr, 2 ); +// returns [ 2.0, 1.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oout**: starting index for `out`. + +
+ + + +
+ +* * * + +## Notes + +- If `N <= 0`, both `main` and `ndarray` methods return a [mean][arithmetic-mean] and [variance][variance] equal to `NaN`. +- If `N - c` is less than or equal to `0` (where `c` corresponds to the provided degrees of freedom adjustment), both methods return a [variance][variance] equal to `NaN`. +- This package implements routines using WebAssembly. When provided arrays which are not allocated on a `dmeanvar` 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/stats/strided/dmeanvar`][@stdlib/stats/strided/dmeanvar]. 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/stats/strided/dmeanvar`][@stdlib/stats/strided/dmeanvar]. 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. + +
+ + + +
+ +* * * + +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); + +var opts = { + 'dtype': 'float64' +}; +var x = discreteUniform( 10, -50, 50, opts ); +console.log( x ); + +var out = new Float64Array( 2 ); +var v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); +console.log( out ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +[arithmetic-mean]: https://en.wikipedia.org/wiki/Arithmetic_mean + +[variance]: https://en.wikipedia.org/wiki/Variance + +[@stdlib/array/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/float64 + +[mdn-typed-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray + +[@stdlib/wasm/memory]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/wasm/memory + +[@stdlib/wasm/module-wrapper]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/wasm/module-wrapper + +[@stdlib/stats/strided/dmeanvar]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/strided/dmeanvar + + + +
+ + diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.js new file mode 100644 index 000000000000..13becb4d4046 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dmeanvar = 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 x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = dmeanvar.main( x.length, x, 1 ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + 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/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.js new file mode 100644 index 000000000000..f1dc69085318 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 dmeanvar = 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 dmeanvar.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/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.main.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.main.js new file mode 100644 index 000000000000..8b5291384203 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.main.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dmeanvar = 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 xptr; + var mod; + var mem; + var nb; + var v; + var i; + + // Create a new routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new dmeanvar.Module( mem ); + + // Initialize the module: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Reallocate the underlying memory to allow storing a vector: + nb = bytesPerElement( options.dtype ); + mod.realloc( len*nb ); + + // Define a pointer (i.e., byte offset) to the first vector element: + xptr = 0; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -10.0, 10.0, options ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = mod.main( len, xptr, 1 ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + 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/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.ndarray.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.ndarray.js new file mode 100644 index 000000000000..0325dad175a2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.module.ndarray.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var bytesPerElement = require( '@stdlib/ndarray/base/bytes-per-element' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dmeanvar = 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 xptr; + var mod; + var mem; + var nb; + var v; + var i; + + // Create a new routine interface: + mem = new Memory({ + 'initial': 0 + }); + mod = new dmeanvar.Module( mem ); + + // Initialize the module: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Reallocate the underlying memory to allow storing a vector: + nb = bytesPerElement( options.dtype ); + mod.realloc( len*nb ); + + // Define a pointer (i.e., byte offset) to the first vector element: + xptr = 0; + + // Write random values to module memory: + mod.write( xptr, uniform( len, -10.0, 10.0, options ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = mod.ndarray( len, xptr, 1, 0 ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + 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/stats/strided/wasm/dmeanvar/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..d6dc7c1f51b8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/benchmark/benchmark.ndarray.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var pkg = require( './../package.json' ).name; +var dmeanvar = 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 x = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = dmeanvar.ndarray( x.length, x, 1, 0 ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + 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/stats/strided/wasm/dmeanvar/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/repl.txt new file mode 100644 index 000000000000..d48a7e175e10 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/repl.txt @@ -0,0 +1,583 @@ + +{{alias}}( N, c, x, strideX, out, strideOut ) + Computes the mean and variance of a double-precision floating-point strided + array. + + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use a typed + array view. + + If `N <= 0`, the function returns a mean and variance equal to `NaN`. + + Parameters + ---------- + N: integer + Number of indexed elements. + + c: number + Degrees of freedom adjustment. Setting this parameter to a value other + than `0` has the effect of adjusting the divisor during the calculation + of the variance according to `N - c` where `c` corresponds to the + provided degrees of freedom adjustment. When computing the variance of a + population, setting this parameter to `0` is the standard choice (i.e., + the provided array contains data constituting an entire population). + When computing the unbiased sample variance, setting this parameter to + `1` is the standard choice (i.e., the provided array contains data + sampled from a larger population; this is commonly referred to as + Bessel's correction). + + x: Float64Array + Input array. + + strideX: integer + Stride length for `x`. + + out: Float64Array + Output array. + + strideOut: integer + Stride length for `out`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + // Standard Usage: +> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); +> var out = new {{alias:@stdlib/array/float64}}( 2 ); +> {{alias}}( x.length, 1, x, 1, out, 1 ) + [ ~0.3333, ~4.3333 ] + + // Using `N` and stride parameters: +> x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); +> out = new {{alias:@stdlib/array/float64}}( 2 ); +> {{alias}}( 3, 1, x, 2, out, 1 ) + [ ~0.3333, ~4.3333 ] + + // Using view offsets: +> var x0 = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] ); +> var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); +> out = new {{alias:@stdlib/array/float64}}( 2 ); +> {{alias}}( 3, 1, x1, 2, out, 1 ) + [ ~0.3333, ~4.3333 ] + + +{{alias}}.ndarray( N, c, x, strideX, offsetX, out, strideOut, offsetOut ) + Computes the mean and variance of a double-precision floating-point strided + array using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the `offset` parameter supports indexing semantics based on a + starting index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + c: number + Degrees of freedom adjustment. Setting this parameter to a value other + than `0` has the effect of adjusting the divisor during the calculation + of the variance according to `N - c` where `c` corresponds to the + provided degrees of freedom adjustment. When computing the variance of a + population, setting this parameter to `0` is the standard choice (i.e., + the provided array contains data constituting an entire population). + When computing the unbiased sample variance, setting this parameter to + `1` is the standard choice (i.e., the provided array contains data + sampled from a larger population; this is commonly referred to as + Bessel's correction). + + x: Float64Array + Input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + out: Float64Array + Output array. + + strideOut: integer + Stride length for `out`. + + offsetOut: integer + Starting index for `out`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + // Standard Usage: +> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); +> var out = new {{alias:@stdlib/array/float64}}( 2 ); +> {{alias}}.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ) + [ ~0.3333, ~4.3333 ] + + // Using offset parameter: +> var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, 1.0 ] ); +> out = new {{alias:@stdlib/array/float64}}( 2 ); +> {{alias}}.ndarray( 3, 1, x, 2, 1, out, 1, 0 ) + [ ~0.3333, ~4.3333 ] + + +{{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, c, xp, sx, out, sout ) + Computes the mean and variance of a double-precision floating-point strided + array. + + Parameters + ---------- + N: integer + Number of indexed elements. + + c: number + Degrees of freedom adjustment. Setting this parameter to a value other + than `0` has the effect of adjusting the divisor during the calculation + of the variance according to `N - c` where `c` corresponds to the + provided degrees of freedom adjustment. When computing the variance of a + population, setting this parameter to `0` is the standard choice (i.e., + the provided array contains data constituting an entire population). + When computing the unbiased sample variance, setting this parameter to + `1` is the standard choice (i.e., the provided array contains data + sampled from a larger population; this is commonly referred to as + Bessel's correction). + + xp: integer + Input array pointer (i.e., byte offset). + + sx: integer + Stride length. + + out: Float64Array + Output array. + + sout: integer + Stride length for `out`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- +> var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); +> var mod = new {{alias}}.Module( mem ); +> var out = new {{alias:@stdlib/array/float64}}( 2 ); +> mod.initializeSync(); + + // Define a "pointer" (i.e., byte offset) into module memory: +> var xptr = 0; + + // Write data to module memory: +> mod.write( xptr, {{alias:@stdlib/array/one-to}}( 3, 'float64' ) ); + + // Perform computation: +> var s = mod.main( 3, 1, xptr, 1, out, 1 ) + [ 2.0, 1.0 ] + + +{{alias}}.Module.prototype.ndarray( N, c, xp, sx, ox, out, sout, oout ) + Computes the mean and variance of a double-precision floating-point strided + array using alternative indexing semantics. + + Parameters + ---------- + N: integer + Number of indexed elements. + + c: number + Degrees of freedom adjustment. Setting this parameter to a value other + than `0` has the effect of adjusting the divisor during the calculation + of the variance according to `N - c` where `c` corresponds to the + provided degrees of freedom adjustment. When computing the variance of a + population, setting this parameter to `0` is the standard choice (i.e., + the provided array contains data constituting an entire population). + When computing the unbiased sample variance, setting this parameter to + `1` is the standard choice (i.e., the provided array contains data + sampled from a larger population; this is commonly referred to as + Bessel's correction). + + xp: Float64Array + Input array. + + sx: integer + Stride length for `x`. + + ox: integer + Starting index for `x`. + + out: Float64Array + Output array. + + sout: integer + Stride length for `out`. + + oout: integer + Starting index for `out`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- +> var mem = new {{alias:@stdlib/wasm/memory}}( { 'initial': 1 } ); +> var mod = new {{alias}}.Module( mem ); +> var out = new {{alias:@stdlib/array/float64}}( 2 ); +> mod.initializeSync(); + + // Define a "pointer" (i.e., byte offset) into module memory: +> var xptr = 0; + + // Write data to module memory: +> mod.write( xptr, {{alias:@stdlib/array/one-to}}( 3, 'float64' ) ); + + // Perform computation: +> var s = mod.main( 3, 1, xptr, 1, out, 1 ) + [ 2.0, 1.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/index.d.ts new file mode 100644 index 000000000000..3b747666028e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/index.d.ts @@ -0,0 +1,357 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 Float64Array = require( '@stdlib/array/float64' ); + * + * // 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 new routine: + * var mod = new dmeanvar.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 3; + * + * // Define a pointer (i.e., byte offset) to the first vector element: + * var xptr = 0; + * + * // Allocate space for the output: + * var out = new Float64Array( 2 ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var y = mod.main( N, 1, xptr, 1, out, 1 ); + * // returns [ 2.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 Float64Array = require( '@stdlib/array/float64' ); + * + * // 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 new routine: + * var mod = dmeanvar.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 3; + * + * // Define a pointer (i.e., byte offset) to the first vector element: + * var xptr = 0; + * + * // Allocate space for the output: + * var out = new Float64Array( 2 ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var y = mod.main( N, 1, xptr, 1, out, 1 ); + * // returns [ 2.0, 1.0 ] + */ + ( mem: Memory ): Module; // callable +} + +/** +* Interface describing a `dmeanvar` WebAssembly module. +*/ +interface Module extends ModuleWrapper { + /** + * Computes the mean and variance of a double-precision floating-point strided array. + * + * @param N - number of indexed elements + * @param correction - degrees of freedom adjustment + * @param xptr - input array pointer (i.e., byte offset) + * @param strideX - stride length + * @param out - output array + * @param strideOut - `out` stride length + * @returns output array + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * // 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 new routine: + * var mod = new dmeanvar.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 3; + * + * // Define a pointer (i.e., byte offset) to the first vector element: + * var xptr = 0; + * + * // Allocate space for the output: + * var out = new Float64Array( 2 ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var y = mod.main( N, 1, xptr, 1, out, 1 ); + * // returns [ 2.0, 1.0 ] + */ + main( N: number, correction: number, xptr: number, strideX: number, out: Float64Array, strideOut: number ): Float64Array; + + /** + * Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param correction - degrees of freedom adjustment + * @param xptr - input array pointer (i.e., byte offset) + * @param strideX - stride length + * @param offsetX - starting index + * @param out - output array + * @param strideOut - `out` stride length + * @param offsetOut - `out` starting index + * @returns output array + * + * @example + * var Memory = require( '@stdlib/wasm/memory' ); + * var oneTo = require( '@stdlib/array/one-to' ); + * var Float64Array = require( '@stdlib/array/float64' ); + * + * // 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 new routine: + * var mod = new dmeanvar.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 3; + * + * // Define a pointer (i.e., byte offset) to the first vector element: + * var xptr = 0; + * + * // Allocate space for the output: + * var out = new Float64Array( 2 ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var y = mod.ndarray( N, 1, xptr, 1, 0, out, 1, 0 ); + * // returns [ 2.0, 1.0 ] + */ + ndarray( N: number, correction: number, xptr: number, strideX: number, offsetX: number, out: Float64Array, strideOut: number, offsetOut: number ): Float64Array; +} + +/** +* Interface describing `dmeanvar`. +*/ +interface Routine extends ModuleWrapper { + /** + * Computes the mean and variance of a double-precision floating-point strided array. + * + * @param N - number of indexed elements + * @param correction - degrees of freedom adjustment + * @param x - input array + * @param strideX - `x` stride length + * @param out - output array + * @param strideOut - `out` stride length + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); + * var out = new Float64Array( 2 ); + * + * var y = dmeanvar.main( 3, 1, x, 1, out, 1 ); + * // returns [ ~0.3333, ~4.3333 ] + */ + main( N: number, correction: number, x: Float64Array, strideX: number, out: Float64Array, strideOut: number ): Float64Array; + + /** + * Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param correction - degrees of freedom adjustment + * @param x - input array + * @param strideX - `x` stride length + * @param offsetX - `x` starting index + * @param out - output array + * @param strideOut - `out` stride length + * @param offsetOut - `out` starting index + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); + * var out = new Float64Array( 2 ); + * + * var y = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); + * // returns [ 1.25, 6.25 ] + */ + ndarray( N: number, correction: number, x: Float64Array, strideX: number, offsetX: number, out: Float64Array, strideOut: number, offsetOut: number ): 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 Float64Array = require( '@stdlib/array/float64' ); + * + * // 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 new routine: + * var mod = new dmeanvar.Module( mem ); + * // returns + * + * // Initialize the routine: + * mod.initializeSync(); + * + * // Define a vector data type: + * var dtype = 'float64'; + * + * // Specify a vector length: + * var N = 3; + * + * // Define a pointer (i.e., byte offset) to the first vector element: + * var xptr = 0; + * + * // Allocate space for the output: + * var out = new Float64Array( 2 ); + * + * // Write vector values to module memory: + * mod.write( xptr, oneTo( N, dtype ) ); + * + * // Perform computation: + * var y = mod.main( N, 1, xptr, 1, out, 1 ); + * // returns [ 2.0, 1.0 ] + */ + Module: ModuleConstructor; +} + +/** +* Computes the mean and variance of a double-precision floating-point strided array. +* +* @param N - number of indexed elements +* @param correction - degrees of freedom adjustment +* @param x - input array +* @param strideX - `x` stride length +* @param out - output array +* @param strideOut - `out` stride length +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var out = new Float64Array( 2 ); +* +* var v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); +* // returns [ ~0.3333, ~4.3333 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var out = new Float64Array( 2 ); +* +* var v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); +* // returns [ ~0.3333, ~4.3333 ] +*/ +declare var dmeanvar: Routine; + + +// EXPORTS // + +export = dmeanvar; diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/test.ts b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/test.ts new file mode 100644 index 000000000000..6202adc07b41 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/docs/types/test.ts @@ -0,0 +1,578 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 dmeanvar = require( './index' ); + + +// TESTS // + +// Attached to the main export is a `main` method which returns a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( x.length, 1, x, 1, out, 1 ); // $ExpectType number +} + +// The compiler throws an error if the `main` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( '10', 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( true, 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( false, 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( null, 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( undefined, 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( [], 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( {}, 1, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( ( x: number ): number => x, 1, x, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( x.length, '10', x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, true, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, false, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, null, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, undefined, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, [], x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, {}, x, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, ( x: number ): number => x, x, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a third argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( x.length, 1, 10, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, '10', 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, true, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, false, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, null, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, undefined, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, [ '1' ], 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, {}, 1, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, ( x: number ): number => x, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( x.length, 1, x, '10', out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, true, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, false, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, null, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, undefined, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, [], out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, {}, out, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, ( x: number ): number => x, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a fifth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dmeanvar.main( x.length, 1, x, 1, 10, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, '10', 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, true, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, false, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, null, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, undefined, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, [ '1' ], 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, {}, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided a sixth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main( x.length, 1, x, 1, out, '10' ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, true ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, false ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, null ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, undefined ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, [] ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, {} ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `main` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.main(); // $ExpectError + dmeanvar.main( x.length ); // $ExpectError + dmeanvar.main( x.length, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1 ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out ); // $ExpectError + dmeanvar.main( x.length, 1, x, 1, out, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( '10', 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( true, 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( false, 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( null, 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( undefined, 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( [], 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( {}, 1, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( ( x: number ): number => x, 1, x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, '10', x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, true, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, false, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, null, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, undefined, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, [], x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, {}, x, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, ( x: number ): number => x, x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, 10, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, '10', 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, true, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, false, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, null, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, undefined, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, [ '1' ], 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, {}, 1, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, x, '10', 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, true, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, false, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, null, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, undefined, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, [], 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, {}, 0, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, x, 1, '10', out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, true, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, false, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, null, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, undefined, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, [], out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, {}, out, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dmeanvar.ndarray( x.length, 1, x, 1, 0, 10, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, '10', 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, true, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, false, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, null, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, undefined, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, [ '1' ], 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, {}, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, '10', 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, true, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, false, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, null, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, undefined, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, [], 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, {}, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, '10' ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, true ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, false ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, null ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, undefined ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, [] ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, {} ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const out = new Float64Array( 2 ); + + dmeanvar.ndarray(); // $ExpectError + dmeanvar.ndarray( x.length ); // $ExpectError + dmeanvar.ndarray( x.length, 1 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1 ); // $ExpectError + dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0, 10 ); // $ExpectError +} + + +// Attached to the main export is a `Module` constructor which returns a module... +{ + const mem = new Memory({ + 'initial': 0 + }); + + dmeanvar.Module( mem ); // $ExpectType Module +} + +// The compiler throws an error if the `Module` constructor is not provided a WebAssembly memory instance... +{ + dmeanvar.Module( '10' ); // $ExpectError + dmeanvar.Module( true ); // $ExpectError + dmeanvar.Module( false ); // $ExpectError + dmeanvar.Module( null ); // $ExpectError + dmeanvar.Module( undefined ); // $ExpectError + dmeanvar.Module( [] ); // $ExpectError + dmeanvar.Module( {} ); // $ExpectError + dmeanvar.Module( ( x: number ): number => x ); // $ExpectError +} + + +// The `Module` constructor returns a module instance having a `main` method which returns a Float64Array... +{ + const mem = new Memory({ 'initial': 1 }); + const mod = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( 10, 1, 0, 1, out, 0 ); // $ExpectType Float64Array +} + +// 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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( '10', 1, 0, 1, out, 0 ); // $ExpectError + mod.main( true, 1, 0, 1, out, 0 ); // $ExpectError + mod.main( false, 1, 0, 1, out, 0 ); // $ExpectError + mod.main( null, 1, 0, 1, out, 0 ); // $ExpectError + mod.main( undefined, 1, 0, 1, out, 0 ); // $ExpectError + mod.main( [], 1, 0, 1, out, 0 ); // $ExpectError + mod.main( {}, 1, 0, 1, out, 0 ); // $ExpectError + mod.main( (x: number): number => x, 1, 0, 1, out, 0 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( 10, '1', 0, 1, out, 0 ); // $ExpectError + mod.main( 10, true, 0, 1, out, 0 ); // $ExpectError + mod.main( 10, false, 0, 1, out, 0 ); // $ExpectError + mod.main( 10, null, 0, 1, out, 0 ); // $ExpectError + mod.main( 10, undefined, 0, 1, out, 0 ); // $ExpectError + mod.main( 10, [], 0, 1, out, 0 ); // $ExpectError + mod.main( 10, {}, 0, 1, out, 0 ); // $ExpectError + mod.main( 10, (x: number): number => x, 0, 1, out, 0 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( 10, 1, '0', 1, out, 0 ); // $ExpectError + mod.main( 10, 1, true, 1, out, 0 ); // $ExpectError + mod.main( 10, 1, false, 1, out, 0 ); // $ExpectError + mod.main( 10, 1, null, 1, out, 0 ); // $ExpectError + mod.main( 10, 1, undefined, 1, out, 0 ); // $ExpectError + mod.main( 10, 1, [], 1, out, 0 ); // $ExpectError + mod.main( 10, 1, {}, 1, out, 0 ); // $ExpectError + mod.main( 10, 1, (x: number): number => x, 1, out, 0 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( 10, 1, 0, '1', out, 0 ); // $ExpectError + mod.main( 10, 1, 0, true, out, 0 ); // $ExpectError + mod.main( 10, 1, 0, false, out, 0 ); // $ExpectError + mod.main( 10, 1, 0, null, out, 0 ); // $ExpectError + mod.main( 10, 1, 0, undefined, out, 0 ); // $ExpectError + mod.main( 10, 1, 0, [], out, 0 ); // $ExpectError + mod.main( 10, 1, 0, {}, out, 0 ); // $ExpectError + mod.main( 10, 1, 0, (x: number): number => x, out, 0 ); // $ExpectError +} + +// The compiler throws an error if the `main` method of a module instance is provided a fifth argument which is not a Float64Array... +{ + const mem = new Memory({ 'initial': 1 }); + const mod = dmeanvar.Module( mem ); + + mod.main( 10, 1, 0, 1, 10, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, '10', 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, true, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, false, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, null, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, undefined, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, [ '1' ], 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, {}, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1, (x: number): number => x, 0 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main( 10, 1, 0, 1, out, '0' ); // $ExpectError + mod.main( 10, 1, 0, 1, out, true ); // $ExpectError + mod.main( 10, 1, 0, 1, out, false ); // $ExpectError + mod.main( 10, 1, 0, 1, out, null ); // $ExpectError + mod.main( 10, 1, 0, 1, out, undefined ); // $ExpectError + mod.main( 10, 1, 0, 1, out, [] ); // $ExpectError + mod.main( 10, 1, 0, 1, out, {} ); // $ExpectError + mod.main( 10, 1, 0, 1, out, (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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.main(); // $ExpectError + mod.main( 10 ); // $ExpectError + mod.main( 10, 1 ); // $ExpectError + mod.main( 10, 1, 0 ); // $ExpectError + mod.main( 10, 1, 0, 1 ); // $ExpectError + mod.main( 10, 1, 0, 1, out ); // $ExpectError + mod.main( 10, 1, 0, 1, out, 0, 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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 0, 1, 1, 1, 0, out, 1, 0 ); // $ExpectType number +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a first argument which is not a number... +{ + const mem = new Memory({ 'initial': 1 }); + const mod = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( '10', 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( true, 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( false, 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( null, 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( undefined, 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( [], 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( {}, 0, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( (x: number): number => x, 0, 1, 0, 1, out, 0, 1 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, '0', 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, true, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, false, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, null, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, undefined, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, [], 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, {}, 1, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, (x: number): number => x, 1, 0, 1, out, 0, 1 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, 0, '1', 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, true, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, false, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, null, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, undefined, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, [], 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, {}, 0, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, (x: number): number => x, 0, 1, out, 0, 1 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, 0, 1, '0', 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, true, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, false, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, null, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, undefined, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, [], 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, {}, 1, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, (x: number): number => x, 1, out, 0, 1 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, 0, 1, 1, '0', out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, true, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, false, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, null, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, undefined, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, [], out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, {}, out, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, (x: number): number => x, out, 0, 1 ); // $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 = dmeanvar.Module( mem ); + + mod.ndarray( 10, 0, 1, 1, 1, '0', 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, true, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, false, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, null, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, undefined, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, [], 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, {}, 0, 1 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, (x: number): number => x, 0, 1 ); // $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 = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, 0, 1, 1, 1, out, '0', 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, true, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, false, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, null, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, undefined, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, [], 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, {}, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, (x: number): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided a eighth argument which is not a number... +{ + const mem = new Memory({ 'initial': 1 }); + const mod = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray( 10, 0, 1, 1, 1, out, 1, '0' ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, true ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, false ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, null ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, undefined ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, [] ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, {} ); // $ExpectError + mod.ndarray( 10, 0, 1, 1, 1, out, 1, (x: number): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method of a module instance is provided an unsupported number of arguments... +{ + const mem = new Memory({ 'initial': 1 }); + const mod = dmeanvar.Module( mem ); + const out = new Float64Array( 2 ); + + mod.ndarray(); // $ExpectError + mod.ndarray( 10 ); // $ExpectError + mod.ndarray( 10, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 10 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 10, out ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 10, out, 0 ); // $ExpectError + mod.ndarray( 10, 0, 1, 0, 10, out, 0, 1, 1 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/index.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/index.js new file mode 100644 index 000000000000..20d1a3264f58 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/index.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var oneTo = require( '@stdlib/array/one-to' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dmeanvar = require( './../lib' ); + +function main() { + if ( !hasWebAssemblySupport() ) { + console.error( 'Environment does not support WebAssembly.' ); + return; + } + // Specify a vector length: + var N = 3; + + // Allocate space for the output: + var out = new Float64Array(2); + + // Create an input array: + var x = oneTo( N, 'float64' ); + + // Perform computation: + var v = dmeanvar.ndarray( N, 1, x, 1, 0, out, 1, 0 ); + + var bool = ( v === out ); + + // Print the result: + console.log( dmeanvar.main( N, 1, x, 1, out, 1 ) ); + console.log(out); + console.log(bool); +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/little_endian_arrays.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/little_endian_arrays.js new file mode 100644 index 000000000000..a3cd21c2c370 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/little_endian_arrays.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var hasWebAssemblySupport = require( '@stdlib/assert/has-wasm-support' ); +var Memory = require( '@stdlib/wasm/memory' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var gfillBy = require( '@stdlib/blas/ext/base/gfill-by' ); +var Float64ArrayLE = require( '@stdlib/array/little-endian-float64' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dmeanvar = 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 new routine: + var mod = new dmeanvar.Module( mem ); + // returns + + // Initialize the routine: + mod.initializeSync(); // eslint-disable-line node/no-sync + + // Specify a vector length: + var N = 3; + + // Allocate space for the output: + var out = new Float64Array(2); + + // Define a pointer (i.e., byte offset) for storing the input vector: + var xptr = 0; + + // Create a typed array view over module memory: + var x = new Float64ArrayLE( mod.memory.buffer, xptr, N ); + + // Write values to module memory: + gfillBy( N, x, 1, discreteUniform( -10.0, 10.0 ) ); + + // Perform computation: + var v = mod.ndarray( N, 1, x, 1, 0, out, 1, 0 ); + + var bool = ( v === out ); + + // Print the result: + console.log( bool ); +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/module.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/module.js new file mode 100644 index 000000000000..b171c4c07ee3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/examples/module.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 Memory = require( '@stdlib/wasm/memory' ); +var oneTo = require( '@stdlib/array/one-to' ); +var dmeanvar = 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 new routine: + var mod = new dmeanvar.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 = 3; + + // Allocate space for the output: + var out = new Float64Array(2); + + // Define a pointer (i.e., byte offset) for storing the input vector: + var xptr = 0; + + // Write vector values to module memory: + mod.write( xptr, oneTo( N, dtype ) ); + + // Perform computation: + var v = mod.ndarray( N, 1, xptr, 1, 0, out, 1, 0 ); + + var bool = ( v === out ); + + // Print the result: + console.log( bool ); +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.browser.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.browser.js new file mode 100644 index 000000000000..f50f9b2086d3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.browser.js @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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( 'AGFzbQEAAAAADwhkeWxpbmsuMAEEAAAAAAEgBGAIf3x/f39/f38AYAAAYAZ/fH9/f38AYAR/f39/AXwCDwEDZW52Bm1lbW9yeQIAAAMGBQECAAADB1EDEV9fd2FzbV9jYWxsX2N0b3JzAAAXc3RkbGliX3N0cmlkZWRfZG1lYW52YXIAAR9zdGRsaWJfc3RyaWRlZF9kbWVhbnZhcl9uZGFycmF5AAMKoAcFAwABCysAIAAgASACIANBASAAayADbEEAIANBAEwbIAQgBUEAIAVrIAVBH3VxEAIL5AICBXwBfwJAIABBAEwEQCAFIAdBA3RqIgBCgICAgICAgPz/ADcDAAwBCyAAuCILIAGhIQEgAEEBR0EAIAMbRQRAIAUgB0EDdGoiACACIARBA3RqKwMAOQMAIAAgBkEDdGohACABRAAAAAAAAAAAZQRAIABCgICAgICAgPz/ADcDAA8LIABCADcDAA8LIAAgAiADIAQQBCALoyIIIAhhBEADQCAAIA1GRQRAIA1BAWohDSAJIAIgBEEDdGorAwAgCKEiDKAhCSAMIAyiIAqgIQogAyAEaiEEDAELCyAFIAdBA3RqIgAgCCAJIAujIgigOQMAIAFEAAAAAAAAAABlBEAMAgsgACAGQQN0aiAKIAGjIAggCSABo6KhOQMADwsgBSAHQQN0aiIAQoCAgICAgID8/wA3AwAgACAGQQN0akKAgICAgICA/P8ANwMADwsgACAGQQN0akKAgICAgICA/P8ANwMACxQAIAAgASACIAMgBCAFIAYgBxACC/IDAgp/CHwgAEEATARARAAAAAAAAAAADwsCQCAAQQdNBEAgASADQQN0aisDACEOQQEhBANAIAAgBEYNAiAEQQFqIQQgDiABIAIgA2oiA0EDdGorAwCgIQ4MAAsACyAAQYABTQRAIAEgA0EDdGoiBCACQThsIghqKwMAIQ4gBCACQTBsIglqKwMAIQ8gBCACQShsIgpqKwMAIRAgBCACQQV0IgtqKwMAIREgBCACQRhsIgxqKwMAIRIgBCACQQR0Ig1qKwMAIRMgBCACQQN0IgZqKwMAIRQgAEH4AXEhByAEKwMAIRVBCCEFA0AgAyAGaiEDIAUgB09FBEAgDiABIANBA3RqIgQgCGorAwCgIQ4gDyAEIAlqKwMAoCEPIBAgBCAKaisDAKAhECARIAQgC2orAwCgIREgEiAEIAxqKwMAoCESIBMgBCANaisDAKAhEyAUIAQgBmorAwCgIRQgBUEIaiEFIBUgBCsDAKAhFQwBCwsgFSAUoCATIBKgoCARIBCgIA8gDqCgoCEOIAdBAWtBeHFBCGohBANAIAAgBEwNAiAEQQFqIQQgDiABIANBA3RqKwMAoCEOIAIgA2ohAwwACwALIABBAXZB+P///wNxIgQgASACIAMQBCAAIARrIAEgAiADIAIgBGxqEASgIQ4LIA4L' ); + + +// EXPORTS // + +module.exports = wasm; diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.js new file mode 100644 index 000000000000..2b83fe651780 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/binary.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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/stats/strided/wasm/dmeanvar/lib/index.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/index.js new file mode 100644 index 000000000000..372c9c9112ee --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/index.js @@ -0,0 +1,109 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 compute the mean and variance of a double-precision floating-point strided array. +* +* @module @stdlib/stats/strided/wasm/dmeanvar +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* +* // Define a strided array: +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); +* // returns [ ~0.3333, ~4.3333 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* +* // Define a strided array: +* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); +* // returns [ 1.25, 6.25 ] +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* +* // 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 new routine: +* var mod = new dmeanvar.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 3; +* +* // Define a pointer (i.e., byte offset) to the first vector element: +* var xptr = 0; +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var y = mod.main( N, 1, xptr, 1, out, 1 ); +* // returns [ 2.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/stats/strided/wasm/dmeanvar/lib/main.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/main.js new file mode 100644 index 000000000000..82a4942c044a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/main.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 routine to compute the mean and variance of a double-precision floating-point strided array. +* +* @name dmeanvar +* @type {Routine} +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* +* // Define a strided array: +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); +* // returns [ ~0.3333, ~4.3333 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* +* // Define a strided array: +* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); +* // returns [ 1.25, 6.25 ] +*/ +var dmeanvar = new Routine(); +dmeanvar.initializeSync(); // eslint-disable-line node/no-sync + + +// EXPORTS // + +module.exports = dmeanvar; diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/module.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/module.js new file mode 100644 index 000000000000..788d662695f6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/module.js @@ -0,0 +1,218 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 // + +/** +* 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 dmeanvar = require( '@stdlib/stats/strided/wasm/dmeanvar' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // 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 new routine: +* var mod = new dmeanvar.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 3; +* +* // Define a pointer (i.e., byte offset) to the first vector element: +* var xptr = 0; +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var y = mod.main( N, 1, xptr, 1, out, 1 ); +* // returns [ 2.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 ); + +/** +* Computes the mean and variance of a double-precision floating-point strided array. +* +* @name main +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} correction - degrees of freedom adjustment +* @param {integer} xptr - input array pointer (i.e., byte offset) +* @param {integer} strideX - stride length +* @param {Float64Array} out - output array +* @param {integer} strideOut - `out` stride length +* @returns {Float64Array} output array +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // 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 new routine: +* var mod = new dmeanvar.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 3; +* +* // Define a pointer (i.e., byte offset) to the first vector element: +* var xptr = 0; +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var y = mod.main( N, 1, xptr, 1, out, 1 ); +* // returns [ 2.0, 1.0 ] +*/ +setReadOnly( Module.prototype, 'main', function dmeanvar( N, correction, xptr, strideX, out, strideOut ) { + return this._instance.exports.stdlib_strided_dmeanvar( N, correction, xptr, strideX, out, strideOut ); // eslint-disable-line max-len +}); + +/** +* Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. +* +* @name ndarray +* @memberof Module.prototype +* @readonly +* @type {Function} +* @param {PositiveNumber} N - number of indexed elements +* @param {PositiveNumber} correction - degrees of freedom adjustment +* @param {integer} xptr - input array pointer (i.e., byte offset) +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @param {Float64Array} out - output array +* @param {integer} strideOut - `out` stride length +* @param {NonNegativeInteger} offsetOut - `out` starting index +* @returns {Float64Array} output array +* +* @example +* var Memory = require( '@stdlib/wasm/memory' ); +* var oneTo = require( '@stdlib/array/one-to' ); +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // 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 new routine: +* var mod = new dmeanvar.Module( mem ); +* // returns +* +* // Initialize the routine: +* mod.initializeSync(); +* +* // Define a vector data type: +* var dtype = 'float64'; +* +* // Specify a vector length: +* var N = 3; +* +* // Define a pointer (i.e., byte offset) to the first vector element: +* var xptr = 0; +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Write vector values to module memory: +* mod.write( xptr, oneTo( N, dtype ) ); +* +* // Perform computation: +* var y = mod.ndarray( N, 1, xptr, 1, 0, out, 1, 0 ); +* // returns [ 2.0, 1.0 ] +*/ +setReadOnly( Module.prototype, 'ndarray', function dmeanvar( N, correction, xptr, strideX, offsetX, out, strideOut, offsetOut ) { + return this._instance.exports.stdlib_strided_dmeanvar_ndarray( N, correction, xptr, strideX, offsetX, out, strideOut, offsetOut ); // eslint-disable-line max-len +}); + + +// EXPORTS // + +module.exports = Module; diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/routine.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/routine.js new file mode 100644 index 000000000000..d76c898490bd --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/lib/routine.js @@ -0,0 +1,182 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 max-len, 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 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 dmeanvar = new Routine(); +* +* // Initialize the module: +* dmeanvar.initializeSync(); +* +* // Define a strided array: +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* var v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); +* // returns [ ~0.3333, ~4.3333 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var dmeanvar = new Routine(); +* +* // Initialize the module: +* dmeanvar.initializeSync(); +* +* // Define a strided array: +* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var y = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); +* // returns [ 1.25, 6.25 ] +*/ +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 ); + +/** +* Computes the mean and variance of a double-precision floating-point strided array. +* +* @name main +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveNumber} correction - degrees of freedom adjustment +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length +* @param {Float64Array} out - output array +* @param {integer} strideOut - `out` stride length +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var dmeanvar = new Routine(); +* +* // Initialize the module: +* dmeanvar.initializeSync(); +* +* // Define a strided array: +* var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.main( 3, 1, x, 1, out, 1 ); +* // returns [ ~0.3333, ~4.3333 ] +*/ +setReadOnly( Routine.prototype, 'main', function dmeanvar( N, correction, x, strideX, out, strideOut ) { + return this.ndarray( N, correction, x, strideX, stride2offset( N, strideX ), out, strideOut, stride2offset( N, strideOut ) ); +}); + +/** +* Computes the mean and variance of a double-precision floating-point strided array using alternative indexing semantics. +* +* @name ndarray +* @memberof Routine.prototype +* @readonly +* @type {Function} +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveNumber} correction - degrees of freedom adjustment +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index +* @param {Float64Array} out - output array +* @param {integer} strideOut - `out` stride length +* @param {NonNegativeInteger} offsetOut - `out` starting index +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* // Create a new routine: +* var dmeanvar = new Routine(); +* +* // Initialize the module: +* dmeanvar.initializeSync(); +* +* // Define a strided array: +* var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); +* +* // Allocate space for the output: +* var out = new Float64Array( 2 ); +* +* // Perform operation: +* var v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 1, 0 ); +* // returns [ 1.25, 6.25 ] +*/ +setReadOnly( Routine.prototype, 'ndarray', function dmeanvar( N, correction, x, strideX, offsetX, out, strideOut, offsetOut ) { + var ptrs; + var p0; + + // Convert the input arrays to "pointers" in the module's memory: + ptrs = arrays2ptrs( this, [ + strided2object( N, x, strideX, offsetX ) + ]); + p0 = ptrs[ 0 ]; + + // Perform computation by calling the corresponding parent method: + return Module.prototype.ndarray.call( this, N, correction, p0.ptr, p0.stride, p0.offset, out, strideOut, offsetOut ); +}); + + +// EXPORTS // + +module.exports = Routine; diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/manifest.json b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/manifest.json new file mode 100644 index 000000000000..958b62fe508a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/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/stats/strided/dmeanvar" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/package.json b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/package.json new file mode 100644 index 000000000000..ce3b161a5616 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/package.json @@ -0,0 +1,90 @@ +{ + "name": "@stdlib/stats/strided/wasm/dmeanvar", + "version": "0.0.0", + "description": "Calculate the mean and variance of a double-precision floating-point strided array.", + "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", + "statistics", + "stats", + "mathematics", + "math", + "mean", + "arithmetic mean", + "average", + "avg", + "central tendency", + "variance", + "var", + "deviation", + "dispersion", + "sample variance", + "unbiased", + "stdev", + "std", + "standard deviation", + "strided", + "strided array", + "typed", + "array", + "float64", + "double", + "float64array", + "webassembly", + "wasm" + ], + "__stdlib__": { + "wasm": true + } +} diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/build.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/build.js new file mode 100644 index 000000000000..66bf9650b6d6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/build.js @@ -0,0 +1,66 @@ +#!/usr/bin/env node + +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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' ); +var currentYear = require( '@stdlib/time/current-year' ); + + +// 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}}'; +var YEAR = '{{YEAR}}'; + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var wasm; + var tmpl; + + wasm = readFile( wpath ); + tmpl = readFile( tpath, opts ); + + tmpl = replace( tmpl, YEAR, currentYear().toString() ); + tmpl = replace( tmpl, PLACEHOLDER, wasm.toString( 'base64' ) ); + + writeFile( opath, tmpl, opts ); +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/template.txt b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/template.txt new file mode 100644 index 000000000000..f66cdb9735b1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/scripts/template.txt @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) {{YEAR}} 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/stats/strided/wasm/dmeanvar/src/Makefile b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/Makefile new file mode 100644 index 000000000000..1b1f35347760 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/Makefile @@ -0,0 +1,243 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +#/ +# To compile targets listed in this Makefile, use top-level project `make` +# commands rather than commands listed in this Makefile. The top-level project +# `make` commands will ensure that various environment variables and flags are +# appropriately set. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files to WebAssembly: +ifdef EMCC_COMPILER + EMCC := $(EMCC_COMPILER) +else + EMCC := emcc +endif + +# Define the program used for compiling WebAssembly files to the WebAssembly text format: +ifdef WASM2WAT + WASM_TO_WAT := $(WASM2WAT) +else + WASM_TO_WAT := wasm2wat +endif + +# Define the program used for compiling WebAssembly files to JavaScript: +ifdef WASM2JS + WASM_TO_JS := $(WASM2JS) +else + WASM_TO_JS := wasm2js +endif + +# Define the path to the Node.js executable: +ifdef NODE + NODEJS := $(NODE) +else + NODEJS := node +endif + +# Define the integer size: +ifdef CBLAS_INT + INT_TYPE := $(CBLAS_INT) +else + INT_TYPE := int32_t +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -flto \ + -Wall \ + -pedantic \ + -D CBLAS_INT=$(INT_TYPE) + +# Define the command-line options when compiling C files to WebAssembly and asm.js: +EMCCFLAGS ?= $(CFLAGS) + +# Define shared `emcc` flags: +EMCC_SHARED_FLAGS := \ + -Oz \ + -fwasm-exceptions \ + -s SUPPORT_LONGJMP=1 \ + -s SIDE_MODULE=2 \ + -s EXPORTED_FUNCTIONS="$(shell cat exports.json | tr -d ' \t\n' | sed s/\"/\'/g)" + +# Define WebAssembly `emcc` flags: +EMCC_WASM_FLAGS := $(EMCC_SHARED_FLAGS) \ + -s WASM=1 \ + -s WASM_BIGINT=0 + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of WebAssembly targets: +wasm_targets := main.wasm + +# List of WebAssembly WAT targets: +wat_targets := main.wat + +# List of WebAssembly JavaScript targets: +wasm_js_targets := main.wasm.js + +# List of other JavaScript targets: +browser_js_targets := ./../lib/binary.browser.js + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [EMCC_COMPILER] - EMCC compiler (e.g., `emcc`) +# @param {string} [EMCCFLAGS] - EMCC compiler options +# @param {string} [WASM2WAT] - WebAssembly text format compiler (e.g., `wasm2wat`) +# @param {string} [WASM2JS] - WebAssembly JavaScript compiler (e.g., `wasm2js`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: wasm + +.PHONY: all + +#/ +# Compiles source files to WebAssembly. +# +# @param {string} [EMCC_COMPILER] - EMCC compiler (e.g., `emcc`) +# @param {string} [EMCCFLAGS] - EMCC compiler options +# @param {string} [WASM2WAT] - WebAssembly text format compiler (e.g., `wasm2wat`) +# @param {string} [WASM2JS] - WebAssembly JavaScript compiler (e.g., `wasm2js`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make wasm +#/ +wasm: $(wasm_targets) $(wat_targets) $(browser_js_targets) + +.PHONY: wasm + +#/ +# Compiles C source files to WebAssembly binaries. +# +# @private +# @param {string} EMCC - EMCC compiler (e.g., `emcc`) +# @param {string} EMCCFLAGS - EMCC compiler options +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(wasm_targets): + $(QUIET) $(EMCC) $(EMCCFLAGS) $(EMCC_WASM_FLAGS) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) $(LIBRARIES) + +#/ +# Compiles WebAssembly binary files to the WebAssembly text format. +# +# @private +# @param {string} WASM2WAT - WAT compiler (e.g., `wasm2wat`) +#/ +$(wat_targets): %.wat: %.wasm + $(QUIET) $(WASM_TO_WAT) -o $@ $(wasm_targets) + +#/ +# Compiles WebAssembly binary files to JavaScript. +# +# @private +# @param {string} WASM2JS - JavaScript compiler (e.g., `wasm2js`) +#/ +$(wasm_js_targets): %.wasm.js: %.wasm + $(QUIET) $(WASM_TO_JS) -o $@ $(wasm_targets) + +#/ +# Generates an inline WebAssembly build for use in bundlers. +# +# @private +# @param {string} NODE - Node.js executable +#/ +$(browser_js_targets): $(wasm_targets) + $(QUIET) $(NODEJS) ./../scripts/build.js + +#/ +# Removes generated WebAssembly files. +# +# @example +# make clean-wasm +#/ +clean-wasm: + $(QUIET) -rm -f *.wasm *.wat *.wasm.js $(browser_js_targets) + +.PHONY: clean-wasm + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-wasm + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/exports.json b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/exports.json new file mode 100644 index 000000000000..fd20794dc00e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/exports.json @@ -0,0 +1,4 @@ +[ + "_stdlib_strided_dmeanvar", + "_stdlib_strided_dmeanvar_ndarray" +] diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wasm b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wasm new file mode 100755 index 000000000000..2445d8280765 Binary files /dev/null and b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wasm differ diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wat b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wat new file mode 100644 index 000000000000..035b6472deb1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/src/main.wat @@ -0,0 +1,505 @@ +;; @license Apache-2.0 +;; +;; Copyright (c) 2025 The Stdlib Authors. +;; +;; Licensed under the Apache License, Version 2.0 (the "License"); +;; you may not use this file except in compliance with the License. +;; 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 (param i32 f64 i32 i32 i32 i32 i32 i32))) + (type (;1;) (func)) + (type (;2;) (func (param i32 f64 i32 i32 i32 i32))) + (type (;3;) (func (param i32 i32 i32 i32) (result f64))) + (import "env" "memory" (memory (;0;) 0)) + (func (;0;) (type 1) + nop) + (func (;1;) (type 2) (param i32 f64 i32 i32 i32 i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + i32.const 1 + local.get 0 + i32.sub + local.get 3 + i32.mul + i32.const 0 + local.get 3 + i32.const 0 + i32.le_s + select + local.get 4 + local.get 5 + i32.const 0 + local.get 5 + i32.sub + local.get 5 + i32.const 31 + i32.shr_s + i32.and + call 2) + (func (;2;) (type 0) (param i32 f64 i32 i32 i32 i32 i32 i32) + (local f64 f64 f64 f64 f64 i32) + block ;; label = @1 + local.get 0 + i32.const 0 + i32.le_s + if ;; label = @2 + local.get 5 + local.get 7 + i32.const 3 + i32.shl + i32.add + local.tee 0 + i64.const 9221120237041090560 + i64.store + br 1 (;@1;) + end + local.get 0 + f64.convert_i32_u + local.tee 11 + local.get 1 + f64.sub + local.set 1 + local.get 0 + i32.const 1 + i32.ne + i32.const 0 + local.get 3 + select + i32.eqz + if ;; label = @2 + local.get 5 + local.get 7 + i32.const 3 + i32.shl + i32.add + local.tee 0 + local.get 2 + local.get 4 + i32.const 3 + i32.shl + i32.add + f64.load + f64.store + local.get 0 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.set 0 + local.get 1 + f64.const 0x0p+0 (;=0;) + f64.le + if ;; label = @3 + local.get 0 + i64.const 9221120237041090560 + i64.store + return + end + local.get 0 + i64.const 0 + i64.store + return + end + local.get 0 + local.get 2 + local.get 3 + local.get 4 + call 4 + local.get 11 + f64.div + local.tee 8 + local.get 8 + f64.eq + if ;; label = @2 + loop ;; label = @3 + local.get 0 + local.get 13 + i32.eq + i32.eqz + if ;; label = @4 + local.get 13 + i32.const 1 + i32.add + local.set 13 + local.get 9 + local.get 2 + local.get 4 + i32.const 3 + i32.shl + i32.add + f64.load + local.get 8 + f64.sub + local.tee 12 + f64.add + local.set 9 + local.get 12 + local.get 12 + f64.mul + local.get 10 + f64.add + local.set 10 + local.get 3 + local.get 4 + i32.add + local.set 4 + br 1 (;@3;) + end + end + local.get 5 + local.get 7 + i32.const 3 + i32.shl + i32.add + local.tee 0 + local.get 8 + local.get 9 + local.get 11 + f64.div + local.tee 8 + f64.add + f64.store + local.get 1 + f64.const 0x0p+0 (;=0;) + f64.le + if ;; label = @3 + br 2 (;@1;) + end + local.get 0 + local.get 6 + i32.const 3 + i32.shl + i32.add + local.get 10 + local.get 1 + f64.div + local.get 8 + local.get 9 + local.get 1 + f64.div + f64.mul + f64.sub + f64.store + return + end + local.get 5 + local.get 7 + i32.const 3 + i32.shl + i32.add + local.tee 0 + i64.const 9221120237041090560 + i64.store + local.get 0 + local.get 6 + i32.const 3 + i32.shl + i32.add + i64.const 9221120237041090560 + i64.store + return + end + local.get 0 + local.get 6 + i32.const 3 + i32.shl + i32.add + i64.const 9221120237041090560 + i64.store) + (func (;3;) (type 0) (param i32 f64 i32 i32 i32 i32 i32 i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + local.get 4 + local.get 5 + local.get 6 + local.get 7 + call 2) + (func (;4;) (type 3) (param i32 i32 i32 i32) (result f64) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 f64 f64 f64 f64 f64 f64 f64 f64) + local.get 0 + i32.const 0 + i32.le_s + if ;; label = @1 + f64.const 0x0p+0 (;=0;) + return + end + block ;; label = @1 + local.get 0 + i32.const 7 + i32.le_u + if ;; label = @2 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + f64.load + local.set 14 + i32.const 1 + local.set 4 + loop ;; label = @3 + local.get 0 + local.get 4 + i32.eq + br_if 2 (;@1;) + local.get 4 + i32.const 1 + i32.add + local.set 4 + local.get 14 + local.get 1 + local.get 2 + local.get 3 + i32.add + local.tee 3 + i32.const 3 + i32.shl + i32.add + f64.load + f64.add + local.set 14 + br 0 (;@3;) + end + unreachable + end + local.get 0 + i32.const 128 + i32.le_u + if ;; label = @2 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 4 + local.get 2 + i32.const 56 + i32.mul + local.tee 8 + i32.add + f64.load + local.set 14 + local.get 4 + local.get 2 + i32.const 48 + i32.mul + local.tee 9 + i32.add + f64.load + local.set 15 + local.get 4 + local.get 2 + i32.const 40 + i32.mul + local.tee 10 + i32.add + f64.load + local.set 16 + local.get 4 + local.get 2 + i32.const 5 + i32.shl + local.tee 11 + i32.add + f64.load + local.set 17 + local.get 4 + local.get 2 + i32.const 24 + i32.mul + local.tee 12 + i32.add + f64.load + local.set 18 + local.get 4 + local.get 2 + i32.const 4 + i32.shl + local.tee 13 + i32.add + f64.load + local.set 19 + local.get 4 + local.get 2 + i32.const 3 + i32.shl + local.tee 6 + i32.add + f64.load + local.set 20 + local.get 0 + i32.const 248 + i32.and + local.set 7 + local.get 4 + f64.load + local.set 21 + i32.const 8 + local.set 5 + loop ;; label = @3 + local.get 3 + local.get 6 + i32.add + local.set 3 + local.get 5 + local.get 7 + i32.ge_u + i32.eqz + if ;; label = @4 + local.get 14 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + local.tee 4 + local.get 8 + i32.add + f64.load + f64.add + local.set 14 + local.get 15 + local.get 4 + local.get 9 + i32.add + f64.load + f64.add + local.set 15 + local.get 16 + local.get 4 + local.get 10 + i32.add + f64.load + f64.add + local.set 16 + local.get 17 + local.get 4 + local.get 11 + i32.add + f64.load + f64.add + local.set 17 + local.get 18 + local.get 4 + local.get 12 + i32.add + f64.load + f64.add + local.set 18 + local.get 19 + local.get 4 + local.get 13 + i32.add + f64.load + f64.add + local.set 19 + local.get 20 + local.get 4 + local.get 6 + i32.add + f64.load + f64.add + local.set 20 + local.get 5 + i32.const 8 + i32.add + local.set 5 + local.get 21 + local.get 4 + f64.load + f64.add + local.set 21 + br 1 (;@3;) + end + end + local.get 21 + local.get 20 + f64.add + local.get 19 + local.get 18 + f64.add + f64.add + local.get 17 + local.get 16 + f64.add + local.get 15 + local.get 14 + f64.add + f64.add + f64.add + local.set 14 + local.get 7 + i32.const 1 + i32.sub + i32.const -8 + i32.and + i32.const 8 + i32.add + local.set 4 + loop ;; label = @3 + local.get 0 + local.get 4 + i32.le_s + br_if 2 (;@1;) + local.get 4 + i32.const 1 + i32.add + local.set 4 + local.get 14 + local.get 1 + local.get 3 + i32.const 3 + i32.shl + i32.add + f64.load + f64.add + local.set 14 + local.get 2 + local.get 3 + i32.add + local.set 3 + br 0 (;@3;) + end + unreachable + end + local.get 0 + i32.const 1 + i32.shr_u + i32.const 1073741816 + i32.and + local.tee 4 + local.get 1 + local.get 2 + local.get 3 + call 4 + local.get 0 + local.get 4 + i32.sub + local.get 1 + local.get 2 + local.get 3 + local.get 2 + local.get 4 + i32.mul + i32.add + call 4 + f64.add + local.set 14 + end + local.get 14) + (export "__wasm_call_ctors" (func 0)) + (export "stdlib_strided_dmeanvar" (func 1)) + (export "stdlib_strided_dmeanvar_ndarray" (func 3))) diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.js new file mode 100644 index 000000000000..12b8f14d04b8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.js @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 dmeanvar = require( './../lib' ); + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dmeanvar, 'object', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `main` method', function test( t ) { + t.strictEqual( typeof dmeanvar.main, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is an `ndarray` method', function test( t ) { + t.strictEqual( typeof dmeanvar.ndarray, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `Module` constructor', function test( t ) { + t.strictEqual( typeof dmeanvar.Module, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'the main export is a `Module` instance', function test( t ) { + t.strictEqual( dmeanvar instanceof dmeanvar.Module, true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.main.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.main.js new file mode 100644 index 000000000000..3c743880b7f4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.main.js @@ -0,0 +1,290 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dmeanvar = require( './../lib' ); + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dmeanvar, 'object', 'main export is an object' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( dmeanvar.main.length, 6, 'has expected arity' ); + t.end(); +}); + +tape( 'the `main` method that calculates the arithmetic mean and population variance of a strided array', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 0, x, 1, out, 1 ); + + expected = new Float64Array( [ 0.5, 53.5/x.length ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ -4.0, -4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 0, x, 1, out, 1 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ NaN, 4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 0, x, 1, out, 1 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `main` method that calculates the arithmetic mean and sample variance of a strided array', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); + + expected = new Float64Array( [ 0.5, 53.5/(x.length-1) ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ -4.0, -4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ NaN, 4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, 1, x, 1, out, 1 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the `main` method returns `NaN` values', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( 0, 1, x, 1, out, 1 ); + + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( -1, 1, x, 1, out, 1 ); + + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the `main` method returns a population variance of `0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( 1, 0, x, 1, out, 1 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the `main` method returns a variance equal to `NaN`', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( 1, 1, x, 1, out, 1 ); + + t.strictEqual( v[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, x.length, x, 0, out, 1 ); + + t.strictEqual( v[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, x.length, x, 1, out, 1 ); + + t.strictEqual( v[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.main( x.length, x.length+1, x, 1, out, 1 ); + + t.strictEqual( v[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `main` method supports `stride` parameters', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]); + out = new Float64Array( 4 ); + + v = dmeanvar.main( 4, 1, x, 2, out, 2 ); + + expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `main` method supports negative `stride` parameters', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + out = new Float64Array( 4 ); + + v = dmeanvar.main( 4, 1, x, -2, out, -2 ); + + expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the `main` method returns an arithmetic mean equal to the first element and a variance of `0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + out = new Float64Array( 2 ); + + v = dmeanvar.main( x.length, 1, x, 0, out, 1 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the `main` method supports view offsets', function test( t ) { + var expected0; + var expected1; + var out0; + var out1; + var x0; + var x1; + var v; + + x0 = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + 6.0 + ]); + out0 = new Float64Array( 4 ); + + x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at the 3rd element + + v = dmeanvar.main( 4, 1, x1, 2, out1, 1 ); + + expected0 = new Float64Array( [ 0.0, 0.0, 1.25, 6.25 ] ); + expected1 = new Float64Array( [ 1.25, 6.25 ] ); + + t.deepEqual( out0, expected0, 'returns expected value' ); + t.deepEqual( v, expected1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.js new file mode 100644 index 000000000000..0cdcd97ef151 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.js @@ -0,0 +1,154 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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/stats/strided/wasm/dmeanvar/test/test.module.main.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.main.js new file mode 100644 index 000000000000..6365beea17f6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.main.js @@ -0,0 +1,388 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Module = require( './../lib' ).Module; + + +// 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 that calculates the arithmetic mean and population variance of a strided array', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 6, 0, xp, 1, out, 1 ); + + expected = new Float64Array( [ 0.5, 53.5/6 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ -4.0, -4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 2, 0, xp, 1, out, 1 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ NaN, 4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 2, 0, xp, 1, out, 1 ); + + t.strictEqual( y, out, 'returns expected value' ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has a `main` method that calculates the arithmetic mean and sample variance of a strided array', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 6, 1, xp, 1, out, 1 ); + + expected = new Float64Array( [ 0.5, 53.5/5 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ -4.0, -4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 2, 1, xp, 1, out, 1 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ NaN, 4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 2, 1, xp, 1, out, 1 ); + + t.strictEqual( y, out, 'returns expected value' ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, '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 returns `NaN` values', function test( t ) { + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 0, 1, xp, 1, out, 1 ); + + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.main( -1, 1, xp, 1, out, 1 ); + + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, a module instance has a `main` method which returns a population variance of `0`', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 1, 0, xp, 1, out, 1 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, a module instance has a `main` method which returns a variance equal to `NaN`', function test( t ) { + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.main( 1, 1, xp, 1, out, 1 ); + + t.strictEqual( y[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.main( 6, 6, xp, 0, out, 1 ); + + t.strictEqual( y[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.main( 6, 6, xp, 1, out, 1 ); + + t.strictEqual( y[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.main( 6, 7, xp, 1, out, 1 ); + + t.strictEqual( y[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports a `stride` parameter', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ])); + out = new Float64Array( 4 ); + + y = mod.main( 4, 1, xp, 2, out, 2 ); + + expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports a negative `stride` parameter', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ])); + out = new Float64Array( 4 ); + + y = mod.main( 4, 1, xp, -2, out, -2 ); + + expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, a module instance has a `main` method which returns an arithmetic mean equal to the first element and a variance of `0`', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ) ); + out = new Float64Array( 2 ); + + y = mod.main( 5, 1, xp, 0, out, 1 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has a `main` method which supports view offsets', function test( t ) { + var expected0; + var expected1; + var out0; + var out1; + var mem; + var mod; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + 6.0 + ])); + out0 = new Float64Array( 4 ); + + out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*2 ); // start at the 3rd element + + y = mod.main( 4, 1, xp, 2, out1, 1 ); + + expected0 = new Float64Array( [ 0.0, 0.0, 1.25, 6.25 ] ); + expected1 = new Float64Array( [ 1.25, 6.25 ] ); + + t.deepEqual( out0, expected0, 'returns expected value' ); + t.deepEqual( y, expected1, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.ndarray.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.ndarray.js new file mode 100644 index 000000000000..6214799b6923 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.module.ndarray.js @@ -0,0 +1,363 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var Module = require( './../lib' ).Module; + + +// 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 which calculates the arithmetic mean and population variance of a strided array', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 6, 0, xp, 1, 0, out, 1, 0 ); + expected = new Float64Array( [ 0.5, 53.5/6 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ -4.0, -4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 2, 0, xp, 1, 0, out, 1, 0 ); + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ NaN, 4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 2, 0, xp, 1, 0, out, 1, 0 ); + t.strictEqual( y, out, 'returns expected value' ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which calculates the arithmetic mean and sample variance of a strided array', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 6, 1, xp, 1, 0, out, 1, 0 ); + expected = new Float64Array( [ 0.5, 53.5/5 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ -4.0, -4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 2, 1, xp, 1, 0, out, 1, 0 ); + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( y, out, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + mod.write( xp, new Float64Array( [ NaN, 4.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 2, 1, xp, 1, 0, out, 1, 0 ); + t.strictEqual( y, out, 'returns expected value' ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, '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 returns `NaN`', function test( t ) { + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 0, 1, xp, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.ndarray( -1, 1, xp, 1, 0, out, 1, 0 ); + t.strictEqual( isnan( y[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, a module instance has an `ndarray` method which returns a population variance of `0`', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 1, 0, xp, 1, 0, out, 1, 0 ); + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, a module instance has an `ndarray` method which returns a variance equal to `NaN`', function test( t ) { + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ) ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 1, 1, xp, 1, 0, out, 1, 0 ); + t.strictEqual( y[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 6, 6, xp, 0, 0, out, 1, 0 ); + t.strictEqual( y[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 6, 6, xp, 1, 0, out, 1, 0 ); + t.strictEqual( y[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + y = mod.ndarray( 6, 7, xp, 1, 0, out, 1, 0 ); + t.strictEqual( y[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( y[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a `stride` parameter', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ])); + out = new Float64Array( 4 ); + + y = mod.ndarray( 4, 1, xp, 2, 0, out, 2, 0 ); + expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports a negative `stride` parameter', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ])); + out = new Float64Array( 4 ); + + y = mod.ndarray( 4, 1, xp, -2, 6, out, -2, 2 ); + expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, a module instance has an `ndarray` method which returns an arithmetic mean equal to the first element and a variance of `0`', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ) ); + out = new Float64Array( 2 ); + + y = mod.ndarray( 5, 1, xp, 0, 0, out, 1, 0 ); + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'a module instance has an `ndarray` method which supports `offset` parameters', function test( t ) { + var expected; + var mem; + var mod; + var out; + var xp; + var y; + + mem = new Memory({ + 'initial': 1 + }); + mod = new Module( mem ); + mod.initializeSync(); + + xp = 0; + + mod.write( xp, new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ])); + out = new Float64Array( 4 ); + + y = mod.ndarray( 4, 1, xp, 2, 1, out, 2, 1 ); + expected = new Float64Array( [ 0.0, 1.25, 0.0, 6.25 ] ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.ndarray.js new file mode 100644 index 000000000000..639ac4753024 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.ndarray.js @@ -0,0 +1,280 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var dmeanvar = require( './../lib' ); + + +// TESTS // + +tape( 'main export is an object', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dmeanvar, 'object', 'main export is an object' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dmeanvar.ndarray.length, 8, 'has expected arity' ); + t.end(); +}); + +tape( 'the function calculates the arithmetic mean and population variance of a strided array', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 0, x, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.5, 53.5/x.length ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ -4.0, -4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 0, x, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ NaN, 4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 0, x, 1, 0, out, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates the arithmetic mean and sample variance of a strided array', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 0.5, 53.5/(x.length-1) ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ -4.0, -4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ -4.0, 0.0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.deepEqual( v, expected, 'returns expected value' ); + + x = new Float64Array( [ NaN, 4.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` values', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( 0, 1, x, 1, 0, out, 1, 0 ); + + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( -1, 1, x, 1, 0, out, 1, 0 ); + + t.strictEqual( isnan( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter equal to `1`, the function returns a population variance of `0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( 1, 0, x, 1, 0, out, 1, 0 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `correction` parameter yielding `N-correction` less than or equal to `0`, the function returns a variance equal to `NaN`', function test( t ) { + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 0.0, 3.0 ] ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( 1, 1, x, 1, 0, out, 1, 0 ); + + t.strictEqual( v[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, x.length, x, 0, 0, out, 1, 0 ); + + t.strictEqual( v[ 0 ], 1.0, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, x.length, x, 1, 0, out, 1, 0 ); + + t.strictEqual( v[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float64Array( 2 ); + v = dmeanvar.ndarray( x.length, x.length+1, x, 1, 0, out, 1, 0 ); + + t.strictEqual( v[ 0 ], 0.5, 'returns expected value' ); + t.strictEqual( isnan( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports `stride` parameters', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0 + ]); + out = new Float64Array( 4 ); + + v = dmeanvar.ndarray( 4, 1, x, 2, 0, out, 2, 0 ); + + expected = new Float64Array( [ 1.25, 0.0, 6.25, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative `stride` parameters', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array([ + 1.0, // 3 + 2.0, + 2.0, // 2 + -7.0, + -2.0, // 1 + 3.0, + 4.0, // 0 + 2.0 + ]); + out = new Float64Array( 4 ); + + v = dmeanvar.ndarray( 4, 1, x, -2, 6, out, -2, 2 ); + + expected = new Float64Array( [ 6.25, 0.0, 1.25, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `stride` parameter equal to `0`, the function returns an arithmetic mean equal to the first element and a variance of `0`', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + out = new Float64Array( 2 ); + + v = dmeanvar.ndarray( x.length, 1, x, 0, 0, out, 1, 0 ); + + expected = new Float64Array( [ 1.0, 0.0 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports `offset` parameters', function test( t ) { + var expected; + var out; + var x; + var v; + + x = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0 // 3 + ]); + out = new Float64Array( 4 ); + + v = dmeanvar.ndarray( 4, 1, x, 2, 1, out, 2, 1 ); + + expected = new Float64Array( [ 0.0, 1.25, 0.0, 6.25 ] ); + t.deepEqual( v, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.routine.js b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.routine.js new file mode 100644 index 000000000000..806b3de987e3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/wasm/dmeanvar/test/test.routine.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* 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 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(); +});

AltStyle によって変換されたページ (->オリジナル) /