From c2a8ed83102626d82e17a094ca835a7d396905be Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 26 Mar 2024 14:24:38 +0000 Subject: [PATCH] Auto-generated commit --- ext/base/dcusumors/README.md | 33 +--- ext/base/dcusumors/benchmark/benchmark.js | 19 +- .../dcusumors/benchmark/benchmark.native.js | 15 +- .../dcusumors/benchmark/benchmark.ndarray.js | 19 +- .../benchmark/benchmark.ndarray.native.js | 15 +- ext/base/dcusumors/docs/repl.txt | 14 +- ext/base/dcusumors/examples/index.js | 14 +- ext/base/dcusumors/include.gypi | 2 +- ext/base/dcusumors/lib/dcusumors.js | 3 +- ext/base/dcusumors/lib/dcusumors.native.js | 3 +- ext/base/dcusumors/lib/index.js | 7 +- ext/base/dcusumors/lib/ndarray.js | 4 +- ext/base/dcusumors/lib/ndarray.native.js | 20 +-- ext/base/dcusumors/manifest.json | 112 ++++++++---- ext/base/dcusumors/package.json | 4 +- ext/base/dcusumors/src/addon.c | 46 +++++ ext/base/dcusumors/src/addon.cpp | 164 ------------------ ext/base/dcusumors/test/test.dcusumors.js | 24 +-- .../dcusumors/test/test.dcusumors.native.js | 24 +-- ext/base/dcusumors/test/test.ndarray.js | 27 +-- .../dcusumors/test/test.ndarray.native.js | 27 +-- 21 files changed, 210 insertions(+), 386 deletions(-) create mode 100644 ext/base/dcusumors/src/addon.c delete mode 100644 ext/base/dcusumors/src/addon.cpp diff --git a/ext/base/dcusumors/README.md b/ext/base/dcusumors/README.md index 27663cb72..0099c9ecc 100644 --- a/ext/base/dcusumors/README.md +++ b/ext/base/dcusumors/README.md @@ -65,18 +65,15 @@ The function has the following parameters: - **y**: output [`Float64Array`][@stdlib/array/float64]. - **strideY**: index increment for `y`. -The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`, +The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in the strided input array, ```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 y = new Float64Array( x.length ); -var N = floor( x.length / 2 ); - -var v = dcusumors( N, 0.0, x, 2, y, 1 ); +var v = dcusumors( 4, 0.0, x, 2, y, 1 ); // y => [ 1.0, 3.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ``` @@ -86,7 +83,6 @@ 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' ); // Initial arrays... var x0 = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); @@ -96,9 +92,7 @@ var y0 = new Float64Array( x0.length ); var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // start at 4th element -var N = floor( x0.length / 2 ); - -dcusumors( N, 0.0, x1, -2, y1, 1 ); +dcusumors( 4, 0.0, x1, -2, y1, 1 ); // y0 => [ 0.0, 0.0, 0.0, 4.0, 6.0, 4.0, 5.0, 0.0 ] ``` @@ -121,18 +115,15 @@ The function has the following additional parameters: - **offsetX**: starting index for `x`. - **offsetY**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x` starting from the second value and to store in the last `N` elements of `y` starting from the last element +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, `offsetX` and `offsetY` parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in the strided input array starting from the second value and to store in the last `N` elements of the strided output array starting from the last element ```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 y = new Float64Array( x.length ); -var N = floor( x.length / 2 ); - -dcusumors.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); +dcusumors.ndarray( 4, 0.0, x, 2, 1, y, -1, y.length-1 ); // y => [ 0.0, 0.0, 0.0, 0.0, 5.0, 1.0, -1.0, 1.0 ] ``` @@ -158,20 +149,14 @@ dcusumors.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( '@stdlib/blas/ext/base/dcusumors' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var y = new Float64Array( x.length ); -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/ext/base/dcusumors/benchmark/benchmark.js b/ext/base/dcusumors/benchmark/benchmark.js index 87adfafa3..5022df2c1 100644 --- a/ext/base/dcusumors/benchmark/benchmark.js +++ b/ext/base/dcusumors/benchmark/benchmark.js @@ -21,7 +21,8 @@ // 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' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var dcusumors = require( './../lib/dcusumors.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var dcusumors = require( './../lib/dcusumors.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var y; - var x; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/ext/base/dcusumors/benchmark/benchmark.native.js b/ext/base/dcusumors/benchmark/benchmark.native.js index a33141439..37792d8f2 100644 --- a/ext/base/dcusumors/benchmark/benchmark.native.js +++ b/ext/base/dcusumors/benchmark/benchmark.native.js @@ -22,7 +22,8 @@ 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' ); @@ -32,6 +33,7 @@ var pkg = require( './../package.json' ).name; // VARIABLES // +var rand = uniform( -10.0, 10.0 ); var dcusumors = tryRequire( resolve( __dirname, './../lib/dcusumors.native.js' ) ); var opts = { 'skip': ( dcusumors instanceof Error ) @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/ext/base/dcusumors/benchmark/benchmark.ndarray.js b/ext/base/dcusumors/benchmark/benchmark.ndarray.js index 38570e188..0b900d440 100644 --- a/ext/base/dcusumors/benchmark/benchmark.ndarray.js +++ b/ext/base/dcusumors/benchmark/benchmark.ndarray.js @@ -21,7 +21,8 @@ // 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' ); @@ -29,6 +30,11 @@ var pkg = require( './../package.json' ).name; var dcusumors = require( './../lib/ndarray.js' ); +// VARIABLES // + +var rand = uniform( -10.0, 10.0 ); + + // FUNCTIONS // /** @@ -39,15 +45,8 @@ var dcusumors = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js b/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js index c31033d7b..4d25cae43 100644 --- a/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js +++ b/ext/base/dcusumors/benchmark/benchmark.ndarray.native.js @@ -22,7 +22,8 @@ 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' ); @@ -32,6 +33,7 @@ var pkg = require( './../package.json' ).name; // VARIABLES // +var rand = uniform( -10.0, 10.0 ); var dcusumors = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); var opts = { 'skip': ( dcusumors instanceof Error ) @@ -48,15 +50,8 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var y; - var i; - - x = new Float64Array( len ); - y = new Float64Array( len ); - for ( i = 0; i < x.length; i++ ) { - x[ i ] = ( randu()*20.0 ) - 10.0; - } + var x = filledarrayBy( len, 'float64', rand ); + var y = new Float64Array( len ); return benchmark; function benchmark( b ) { diff --git a/ext/base/dcusumors/docs/repl.txt b/ext/base/dcusumors/docs/repl.txt index 25cf1a39f..cd2c847aa 100644 --- a/ext/base/dcusumors/docs/repl.txt +++ b/ext/base/dcusumors/docs/repl.txt @@ -3,8 +3,8 @@ Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. - The `N` and `stride` parameters determine which elements in `x` and `y` are - accessed at runtime. + The `N` and `stride` parameters determine which elements in the strided + arrays are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -47,8 +47,7 @@ // Using `N` and `stride` parameters: > x = new {{alias:@stdlib/array/float64}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float64}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}( N, 0.0, x, 2, y, 2 ) + > {{alias}}( 3, 0.0, x, 2, y, 2 ) [ -2.0, 0.0, -1.0, 0.0, 1.0, 0.0 ] // Using view offsets: @@ -56,12 +55,12 @@ > var y0 = new {{alias:@stdlib/array/float64}}( x0.length ); > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > {{alias}}( N, 0.0, x1, 2, y1, 1 ) + > {{alias}}( 3, 0.0, x1, 2, y1, 1 ) [ -2.0, 0.0, -1.0 ] > y0 [ 0.0, 0.0, 0.0, -2.0, 0.0, -1.0 ] + {{alias}}.ndarray( N, sum, x, strideX, offsetX, y, strideY, offsetY ) Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation and alternative indexing @@ -113,8 +112,7 @@ // Advanced indexing: > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0 ] ); > y = new {{alias:@stdlib/array/float64}}( x.length ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, 0.0, x, 2, 1, y, -1, y.length-1 ) + > {{alias}}.ndarray( 3, 0.0, x, 2, 1, y, -1, y.length-1 ) [ 0.0, 0.0, 0.0, -1.0, 0.0, -2.0 ] See Also diff --git a/ext/base/dcusumors/examples/index.js b/ext/base/dcusumors/examples/index.js index 3f3ed99b8..0e92da86a 100644 --- a/ext/base/dcusumors/examples/index.js +++ b/ext/base/dcusumors/examples/index.js @@ -18,20 +18,14 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory; +var filledarrayBy = require( '@stdlib/array/filled-by' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( './../lib' ); -var y; -var x; -var i; +var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) ); +var y = new Float64Array( x.length ); -x = new Float64Array( 10 ); -y = new Float64Array( x.length ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*100.0 ); -} console.log( x ); console.log( y ); diff --git a/ext/base/dcusumors/include.gypi b/ext/base/dcusumors/include.gypi index 868c5c12e..26476a8c2 100644 --- a/ext/base/dcusumors/include.gypi +++ b/ext/base/dcusumors/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', '[ 1.0, -1.0, 1.0 ] */ function dcusumors( N, sum, x, strideX, y, strideY ) { diff --git a/ext/base/dcusumors/lib/dcusumors.native.js b/ext/base/dcusumors/lib/dcusumors.native.js index db8807d1b..c311751b4 100644 --- a/ext/base/dcusumors/lib/dcusumors.native.js +++ b/ext/base/dcusumors/lib/dcusumors.native.js @@ -41,9 +41,8 @@ var addon = require( './../src/addon.node' ); * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float64Array( x.length ); -* var N = x.length; * -* var v = dcusumors( N, 0.0, x, 1, y, 1 ); +* var v = dcusumors( 3, 0.0, x, 1, y, 1 ); * // returns [ 1.0, -1.0, 1.0 ] */ function dcusumors( N, sum, x, strideX, y, strideY ) { diff --git a/ext/base/dcusumors/lib/index.js b/ext/base/dcusumors/lib/index.js index 492a1b065..5a5eea526 100644 --- a/ext/base/dcusumors/lib/index.js +++ b/ext/base/dcusumors/lib/index.js @@ -29,21 +29,18 @@ * * var x = new Float64Array( [ 1.0, -2.0, 2.0 ] ); * var y = new Float64Array( x.length ); -* var N = x.length; * -* dcusumors( N, 0.0, x, 1, y, 1 ); +* dcusumors( 3, 0.0, x, 1, y, 1 ); * // y => [ 1.0, -1.0, 1.0 ] * * @example * var Float64Array = require( '@stdlib/array/float64' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dcusumors = require( '@stdlib/blas/ext/base/dcusumors' ); * * var x = new Float64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* dcusumors.ndarray( N, 0.0, x, 2, 1, y, 1, 0 ); +* dcusumors.ndarray( 4, 0.0, x, 2, 1, y, 1, 0 ); * // y => [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ diff --git a/ext/base/dcusumors/lib/ndarray.js b/ext/base/dcusumors/lib/ndarray.js index 35f63d246..40f9e7ced 100644 --- a/ext/base/dcusumors/lib/ndarray.js +++ b/ext/base/dcusumors/lib/ndarray.js @@ -35,13 +35,11 @@ * * @example * 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 y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = dcusumors( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = dcusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function dcusumors( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { diff --git a/ext/base/dcusumors/lib/ndarray.native.js b/ext/base/dcusumors/lib/ndarray.native.js index e23d51b82..6801b3086 100644 --- a/ext/base/dcusumors/lib/ndarray.native.js +++ b/ext/base/dcusumors/lib/ndarray.native.js @@ -20,7 +20,8 @@ // MODULES // -var Float64Array = require( '@stdlib/array/float64' ); +var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' ); +var offsetView = require( '@stdlib/strided/base/offset-view' ); var addon = require( './dcusumors.native.js' ); @@ -41,26 +42,21 @@ var addon = require( './dcusumors.native.js' ); * * @example * 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 y = new Float64Array( x.length ); -* var N = floor( x.length / 2 ); * -* var v = dcusumors( N, 0.0, x, 2, 1, y, 1, 0 ); +* var v = dcusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); * // returns [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] */ function dcusumors( N, sum, x, strideX, offsetX, y, strideY, offsetY ) { var viewX; var viewY; - if ( strideX < 0 ) { - offsetX += (N-1) * strideX; - } - if ( strideY < 0 ) { - offsetY += (N-1) * strideY; - } - viewX = new Float64Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offsetX), x.length-offsetX ); // eslint-disable-line max-len - viewY = new Float64Array( y.buffer, y.byteOffset+(y.BYTES_PER_ELEMENT*offsetY), y.length-offsetY ); // eslint-disable-line max-len + offsetX = minViewBufferIndex( N, strideX, offsetX ); + offsetY = minViewBufferIndex( N, strideY, offsetY ); + + viewX = offsetView( x, offsetX ); + viewY = offsetView( y, offsetY ); addon( N, sum, viewX, strideX, viewY, strideY ); return y; } diff --git a/ext/base/dcusumors/manifest.json b/ext/base/dcusumors/manifest.json index 96d5a0a24..3f41ea2d5 100644 --- a/ext/base/dcusumors/manifest.json +++ b/ext/base/dcusumors/manifest.json @@ -1,40 +1,76 @@ { - "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/dcusumors.c" - ], - "include": [ - "./include" - ], - "libraries": [ - "-lm" - ], - "libpath": [], - "dependencies": [] - } - ] + "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/dcusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array", + "@stdlib/napi/export" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/dcusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/dcusumors.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + } + ] } diff --git a/ext/base/dcusumors/package.json b/ext/base/dcusumors/package.json index aa74b866a..7c8ac96c5 100644 --- a/ext/base/dcusumors/package.json +++ b/ext/base/dcusumors/package.json @@ -75,5 +75,7 @@ "double", "float64array" ], - "__stdlib__": {} + "__stdlib__": { + "wasm": false + } } diff --git a/ext/base/dcusumors/src/addon.c b/ext/base/dcusumors/src/addon.c new file mode 100644 index 000000000..8d7cf76a1 --- /dev/null +++ b/ext/base/dcusumors/src/addon.c @@ -0,0 +1,46 @@ +/** +* @license Apache-2.0 +* +* 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/blas/ext/base/dcusumors.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include "stdlib/napi/export.h" + +/** +* Receives JavaScript callback invocation data. +* +* @private +* @param env environment under which the function is invoked +* @param info callback data +* @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_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, sum, 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_dcusumors( N, sum, X, strideX, Y, strideY ); + return NULL; +} + + // Register a Node-API module: +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ); diff --git a/ext/base/dcusumors/src/addon.cpp b/ext/base/dcusumors/src/addon.cpp deleted file mode 100644 index e79d4d32b..000000000 --- a/ext/base/dcusumors/src/addon.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/** -* @license Apache-2.0 -* -* 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. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -#include "stdlib/blas/ext/base/dcusumors.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_blas_ext_base_dcusumors { - - /** - * Computes the cumulative sum of double-precision floating-point strided array elements using ordinary recursive summation. - * - * ## Notes - * - * - When called from JavaScript, the function expects six arguments: - * - * - `N`: number of indexed elements - * - `sum`: initial sum - * - `X`: input array - * - `strideX`: `X` stride length - * - `Y`: output array - * - `strideY`: `Y` stride length - */ - napi_value node_dcusumors( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 6; - napi_value argv[ 6 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 6 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 6 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; - } - - napi_valuetype vtype1; - status = napi_typeof( env, argv[ 1 ], &vtype1 ); - assert( status == napi_ok ); - if ( vtype1 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a number." ); - return nullptr; - } - - bool res2; - status = napi_is_typedarray( env, argv[ 2 ], &res2 ); - assert( status == napi_ok ); - if ( res2 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype3; - status = napi_typeof( env, argv[ 3 ], &vtype3 ); - assert( status == napi_ok ); - if ( vtype3 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fourth argument must be a number." ); - return nullptr; - } - - bool res4; - status = napi_is_typedarray( env, argv[ 4 ], &res4 ); - assert( status == napi_ok ); - if ( res4 == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." ); - return nullptr; - } - - napi_valuetype vtype5; - status = napi_typeof( env, argv[ 5 ], &vtype5 ); - assert( status == napi_ok ); - if ( vtype5 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Sixth argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - double sum; - status = napi_get_value_double( env, argv[ 1 ], &sum ); - assert( status == napi_ok ); - - int64_t strideX; - status = napi_get_value_int64( env, argv[ 3 ], &strideX ); - assert( status == napi_ok ); - - int64_t strideY; - status = napi_get_value_int64( env, argv[ 5 ], &strideY ); - assert( status == napi_ok ); - - napi_typedarray_type vtype2; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 2 ], &vtype2, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype2 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideX) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Third argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_typedarray_type vtype4; - size_t ylen; - void *Y; - status = napi_get_typedarray_info( env, argv[ 4 ], &vtype4, &ylen, &Y, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype4 != napi_float64_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Fifth argument must be a Float64Array." ); - return nullptr; - } - if ( (N-1)*llabs(strideY) >= (int64_t)ylen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Fifth argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - stdlib_strided_dcusumors( N, sum, (double *)X, strideX, (double *)Y, strideY ); - - return nullptr; - } - - 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_dcusumors, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_blas_ext_base_dcusumors diff --git a/ext/base/dcusumors/test/test.dcusumors.js b/ext/base/dcusumors/test/test.dcusumors.js index 70c6cf2b2..3a3044c9c 100644 --- a/ext/base/dcusumors/test/test.dcusumors.js +++ b/ext/base/dcusumors/test/test.dcusumors.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( './../lib/dcusumors.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 6', function test( t ) { - t.strictEqual( dcusumors.length, 6, 'has expected arity' ); + t.strictEqual( dcusumors.length, 6, 'returns expected value' ); t.end(); }); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, y, 1 ); + dcusumors( 3, 0.0, x, 2, y, 1 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusumors( N, 0.0, x, 1, y, 2 ); + dcusumors( 3, 0.0, x, 1, y, 2 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; var i; x = new Float64Array([ @@ -241,9 +235,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, -2, y, -1 ); + dcusumors( 3, 0.0, x, -2, y, -1 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); t.deepEqual( y, expected, 'returns expected value' ); @@ -270,7 +263,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -288,9 +280,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, y, -1 ); + dcusumors( 3, 0.0, x, 2, y, -1 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -304,7 +295,6 @@ tape( 'the function supports view offsets', function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -328,9 +318,7 @@ tape( 'the function supports view offsets', function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - dcusumors( N, 0.0, x1, -2, y1, 1 ); + dcusumors( 3, 0.0, x1, -2, y1, 1 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/ext/base/dcusumors/test/test.dcusumors.native.js b/ext/base/dcusumors/test/test.dcusumors.native.js index e0c43e445..39ee8b397 100644 --- a/ext/base/dcusumors/test/test.dcusumors.native.js +++ b/ext/base/dcusumors/test/test.dcusumors.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 6', opts, function test( t ) { - t.strictEqual( dcusumors.length, 6, 'has expected arity' ); + t.strictEqual( dcusumors.length, 6, 'returns expected value' ); t.end(); }); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, y, 1 ); + dcusumors( 3, 0.0, x, 2, y, 1 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusumors( N, 0.0, x, 1, y, 2 ); + dcusumors( 3, 0.0, x, 1, y, 2 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; var i; x = new Float64Array([ @@ -250,9 +244,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, -2, y, -1 ); + dcusumors( 3, 0.0, x, -2, y, -1 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); t.deepEqual( y, expected, 'returns expected value' ); @@ -279,7 +272,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -297,9 +289,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, y, -1 ); + dcusumors( 3, 0.0, x, 2, y, -1 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); @@ -313,7 +304,6 @@ tape( 'the function supports view offsets', opts, function test( t ) { var y0; var x1; var y1; - var N; // Initial arrays... x0 = new Float64Array([ @@ -337,9 +327,7 @@ tape( 'the function supports view offsets', opts, function test( t ) { x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // begin at 2nd element y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*3 ); // begin at the 4th element - N = floor( x0.length / 2 ); - - dcusumors( N, 0.0, x1, -2, y1, 1 ); + dcusumors( 3, 0.0, x1, -2, y1, 1 ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 6.0, 10.0, 12.0 ] ); t.deepEqual( y0, expected, 'returns expected value' ); diff --git a/ext/base/dcusumors/test/test.ndarray.js b/ext/base/dcusumors/test/test.ndarray.js index e4f5f21c5..e9dd9d7d8 100644 --- a/ext/base/dcusumors/test/test.ndarray.js +++ b/ext/base/dcusumors/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var dcusumors = require( './../lib/ndarray.js' ); @@ -36,7 +35,7 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function has an arity of 8', function test( t ) { - t.strictEqual( dcusumors.length, 8, 'has expected arity' ); + t.strictEqual( dcusumors.length, 8, 'returns expected value' ); t.end(); }); @@ -164,7 +163,6 @@ tape( 'the function supports an `x` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -180,9 +178,8 @@ tape( 'the function supports an `x` stride', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, 0, y, 1, 0 ); + dcusumors( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -194,7 +191,6 @@ tape( 'the function supports a `y` stride', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -210,9 +206,8 @@ tape( 'the function supports a `y` stride', function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusumors( N, 0.0, x, 1, 0, y, 2, 0 ); + dcusumors( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -224,7 +219,6 @@ tape( 'the function supports negative strides', function test( t ) { var expected; var x; var y; - var N; var i; x = new Float64Array([ @@ -241,9 +235,8 @@ tape( 'the function supports negative strides', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + dcusumors( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); t.deepEqual( y, expected, 'returns expected value' ); @@ -268,7 +261,6 @@ tape( 'the function supports negative strides', function test( t ) { tape( 'the function supports an `x` offset', function test( t ) { var expected; - var N; var x; var y; @@ -292,9 +284,8 @@ tape( 'the function supports an `x` offset', function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - dcusumors( N, 0.0, x, 2, 1, y, 1, 0 ); + dcusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float64Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -304,7 +295,6 @@ tape( 'the function supports an `x` offset', function test( t ) { tape( 'the function supports a `y` offset', function test( t ) { var expected; - var N; var x; var y; @@ -328,9 +318,8 @@ tape( 'the function supports a `y` offset', function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - dcusumors( N, 0.0, x, 1, 0, y, 2, 1 ); + dcusumors( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float64Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -342,7 +331,6 @@ tape( 'the function supports complex access patterns', function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -360,9 +348,8 @@ tape( 'the function supports complex access patterns', function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, 0, y, -1, 2 ); + dcusumors( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] ); diff --git a/ext/base/dcusumors/test/test.ndarray.native.js b/ext/base/dcusumors/test/test.ndarray.native.js index 7afae945d..7611606a7 100644 --- a/ext/base/dcusumors/test/test.ndarray.native.js +++ b/ext/base/dcusumors/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float64Array = require( '@stdlib/array/float64' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -45,7 +44,7 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function has an arity of 8', opts, function test( t ) { - t.strictEqual( dcusumors.length, 8, 'has expected arity' ); + t.strictEqual( dcusumors.length, 8, 'returns expected value' ); t.end(); }); @@ -173,7 +172,6 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -189,9 +187,8 @@ tape( 'the function supports an `x` stride', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, 0, y, 1, 0 ); + dcusumors( 3, 0.0, x, 2, 0, y, 1, 0 ); expected = new Float64Array( [ 1.0, 4.0, 9.0, 0.0, 0.0 ] ); @@ -203,7 +200,6 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -219,9 +215,8 @@ tape( 'the function supports a `y` stride', opts, function test( t ) { 0.0, 0.0 // 2 ]); - N = 3; - dcusumors( N, 0.0, x, 1, 0, y, 2, 0 ); + dcusumors( 3, 0.0, x, 1, 0, y, 2, 0 ); expected = new Float64Array( [ 1.0, 0.0, 3.0, 0.0, 6.0 ] ); @@ -233,7 +228,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { var expected; var x; var y; - var N; var i; x = new Float64Array([ @@ -250,9 +244,8 @@ tape( 'the function supports negative strides', opts, function test( t ) { 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, -2, x.length-1, y, -1, 2 ); + dcusumors( 3, 0.0, x, -2, x.length-1, y, -1, 2 ); expected = new Float64Array( [ 9.0, 8.0, 5.0, 0.0, 0.0 ] ); t.deepEqual( y, expected, 'returns expected value' ); @@ -277,7 +270,6 @@ tape( 'the function supports negative strides', opts, function test( t ) { tape( 'the function supports an `x` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -301,9 +293,8 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { 0.0, 0.0 ]); - N = floor( x.length / 2 ); - dcusumors( N, 0.0, x, 2, 1, y, 1, 0 ); + dcusumors( 4, 0.0, x, 2, 1, y, 1, 0 ); expected = new Float64Array( [ 1.0, -1.0, 1.0, 5.0, 0.0, 0.0, 0.0, 0.0 ] ); @@ -313,7 +304,6 @@ tape( 'the function supports an `x` offset', opts, function test( t ) { tape( 'the function supports a `y` offset', opts, function test( t ) { var expected; - var N; var x; var y; @@ -337,9 +327,8 @@ tape( 'the function supports a `y` offset', opts, function test( t ) { 0.0, 0.0 // 3 ]); - N = floor( x.length / 2 ); - dcusumors( N, 0.0, x, 1, 0, y, 2, 1 ); + dcusumors( 4, 0.0, x, 1, 0, y, 2, 1 ); expected = new Float64Array( [ 0.0, 2.0, 0.0, 3.0, 0.0, 5.0, 0.0, 3.0 ] ); @@ -351,7 +340,6 @@ tape( 'the function supports complex access patterns', opts, function test( t ) var expected; var x; var y; - var N; x = new Float64Array([ 1.0, // 0 @@ -369,9 +357,8 @@ tape( 'the function supports complex access patterns', opts, function test( t ) 0.0, 0.0 ]); - N = 3; - dcusumors( N, 0.0, x, 2, 0, y, -1, 2 ); + dcusumors( 3, 0.0, x, 2, 0, y, -1, 2 ); expected = new Float64Array( [ 9.0, 4.0, 1.0, 0.0, 0.0, 0.0 ] );