From e5537422aaf9589b92caa16ebcdbdafb793e18dc Mon Sep 17 00:00:00 2001 From: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> Date: Fri, 22 Mar 2024 15:05:44 +0000 Subject: [PATCH 01/10] refactor blas/ext/base/dsumpw --- .../@stdlib/blas/ext/base/dsumpw/README.md | 30 +++++-------------- .../ext/base/dsumpw/benchmark/benchmark.js | 19 ++++++------ .../base/dsumpw/benchmark/benchmark.native.js | 15 ++++------ .../dsumpw/benchmark/benchmark.ndarray.js | 19 ++++++------ .../benchmark/benchmark.ndarray.native.js | 15 ++++------ .../blas/ext/base/dsumpw/docs/repl.txt | 18 +++++------ .../blas/ext/base/dsumpw/examples/index.js | 15 +++------- .../@stdlib/blas/ext/base/dsumpw/include.gypi | 2 +- .../@stdlib/blas/ext/base/dsumpw/lib/index.js | 6 ++-- .../blas/ext/base/dsumpw/lib/native.js | 2 +- .../blas/ext/base/dsumpw/lib/ndarray.js | 6 ++-- .../ext/base/dsumpw/lib/ndarray.native.js | 16 ++++------ .../blas/ext/base/dsumpw/manifest.json | 7 ++++- .../base/dsumpw/src/{addon.cpp => addon.c} | 0 .../blas/ext/base/dsumpw/test/test.dsumpw.js | 20 ++++++------- .../base/dsumpw/test/test.dsumpw.native.js | 11 ++++--- .../blas/ext/base/dsumpw/test/test.ndarray.js | 11 ++++--- .../base/dsumpw/test/test.ndarray.native.js | 11 ++++--- 18 files changed, 89 insertions(+), 134 deletions(-) rename lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/{addon.cpp => addon.c} (100%) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md index 405c8a09b491..61c1fa30422b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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 [`Float64Array`][@stdlib/array/float64]. - **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 Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0 ] ); -var N = floor( x.length / 2 ); -var v = dsumpw( N, x, 2 ); +var v = dsumpw( 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 Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); 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 N = floor( x0.length / 2 ); - -var v = dsumpw( N, x1, 2 ); +var v = dsumpw( 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 Float64Array = require( '@stdlib/array/float64' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); -var N = floor( x.length / 2 ); -var v = dsumpw.ndarray( N, x, 2, 1 ); +var v = dsumpw.ndarray( 4, x, 2, 1 ); // returns 5.0 ``` @@ -139,18 +132,11 @@ var v = dsumpw.ndarray( N, x, 2, 1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy(10, 'float64', discreteUniform(0, 100)); console.log( x ); var v = dsumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js index d95f07f825fe..16330c99b54a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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,19 @@ // 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 Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dsumpw = require( './../lib/dsumpw.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var dsumpw = require( './../lib/dsumpw.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js index a1001b59d4a6..e18c37aa8ae2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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,10 +22,10 @@ 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 Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dsumpw = tryRequire( resolve( __dirname, './../lib/dsumpw.native.js' ) ); var opts = { 'skip': ( dsumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js index 99a0022913b4..c5eb309c3fd4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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,19 @@ // 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 Float64Array = require( '@stdlib/array/float64' ); var pkg = require( './../package.json' ).name; var dsumpw = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -100.0, 100.0 ); + + // FUNCTIONS // /** @@ -39,13 +44,7 @@ var dsumpw = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js index 778d0f645a3b..15b287c48f59 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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,10 +22,10 @@ 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 Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -36,6 +36,7 @@ var dsumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dsumpw instanceof Error ) }; +var rand = uniform( -100.0, 100.0 ); // FUNCTIONS // @@ -48,13 +49,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*10.0 ) - 20.0; - } + var x = filledarrayBy( len, 'float64', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt index 2b2be76a647b..ba7995fe4397 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt @@ -3,8 +3,8 @@ Computes the sum of double-precision floating-point strided array elements 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/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( N, x, 2 ) 1.0 // 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 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( N, x1, 2 ) -1.0 + {{alias}}.ndarray( N, x, stride, offset ) Computes the sum of double-precision floating-point strided array elements using pairwise summation and alternative indexing semantics. @@ -84,9 +81,8 @@ 1.0 // Using offset parameter: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); + > {{alias}}.ndarray( 3, x, 2, 1 ) -1.0 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js index a349140e92a1..b3d3405ef90b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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,18 +18,11 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Float64Array = require( '@stdlib/array/float64' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var dsumpw = require( './../lib' ); -var x; -var i; - -x = new Float64Array( 10 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} +var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) ); console.log( x ); var v = dsumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include.gypi +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' Date: Fri, 22 Mar 2024 23:07:11 +0530 Subject: [PATCH 02/10] Update ndarray.native.js Signed-off-by: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> --- .../@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js index c906963b9f65..842bc5418f77 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js @@ -45,6 +45,7 @@ var addon = require( './dsumpw.native.js' ); * // returns 5.0 */ function dsumpw( N, x, stride, offset ) { + var view; offset = minViewBufferIndex( N, stride, offset ); view = offsetView( x, offset ); return addon( N, view, stride ); From 11804099273cc272681c0f6882a52347ef4b880e Mon Sep 17 00:00:00 2001 From: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> Date: Sun, 24 Mar 2024 22:16:00 +0000 Subject: [PATCH 03/10] updated copyright date --- .../@stdlib/blas/ext/base/dsumpw/README.md | 4 +- .../ext/base/dsumpw/benchmark/benchmark.js | 2 +- .../base/dsumpw/benchmark/benchmark.native.js | 2 +- .../dsumpw/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../blas/ext/base/dsumpw/examples/index.js | 2 +- .../@stdlib/blas/ext/base/dsumpw/lib/index.js | 2 +- .../blas/ext/base/dsumpw/lib/native.js | 2 +- .../blas/ext/base/dsumpw/lib/ndarray.js | 2 +- .../ext/base/dsumpw/lib/ndarray.native.js | 2 +- .../blas/ext/base/dsumpw/manifest.json | 78 +++++++++---------- .../blas/ext/base/dsumpw/test/test.dsumpw.js | 3 +- .../base/dsumpw/test/test.dsumpw.native.js | 2 +- .../blas/ext/base/dsumpw/test/test.ndarray.js | 2 +- .../base/dsumpw/test/test.ndarray.native.js | 2 +- 15 files changed, 54 insertions(+), 55 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md index 61c1fa30422b..8a5f61acc31b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. @@ -136,7 +136,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarrayBy = require( '@stdlib/array/filled-by' ); var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' ); -var x = filledarrayBy(10, 'float64', discreteUniform(0, 100)); +var x = filledarrayBy(10, 'float64', discreteUniform( 0, 100 ) ); console.log( x ); var v = dsumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js index 16330c99b54a..c2a81dc8cd1c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js index e18c37aa8ae2..fe0d4f48aef3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js index c5eb309c3fd4..29dc3684b0c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js index 15b287c48f59..4292e51047a6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js index b3d3405ef90b..780b609e207a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/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/dsumpw/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js index 1b3288e3e74d..84c585bb77b5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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/dsumpw/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/native.js index 3d3247c129ae..80fe689a5988 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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/dsumpw/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js index 6cd09a72b95a..c335bca94316 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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/dsumpw/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js index 842bc5418f77..3032e3e37ff0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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/dsumpw/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json index 4db624009cf5..5eabe1b27860 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -1,45 +1,45 @@ { "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 - } + { + "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/dsumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "stdlib/napi/export.h", - "stdlib/napi/argv.h", - "stdlib/napi/argv_int64.h", - "stdlib/napi/argv_strided_float64array.h" - ] - } + { + "src": [ + "./src/dsumkbn2.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + } ] -} + } \ No newline at end of file diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js index f80e970db7b8..c9b2bf8a1238 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.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. @@ -129,7 +129,6 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) var v; var i; var N; - x = new Float64Array([ 1.0, // 3 2.0, diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js index f85924b208c3..7deb0c0e3782 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.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/dsumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js index bb3a2a68e29c..2d80a506e291 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js index b33d1c8388e0..12495c1fbe98 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/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. From 1e86fd2a69ceef38eaa6655fdf2cb6f31a87904d Mon Sep 17 00:00:00 2001 From: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> Date: Sun, 24 Mar 2024 22:18:16 +0000 Subject: [PATCH 04/10] updated addon.c --- .../@stdlib/blas/ext/base/dsumpw/README.md | 2 +- .../@stdlib/blas/ext/base/dsumpw/src/addon.c | 122 ++++-------------- 2 files changed, 27 insertions(+), 97 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md index 8a5f61acc31b..3c03cbc53312 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/README.md @@ -136,7 +136,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarrayBy = require( '@stdlib/array/filled-by' ); var dsumpw = require( '@stdlib/blas/ext/base/dsumpw' ); -var x = filledarrayBy(10, 'float64', discreteUniform( 0, 100 ) ); +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); console.log( x ); var v = dsumpw( x.length, x, 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c index e2d5f21d8ba5..2cedea53e157 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* Copyright (c) 2018 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. @@ -16,102 +16,32 @@ * limitations under the License. */ -#include "stdlib/blas/ext/base/dsumpw.h" +#include "stdlib/blas/base/saxpy.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.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_dsumpw { - - /** - * Computes the sum of double-precision floating-point strided array elements 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_dsumpw( 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 Float64Array." ); - 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_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float64Array." ); - 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, stdlib_strided_dsumpw( N, (double *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - 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_dsumpw, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dsumpw +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); + c_saxpy( N, alpha, X, strideX, Y, strideY ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) From b43b5a5f5361bf507c4ac83feb35333a602cfc13 Mon Sep 17 00:00:00 2001 From: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:16:46 +0530 Subject: [PATCH 05/10] Update addon.c Signed-off-by: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c index 2cedea53e157..d78c1fec6b6e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "stdlib/blas/base/saxpy.h" +#include "stdlib/blas/base/dsumpw.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_float.h" @@ -40,7 +40,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); - c_saxpy( N, alpha, X, strideX, Y, strideY ); + stdlib_strided_dsumpw( N, alpha, X, strideX, Y, strideY ); return NULL; } From d7a72c4b07c9d2b5f0428d88a748a8dbe5fdd816 Mon Sep 17 00:00:00 2001 From: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:39:14 +0530 Subject: [PATCH 06/10] Update manifest.json Signed-off-by: utkarsh_raj <49344502+rajutkarsh07@users.noreply.github.com> --- .../blas/ext/base/dsumpw/manifest.json | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) 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 5eabe1b27860..0743d5846229 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -1,5 +1,7 @@ { - "options": {}, + "options": { + "task": "build" + }, "fields": [ { "field": "src", @@ -25,7 +27,7 @@ "confs": [ { "src": [ - "./src/dsumkbn2.c" + "./src/dsumpw.c" ], "include": [ "./include" @@ -40,6 +42,34 @@ "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] - } - ] - } \ No newline at end of file + }, + { + "task": "benchmark", + "src": [ + "./src/dsumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/dsumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] +} From abd6349cefc5dbee1865aa25c7ac74d676d718eb Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 14 Apr 2024 20:38:25 -0400 Subject: [PATCH 07/10] chore: minor clean-up to get CI to pass --- .../ext/base/dsumpw/benchmark/benchmark.js | 2 +- .../base/dsumpw/benchmark/benchmark.native.js | 2 +- .../dsumpw/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../blas/ext/base/dsumpw/docs/repl.txt | 4 +- .../blas/ext/base/dsumpw/examples/index.js | 2 +- .../blas/ext/base/dsumpw/manifest.json | 140 +++++++++--------- .../blas/ext/base/dsumpw/test/test.dsumpw.js | 13 +- .../base/dsumpw/test/test.dsumpw.native.js | 12 +- .../blas/ext/base/dsumpw/test/test.ndarray.js | 12 +- .../base/dsumpw/test/test.ndarray.native.js | 12 +- 11 files changed, 90 insertions(+), 113 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js index c2a81dc8cd1c..d6b22fda28af 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.js @@ -31,7 +31,7 @@ var dsumpw = require( './../lib/dsumpw.js' ); // VARIABLES // -var rand = uniform( -100.0, 100.0 ); +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js index fe0d4f48aef3..399f150736c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.native.js @@ -36,7 +36,7 @@ var dsumpw = tryRequire( resolve( __dirname, './../lib/dsumpw.native.js' ) ); var opts = { 'skip': ( dsumpw instanceof Error ) }; -var rand = uniform( -100.0, 100.0 ); +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js index 29dc3684b0c2..0e13afde1ac7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.js @@ -31,7 +31,7 @@ var dsumpw = require( './../lib/ndarray.js' ); // VARIABLES // -var rand = uniform( -100.0, 100.0 ); +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js index 4292e51047a6..fa9cd2f89840 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/benchmark/benchmark.ndarray.native.js @@ -36,7 +36,7 @@ var dsumpw = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dsumpw instanceof Error ) }; -var rand = uniform( -100.0, 100.0 ); +var rand = uniform( -10.0, 10.0 ); // FUNCTIONS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt index ba7995fe4397..8b39ccffff64 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/docs/repl.txt @@ -36,13 +36,13 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); - > {{alias}}( N, x, 2 ) + > {{alias}}( 3, x, 2 ) 1.0 // 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 ); - > {{alias}}( N, x1, 2 ) + > {{alias}}( 3, x1, 2 ) -1.0 diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js index 780b609e207a..020cf5dbaa6c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/examples/index.js @@ -22,7 +22,7 @@ var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; var filledarrayBy = require( '@stdlib/array/filled-by' ); var dsumpw = require( './../lib' ); -var x = filledarrayBy( 10, 'float64', discreteUniform( -100.0, 100.0 ) ); +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); console.log( x ); var v = dsumpw( x.length, x, 1 ); 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 0743d5846229..e5be7ba28746 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -2,74 +2,74 @@ "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": [ - { - "src": [ - "./src/dsumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [ - "@stdlib/napi/export", - "@stdlib/napi/argv", - "@stdlib/napi/argv-int64", - "@stdlib/napi/argv-strided-float64array" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/dsumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [] - }, - { - "task": "examples", - "src": [ - "./src/dsumpw.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [] - } - ] + "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/dsumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/dsumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/dsumpw.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js index c9b2bf8a1238..f501fae3f0a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.js @@ -104,7 +104,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 x; var v; - var N; x = new Float64Array([ 1.0, // 0 @@ -117,8 +116,7 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = 4; - v = dsumpw( N, x, 2 ); + v = dsumpw( 4, x, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); @@ -128,7 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) var x; var v; var i; - var N; + x = new Float64Array([ 1.0, // 3 2.0, @@ -140,8 +138,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = 4; - v = dsumpw( N, x, -2 ); + v = dsumpw( 4, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -171,7 +168,6 @@ tape( 'the function supports view offsets', function test( t ) { var x0; var x1; var v; - var N; x0 = new Float64Array([ 2.0, @@ -185,9 +181,8 @@ tape( 'the function supports view offsets', function test( t ) { 6.0 ]); - N = 4; x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - v = dsumpw( N, x1, 2 ); + v = dsumpw( 4, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js index 7deb0c0e3782..146763d831a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.dsumpw.native.js @@ -193,7 +193,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; @@ -208,15 +207,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = 4; - v = dsumpw( N, x, 2 ); + v = dsumpw( 4, 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; @@ -232,8 +229,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = 4; - v = dsumpw( N, x, -2 ); + v = dsumpw( 4, x, -2 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -262,7 +258,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 Float64Array([ @@ -278,9 +273,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = 4; - v = dsumpw( N, x1, 2 ); + v = dsumpw( 4, x1, 2 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js index 2d80a506e291..88753d3e7292 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.js @@ -102,7 +102,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; @@ -117,15 +116,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { 2.0 ]); - N = 4; - v = dsumpw( N, x, 2, 0 ); + v = dsumpw( 4, 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; @@ -141,8 +138,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) 2.0 ]); - N = 4; - v = dsumpw( N, x, -2, 6 ); + v = dsumpw( 4, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -169,7 +165,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; @@ -183,9 +178,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { 3.0, 4.0 // 3 ]); - N = 4; - v = dsumpw( N, x, 2, 1 ); + v = dsumpw( 4, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js index 12495c1fbe98..bda9e678287e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/test/test.ndarray.native.js @@ -111,7 +111,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; @@ -126,15 +125,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { 2.0 ]); - N = 4; - v = dsumpw( N, x, 2, 0 ); + v = dsumpw( 4, 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; @@ -150,8 +147,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test 2.0 ]); - N = 4; - v = dsumpw( N, x, -2, 6 ); + v = dsumpw( 4, x, -2, 6 ); t.strictEqual( v, 5.0, 'returns expected value' ); @@ -178,7 +174,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; @@ -192,9 +187,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { 3.0, 4.0 // 3 ]); - N = 4; - v = dsumpw( N, x, 2, 1 ); + v = dsumpw( 4, x, 2, 1 ); t.strictEqual( v, 5.0, 'returns expected value' ); t.end(); From 3fb15d14beffdd6fa16b124eb01db76d4fe5d21f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 14 Apr 2024 20:46:54 -0400 Subject: [PATCH 08/10] build: set task field for configuration --- lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json | 1 + 1 file changed, 1 insertion(+) 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 e5be7ba28746..118f8b71bba9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -26,6 +26,7 @@ ], "confs": [ { + "task": "build", "src": [ "./src/dsumpw.c" ], From 87185153f9586e106b8c47db6dc7708b21caa5af Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 14 Apr 2024 20:53:42 -0400 Subject: [PATCH 09/10] fix: update include path and add missing dependency --- lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json | 1 + lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 118f8b71bba9..f4c78f1c53f0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -40,6 +40,7 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", + "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c index d78c1fec6b6e..4229cfa68a7a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "stdlib/blas/base/dsumpw.h" +#include "stdlib/blas/ext/base/dsumpw.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" #include "stdlib/napi/argv_float.h" From 3cf5f5b2ad37b5fe50ddc8732be17bbd2b01e617 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 14 Apr 2024 21:17:30 -0400 Subject: [PATCH 10/10] fix: rewrite addon.c --- .../@stdlib/blas/ext/base/dsumpw/manifest.json | 1 - .../@stdlib/blas/ext/base/dsumpw/src/addon.c | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) 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 f4c78f1c53f0..118f8b71bba9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/manifest.json @@ -40,7 +40,6 @@ "dependencies": [ "@stdlib/napi/export", "@stdlib/napi/argv", - "@stdlib/napi/argv-float", "@stdlib/napi/argv-int64", "@stdlib/napi/argv-strided-float64array" ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c index 4229cfa68a7a..cda3826460fc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/dsumpw/src/addon.c @@ -19,7 +19,6 @@ #include "stdlib/blas/ext/base/dsumpw.h" #include "stdlib/napi/export.h" #include "stdlib/napi/argv.h" -#include "stdlib/napi/argv_float.h" #include "stdlib/napi/argv_int64.h" #include "stdlib/napi/argv_strided_float64array.h" #include @@ -33,15 +32,16 @@ * @return Node-API value */ static napi_value addon( napi_env env, napi_callback_info info ) { - STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); - STDLIB_NAPI_ARGV_FLOAT( env, alpha, argv, 1 ); - STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); - STDLIB_NAPI_ARGV_INT64( env, strideY, argv, 5 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Y, N, strideY, argv, 4 ); - stdlib_strided_dsumpw( N, alpha, X, strideX, Y, strideY ); - return NULL; + STDLIB_NAPI_ARGV_INT64( env, stride, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, stride, argv, 1 ); + + napi_value v; + napi_status status = napi_create_double( env, stdlib_strided_dsumpw( N, X, stride ), &v ); + assert( status == napi_ok ); + + return v; } STDLIB_NAPI_MODULE_EXPORT_FCN( addon )