From f7d9df8f65c29baf1d191255b20d0a422969485c Mon Sep 17 00:00:00 2001 From: Priyanshu Agarwal Date: Wed, 6 Mar 2024 02:08:08 +0530 Subject: [PATCH 1/2] refactor: update blas/ext/base/snansumpw to follow current projects conventions Updated the package to follow current projects conventions Fixes #1532 --- .../@stdlib/blas/ext/base/snansumpw/README.md | 38 +++++++++---------- .../ext/base/snansumpw/benchmark/benchmark.js | 30 +++++++++------ .../snansumpw/benchmark/benchmark.native.js | 26 +++++++------ .../snansumpw/benchmark/benchmark.ndarray.js | 30 +++++++++------ .../benchmark/benchmark.ndarray.native.js | 26 +++++++------ .../ext/base/snansumpw/benchmark/c/Makefile | 2 +- .../snansumpw/benchmark/c/benchmark.length.c | 2 +- .../blas/ext/base/snansumpw/binding.gyp | 2 +- .../blas/ext/base/snansumpw/docs/repl.txt | 16 +++----- .../ext/base/snansumpw/examples/c/Makefile | 2 +- .../ext/base/snansumpw/examples/c/example.c | 2 +- .../blas/ext/base/snansumpw/examples/index.js | 23 ++++++----- .../blas/ext/base/snansumpw/include.gypi | 4 +- .../include/stdlib/blas/ext/base/snansumpw.h | 2 +- .../blas/ext/base/snansumpw/lib/index.js | 6 +-- .../blas/ext/base/snansumpw/lib/main.js | 2 +- .../blas/ext/base/snansumpw/lib/native.js | 2 +- .../blas/ext/base/snansumpw/lib/ndarray.js | 6 +-- .../ext/base/snansumpw/lib/ndarray.native.js | 15 +++----- .../blas/ext/base/snansumpw/lib/snansumpw.js | 2 +- .../base/snansumpw/lib/snansumpw.native.js | 2 +- .../blas/ext/base/snansumpw/src/Makefile | 2 +- .../base/snansumpw/src/{addon.cpp => addon.c} | 2 +- .../blas/ext/base/snansumpw/src/snansumpw.c | 2 +- .../blas/ext/base/snansumpw/test/test.js | 2 +- .../ext/base/snansumpw/test/test.ndarray.js | 11 +++--- .../snansumpw/test/test.ndarray.native.js | 11 +++--- .../ext/base/snansumpw/test/test.snansumpw.js | 11 +++--- .../snansumpw/test/test.snansumpw.native.js | 11 +++--- 29 files changed, 146 insertions(+), 146 deletions(-) rename lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/{addon.cpp => addon.c} (98%) diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md index 281a6dac1d0b..adb56ec9037d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2020 The Stdlib Authors. +Copyright (c) 2024 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -56,16 +56,14 @@ The function has the following parameters: - **x**: input [`Float32Array`][@stdlib/array/float32]. - **stride**: index increment for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the sum of every other element in `x`, +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the sum of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, NaN, -7.0, NaN, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = snansumpw( N, x, 2 ); +var v = snansumpw( 4, x, 2 ); // returns 5.0 ``` @@ -75,14 +73,11 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = snansumpw( N, x1, 2 ); +var v = snansumpw( 4, x1, 2 ); // returns 5.0 ``` @@ -108,12 +103,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, NaN, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = snansumpw.ndarray( N, x, 2, 1 ); +var v = snansumpw.ndarray( 4, x, 2, 1 ); // returns 5.0 ``` @@ -139,22 +132,25 @@ var v = snansumpw.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var snansumpw = require( '@stdlib/blas/ext/base/snansumpw' ); var x; var i; +var randu; -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( randu()*100.0 ); +function rand() { + i = discreteUniform( 0, 99 ); + if ( i < 20 ) { + return NaN; } + return i; } + +randu = rand(); + +x = filledarrayBy( 10, 'float32', randu ); console.log( x ); var v = snansumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js index 37eb34e8b302..fbd5c9d79e61 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,28 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var snansumpw = require( './../lib/snansumpw.js' ); +// VARIABLES // + +var randu; +var i; +function rand() { + i = uniform( 0, 99 ); + if ( i < 20 ) { + return NaN; + } + return i; +} +randu = rand(); + + // FUNCTIONS // /** @@ -40,16 +54,8 @@ var snansumpw = require( './../lib/snansumpw.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; - } - } + x = filledarrayBy( len, 'float32', randu ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js index 50ea045607e0..69c27835d094 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,20 +22,30 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; // VARIABLES // +var randu; +var i; var snansumpw = tryRequire( resolve( __dirname, './../lib/snansumpw.native.js' ) ); var opts = { 'skip': ( snansumpw instanceof Error ) }; +function rand() { + i = uniform( 0, 99 ); + if ( i < 20 ) { + return NaN; + } + return i; +} +randu = rand(); // FUNCTIONS // @@ -49,16 +59,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; - } - } + x = filledarrayBy( len, 'float32', randu ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js index b507758ef1b9..aedc1a73a331 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,14 +21,28 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var snansumpw = require( './../lib/ndarray.js' ); +// VARIABLES // + +var randu; +var i; +function rand() { + i = uniform( 0, 99 ); + if ( i < 20 ) { + return NaN; + } + return i; +} +randu = rand(); + + // FUNCTIONS // /** @@ -40,16 +54,8 @@ var snansumpw = require( './../lib/ndarray.js' ); */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; - } - } + x = filledarrayBy( len, 'float32', randu ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js index 03339fffd957..ea7fe483767b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,20 +22,30 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; // VARIABLES // +var randu; +var i; var snansumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( snansumpw instanceof Error ) }; +function rand() { + i = uniform( 0, 99 ); + if ( i < 20 ) { + return NaN; + } + return i; +} +randu = rand(); // FUNCTIONS // @@ -49,16 +59,8 @@ var opts = { */ function createBenchmark( len ) { var x; - var i; - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*10.0 ) - 20.0; - } - } + x = filledarrayBy( len, 'float32', randu ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile index 7280962b4c4d..9f97140e7cb0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c index f41ca72fb6b7..5185ee47b008 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp index 7d0005b2e390..ec3992233442 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/docs/repl.txt index c2c03a524234..9b9cdb809479 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + 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. @@ -36,19 +36,16 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 4, x, 2 ) 1.0 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 4, x1, 2 ) -1.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation and alternative indexing @@ -86,8 +83,7 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 4, x, 2, 1 ) -1.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile index ff5293d3059f..6aed70daf167 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c index e6f10680c330..90fb64c1f7b0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js index de44085eb881..741063981c9c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2024 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,22 +18,25 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float32Array = require( '@stdlib/array/float32' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var snansumpw = require( './../lib' ); var x; var i; +var randu; -x = new Float32Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = round( randu()*100.0 ); +function rand() { + i = discreteUniform( 0, 99 ); + if ( i < 20 ) { + return NaN; } + return i; } + +randu = rand(); + +x = filledarrayBy( 10, 'float32', randu ); console.log( x ); var v = snansumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi index 868c5c12e852..575cb043c0bf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# Copyright (c) 2024 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' Date: Sun, 14 Apr 2024 22:19:34 -0400 Subject: [PATCH 2/2] chore: clean-up and rewrite addon.c --- .../@stdlib/blas/ext/base/snansumpw/README.md | 18 +-- .../ext/base/snansumpw/benchmark/benchmark.js | 30 ++--- .../snansumpw/benchmark/benchmark.native.js | 26 ++-- .../snansumpw/benchmark/benchmark.ndarray.js | 30 ++--- .../benchmark/benchmark.ndarray.native.js | 24 ++-- .../ext/base/snansumpw/benchmark/c/Makefile | 2 +- .../snansumpw/benchmark/c/benchmark.length.c | 2 +- .../blas/ext/base/snansumpw/binding.gyp | 2 +- .../ext/base/snansumpw/examples/c/Makefile | 2 +- .../ext/base/snansumpw/examples/c/example.c | 2 +- .../blas/ext/base/snansumpw/examples/index.js | 16 +-- .../blas/ext/base/snansumpw/include.gypi | 2 +- .../include/stdlib/blas/ext/base/snansumpw.h | 2 +- .../blas/ext/base/snansumpw/lib/index.js | 2 +- .../blas/ext/base/snansumpw/lib/main.js | 2 +- .../blas/ext/base/snansumpw/lib/native.js | 2 +- .../blas/ext/base/snansumpw/lib/ndarray.js | 2 +- .../ext/base/snansumpw/lib/ndarray.native.js | 2 +- .../blas/ext/base/snansumpw/lib/snansumpw.js | 2 +- .../base/snansumpw/lib/snansumpw.native.js | 2 +- .../blas/ext/base/snansumpw/manifest.json | 120 ++++++++++++------ .../blas/ext/base/snansumpw/src/Makefile | 2 +- .../blas/ext/base/snansumpw/src/addon.c | 111 +++------------- .../blas/ext/base/snansumpw/src/snansumpw.c | 2 +- .../blas/ext/base/snansumpw/test/test.js | 2 +- .../ext/base/snansumpw/test/test.ndarray.js | 14 +- .../snansumpw/test/test.ndarray.native.js | 14 +- .../ext/base/snansumpw/test/test.snansumpw.js | 14 +- .../snansumpw/test/test.snansumpw.native.js | 14 +- 29 files changed, 189 insertions(+), 276 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md index adb56ec9037d..7eb812cb24fb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2020 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. @@ -132,25 +132,19 @@ var v = snansumpw.ndarray( 4, x, 2, 1 ); ```javascript -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var snansumpw = require( '@stdlib/blas/ext/base/snansumpw' ); -var x; -var i; -var randu; - function rand() { - i = discreteUniform( 0, 99 ); - if ( i < 20 ) { + if ( bernoulli( 0.2 ) > 0 ) { return NaN; } - return i; + return discreteUniform( 0, 100 ); } -randu = rand(); - -x = filledarrayBy( 10, 'float32', randu ); +var x = filledarrayBy( 10, 'float32', rand ); console.log( x ); var v = snansumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js index fbd5c9d79e61..1b470fe0f701 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); @@ -29,20 +30,6 @@ var pkg = require( './../package.json' ).name; var snansumpw = require( './../lib/snansumpw.js' ); -// VARIABLES // - -var randu; -var i; -function rand() { - i = uniform( 0, 99 ); - if ( i < 20 ) { - return NaN; - } - return i; -} -randu = rand(); - - // FUNCTIONS // /** @@ -53,11 +40,16 @@ randu = rand(); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = filledarrayBy( len, 'float32', randu ); + var x = filledarrayBy( len, 'float32', rand ); return benchmark; + function rand() { + if ( bernoulli( 0.8 ) > 0 ) { + return uniform( -10, 10 ); + } + return NaN; + } + function benchmark( b ) { var v; var i; diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js index 69c27835d094..3915e1bcec73 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); @@ -32,20 +33,10 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var randu; -var i; var snansumpw = tryRequire( resolve( __dirname, './../lib/snansumpw.native.js' ) ); var opts = { 'skip': ( snansumpw instanceof Error ) }; -function rand() { - i = uniform( 0, 99 ); - if ( i < 20 ) { - return NaN; - } - return i; -} -randu = rand(); // FUNCTIONS // @@ -58,11 +49,16 @@ randu = rand(); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = filledarrayBy( len, 'float32', randu ); + var x = filledarrayBy( len, 'float32', rand ); return benchmark; + function rand() { + if ( bernoulli( 0.8 ) > 0 ) { + return uniform( -10, 10 ); + } + return NaN; + } + function benchmark( b ) { var v; var i; diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js index aedc1a73a331..557b5cbebb15 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -21,7 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); @@ -29,20 +30,6 @@ var pkg = require( './../package.json' ).name; var snansumpw = require( './../lib/ndarray.js' ); -// VARIABLES // - -var randu; -var i; -function rand() { - i = uniform( 0, 99 ); - if ( i < 20 ) { - return NaN; - } - return i; -} -randu = rand(); - - // FUNCTIONS // /** @@ -53,11 +40,16 @@ randu = rand(); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - - x = filledarrayBy( len, 'float32', randu ); + var x = filledarrayBy( len, 'float32', rand ); return benchmark; + function rand() { + if ( bernoulli( 0.8 ) > 0 ) { + return uniform( -10, 10 ); + } + return NaN; + } + function benchmark( b ) { var v; var i; diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js index ea7fe483767b..1a97fae93582 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/benchmark.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -22,7 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ).factory; +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); @@ -32,20 +33,10 @@ var pkg = require( './../package.json' ).name; // VARIABLES // -var randu; -var i; var snansumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( snansumpw instanceof Error ) }; -function rand() { - i = uniform( 0, 99 ); - if ( i < 20 ) { - return NaN; - } - return i; -} -randu = rand(); // FUNCTIONS // @@ -60,9 +51,16 @@ randu = rand(); function createBenchmark( len ) { var x; - x = filledarrayBy( len, 'float32', randu ); + x = filledarrayBy( len, 'float32', rand ); return benchmark; + function rand() { + if ( bernoulli( 0.8 ) > 0 ) { + return uniform( -10, 10 ); + } + return NaN; + } + function benchmark( b ) { var v; var i; diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile index 9f97140e7cb0..7280962b4c4d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c index 5185ee47b008..f41ca72fb6b7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/benchmark/c/benchmark.length.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp index ec3992233442..7d0005b2e390 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile index 6aed70daf167..ff5293d3059f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c index 90fb64c1f7b0..e6f10680c330 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js index 741063981c9c..564361416428 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/examples/index.js @@ -18,25 +18,19 @@ 'use strict'; -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); var filledarrayBy = require( '@stdlib/array/filled-by' ); var snansumpw = require( './../lib' ); -var x; -var i; -var randu; - function rand() { - i = discreteUniform( 0, 99 ); - if ( i < 20 ) { + if ( bernoulli( 0.2 ) > 0 ) { return NaN; } - return i; + return discreteUniform( 0, 100 ); } -randu = rand(); - -x = filledarrayBy( 10, 'float32', randu ); +var x = filledarrayBy( 10, 'float32', rand ); console.log( x ); var v = snansumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi index 575cb043c0bf..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include/stdlib/blas/ext/base/snansumpw.h b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include/stdlib/blas/ext/base/snansumpw.h index b4c403f906a4..1b81d25a18d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include/stdlib/blas/ext/base/snansumpw.h +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/include/stdlib/blas/ext/base/snansumpw.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/index.js index afa4530abe0c..747491940a1f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/main.js index 92207ab33ccd..a063e0951ee9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/native.js index 10246274c085..87fbc489022d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.js index 55651308a38a..48a3a93cba1a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.native.js index 7ca06488c227..1c8a9ae57c4e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.js index f338bac4793e..545a972e98a2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.native.js index d61e8b2d0c65..bedd15436359 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/lib/snansumpw.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/manifest.json index fdb63abb8c2d..af3ddac3e5f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/manifest.json @@ -1,42 +1,82 @@ { - "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": [ - "./src/snansumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/assert/is-nanf" - ] - } - ] + "options": { + "task": "build" + }, + "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": [ + { + "task": "build", + "src": [ + "./src/snansumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/snansumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf" + ] + }, + { + "task": "examples", + "src": [ + "./src/snansumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf" + ] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/Makefile index bcf18aa46655..dd720a3de8f2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2020 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/addon.c index 8a6066a37565..6a8fbcf3dcee 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/addon.c @@ -17,101 +17,32 @@ */ #include "stdlib/blas/ext/base/snansumpw.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.h" #include -#include -#include -#include #include /** -* Add-on namespace. +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value */ -namespace stdlib_blas_ext_base_snansumpw { - - /** - * Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_snansumpw( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, (double)stdlib_strided_snansumpw( N, (float *)X, stride ), &v ); - assert( status == napi_ok ); +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, stride, argv, 1 ); - return v; - } + napi_value v; + napi_status status = napi_create_double( env, stdlib_strided_snansumpw( N, X, stride ), &v ); + assert( status == napi_ok ); - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_snansumpw, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } + return v; +} - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_snansumpw +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/snansumpw.c b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/snansumpw.c index f7b6cbee0f18..fbede2c45824 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/snansumpw.c +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/src/snansumpw.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.js index b171696d49c3..3ae49b9fa7d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.js index 1fb35e2dcac7..56e17b02ae34 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -124,7 +124,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -141,15 +140,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = 5; - v = snansumpw( N, x, 2, 0 ); + v = snansumpw( 5, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -167,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = 5; - v = snansumpw( N, x, -2, 8 ); + v = snansumpw( 5, x, -2, 8 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -195,7 +191,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -211,9 +206,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]); - N = 5; - v = snansumpw( N, x, 2, 1 ); + v = snansumpw( 5, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.native.js index 4a8e7c6ff882..98667801d815 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.ndarray.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -133,7 +133,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -150,15 +149,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = 5; - v = snansumpw( N, x, 2, 0 ); + v = snansumpw( 5, x, 2, 0 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -176,8 +173,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = 5; - v = snansumpw( N, x, -2, 8 ); + v = snansumpw( 5, x, -2, 8 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -204,7 +200,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -220,9 +215,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { NaN, NaN // 4 ]); - N = 5; - v = snansumpw( N, x, 2, 1 ); + v = snansumpw( 5, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.js index 11cd333630ef..e1acc00fca8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -124,7 +124,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -141,15 +140,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN ]); - N = 5; - v = snansumpw( N, x, 2 ); + v = snansumpw( 5, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; var i; @@ -167,8 +164,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = 5; - v = snansumpw( N, x, -2 ); + v = snansumpw( 5, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -197,7 +193,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -215,9 +210,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = 5; - v = snansumpw( N, x1, 2 ); + v = snansumpw( 5, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.native.js index 26a58f27cb35..256931d154cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/snansumpw/test/test.snansumpw.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2020 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. @@ -215,7 +215,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -232,15 +231,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN ]); - N = 5; - v = snansumpw( N, x, 2 ); + v = snansumpw( 5, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; var i; @@ -258,8 +255,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = 5; - v = snansumpw( N, x, -2 ); + v = snansumpw( 5, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -288,7 +284,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -306,9 +301,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = 5; - v = snansumpw( N, x1, 2 ); + v = snansumpw( 5, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end();