From bf879b0c71cd05aa167d649b8b7f811e74c98104 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 13 Mar 2026 05:24:12 +0500 Subject: [PATCH 01/10] feat: add blas/ext/base/gediff --- .../@stdlib/blas/ext/base/gediff/README.md | 209 ++++++++ .../ext/base/gediff/benchmark/benchmark.js | 123 +++++ .../gediff/benchmark/benchmark.ndarray.js | 123 +++++ .../blas/ext/base/gediff/docs/repl.txt | 161 ++++++ .../ext/base/gediff/docs/types/index.d.ts | 135 +++++ .../blas/ext/base/gediff/docs/types/test.ts | 506 ++++++++++++++++++ .../blas/ext/base/gediff/examples/index.js | 43 ++ .../blas/ext/base/gediff/lib/accessors.js | 111 ++++ .../@stdlib/blas/ext/base/gediff/lib/index.js | 67 +++ .../@stdlib/blas/ext/base/gediff/lib/main.js | 69 +++ .../blas/ext/base/gediff/lib/ndarray.js | 113 ++++ .../@stdlib/blas/ext/base/gediff/package.json | 65 +++ .../@stdlib/blas/ext/base/gediff/test/test.js | 38 ++ .../blas/ext/base/gediff/test/test.main.js | 193 +++++++ .../blas/ext/base/gediff/test/test.ndarray.js | 207 +++++++ 15 files changed, 2163 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md new file mode 100644 index 000000000000..15c993a874d3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -0,0 +1,209 @@ + + +# gediff + +> Calculate the differences between consecutive elements of a strided array. + +
+ +## Usage + +```javascript +var gediff = require( '@stdlib/blas/ext/base/gediff' ); +``` + + + +#### gediff( N, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut ) + +Calculates the differences between consecutive elements of a strided array. + +```javascript +var x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; +var p = [ 1.0 ]; +var a = [ 11.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); + +console.log( out ); +// => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **x**: input array. +- **strideX**: stride length for `x`. +- **N1**: number of elements to `prepend`. +- **prepend**: array containing values to prepend to the output array. +- **strideP**: stride length for `prepend`. +- **N2**: number of elements to `append`. +- **append**: array containing values to append to the output array. +- **strideA**: stride length for `append`. +- **out**: output array. Must have `N + N1 + N2 - 1` elements. +- **strideOut**: stride length for `out`. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute differences of every other element: + +```javascript +var x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; +var p = [ 1.0 ]; +var a = [ 11.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0 ]; + +gediff( 3, x, 2, 1, p, 1, 1, a, 1, out, 1 ); + +console.log( out ); +// => [ 1.0, 4.0, 4.0, 11.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array... +var x0 = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + +// Create an offset view... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var p = [ 1.0 ]; +var a = [ 11.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gediff( x1.length, x1, 1, 1, p, 1, 1, a, 1, out, 1 ); + +console.log( out ); +// => [ 1.0, 2.0, 2.0, 2.0, 11.0 ] +``` + + + +#### gediff.ndarray( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) + +Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. + +```javascript +var x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; +var p = [ 1.0 ]; +var a = [ 11.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); + +console.log( out ); +// => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetP**: starting index for `prepend`. +- **offsetA**: starting index for `append`. +- **offsetOut**: starting index for `out`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements: + +```javascript +var x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; +var p = [ 1.0 ]; +var a = [ 11.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0 ]; + +gediff.ndarray( 3, x, 1, x.length-3, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); + +console.log( out ); +// => [ 1.0, 2.0, 2.0, 11.0 ] +``` + +
+ + + +
+ +## Notes + +- If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, both functions return the output array unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var gediff = require( '@stdlib/blas/ext/base/gediff' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Input array: ', x ); + +var p = discreteUniform( 2, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Prepend array: ', p ); + +var a = discreteUniform( 2, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Append array: ', a ); + +var out = zeros( 13 ); + +gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); +console.log( 'Output', out ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js new file mode 100644 index 000000000000..4d22cb067779 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gediff = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var ol; + var N1; + var N2; + var x; + var p; + var a; + var o; + var N; + var i; + + N = len; + N1 = 1; + N2 = 1; + ol = N + N1 + N2 - 1; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + o = []; + for ( i = 0; i < ol; i++ ) { + o.push( 0.0 ); + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + gediff( N, x, 1, N1, p, 1, N2, a, 1, o, 1 ); + if ( isnan( o[ i%ol ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( o[ i%ol ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..8839933054ab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js @@ -0,0 +1,123 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var gediff = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var ol; + var N1; + var N2; + var x; + var p; + var a; + var o; + var N; + var i; + + N = len; + N1 = 1; + N2 = 1; + ol = N + N1 + N2 - 1; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + o = []; + for ( i = 0; i < ol; i++ ) { + o.push( 0.0 ); + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + gediff( N, x, 1, 0, N1, p, 1, 0, N2, a, 1, 0, o, 1, 0 ); + if ( isnan( o[ i%ol ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( o[ i%ol ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt new file mode 100644 index 000000000000..933562003001 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt @@ -0,0 +1,161 @@ + +{{alias}}( N, x, sx, N1, p, sp, N2, a, sa, out, so ) + Calculates the differences between consecutive elements of a strided array. + + 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. + + If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, the function + returns the output array unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: ArrayLikeObject + Input array. + + sx: integer + Stride length for `x`. + + N1: integer + Number of elements to `prepend`. + + p: ArrayLikeObject + Array containing values to prepend to the output array. + + sp: integer + Stride length for `prepend`. + + N2: integer + Number of elements to `append`. + + a: ArrayLikeObject + Array containing values to append to the output array. + + sa: integer + Stride length for `append`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Standard Usage: + > var x = [ 1.0, -2.0, 2.0 ]; + > var p = [ 0.0 ]; + > var a = [ 3.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ) + [ 0.0, -3.0, 4.0, 3.0 ] + + // Using `N` and stride parameters: + > x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; + > p = [ 1.0 ]; + > a = [ 11.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 3, x, 2, 1, p, 1, 1, a, 1, out, 1 ) + [ 1.0, 4.0, 4.0, 11.0 ] + + // Using view offsets: + > var x0 = new {{alias:@stdlib/array/float64}}( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > p = [ 1.0 ]; + > a = [ 11.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( x1.length, x1, 1, 1, p, 1, 1, a, 1, out, 1 ) + [ 1.0, 2.0, 2.0, 2.0, 11.0 ] + + +{{alias}}.ndarray( N, x, sx, ox, N1, p, sp, op, N2, a, sa, oa, out, so, oo ) + Calculates the differences between consecutive elements of a strided array + using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on + starting indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + x: ArrayLikeObject + Input array. + + sx: integer + Stride length for `x`. + + ox: integer + Starting index for `x`. + + N1: integer + Number of elements to `prepend`. + + p: ArrayLikeObject + Array containing values to prepend to the output array. + + sp: integer + Stride length for `prepend`. + + op: integer + Starting index for `prepend`. + + N2: integer + Number of elements to `append`. + + a: ArrayLikeObject + Array containing values to append to the output array. + + sa: integer + Stride length for `append`. + + oa: integer + Starting index for `append`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Standard Usage: + > var x = [ 1.0, -2.0, 2.0 ]; + > var p = [ 0.0 ]; + > var a = [ 3.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ) + [ 0.0, -3.0, 4.0, 3.0 ] + + // Advanced indexing: + > x = [ 1.0, -2.0, 2.0 ]; + > p = [ 0.0 ]; + > a = [ 3.0 ]; + > out = [ 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 2, x, 1, 1, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ) + [ 0.0, 4.0, 3.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts new file mode 100644 index 000000000000..9f978c0cc5db --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts @@ -0,0 +1,135 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection } from '@stdlib/types/array'; + +/** +* Interface describing `gediff`. +*/ +interface Routine { + /** + * Calculates the differences between consecutive elements of a strided array. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length for `x` + * @param N1 - number of indexed elements of prepend + * @param prepend - prepend array + * @param strideP - stride length for `prepend` + * @param N2 - number of indexed elements of append + * @param append - append array + * @param strideA - stride length for `append` + * @param out - output array + * @param strideOut - stride length for `out` + * @returns output array + * + * @example + * var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; + * var p = [ 1.0 ]; + * var a = [ 22.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); + * + * console.log( out ); + * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] + */ + ( N: number, x: Collection, strideX: number, N1: number, prepend: Collection, strideP: number, N2: number, append: Collection, strideA: number, out: Collection, strideOut: number ): Collection; + + /** + * Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param x - input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @param N1 - number of indexed elements of prepend + * @param prepend - prepend array + * @param strideP - stride length for `prepend` + * @param offsetP - starting index for `prepend` + * @param N2 - number of indexed elements of append + * @param append - append array + * @param strideA - stride length for `append` + * @param offsetA - starting index for `append` + * @param out - output array + * @param strideOut - stride length for `out` + * @param offsetOut - starting index for `out` + * @returns output array + * + * @example + * var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; + * var p = [ 1.0 ]; + * var a = [ 22.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); + * + * console.log( out ); + * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] + */ + ndarray( N: number, x: Collection, strideX: number, offsetX: number, N1: number, prepend: Collection, strideP: number, offsetP: number, N2: number, append: Collection, strideA: number, offsetA: number, out: Collection, strideOut: number, offsetOut: number ): Collection; +} + +/** +* Calculates the differences between consecutive elements of a strided array. +* +* @param N - number of indexed elements +* @param x - input array +* @param strideX - stride length for `x` +* @param N1 - number of indexed elements of prepend +* @param prepend - prepend array +* @param strideP - stride length for `prepend` +* @param N2 - number of indexed elements of append +* @param append - append array +* @param strideA - stride length for `append` +* @param out - output array +* @param strideOut - stride length for `out` +* @returns output array +* +* @example +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* +* @example +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +*/ +declare var gediff: Routine; + + +// EXPORTS // + +export = gediff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts new file mode 100644 index 000000000000..c6c7e48b446d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts @@ -0,0 +1,506 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +*/ + +import gediff = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectType Collection +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( '10', x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( true, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( false, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( null, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( undefined, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( [], x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( {}, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( ( x: number ): number => x, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a collection... +{ + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( 5, 10, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( 5, true, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( 5, false, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( 5, null, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( 5, undefined, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( 5, {}, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, '10', 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, true, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, false, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, null, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, undefined, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, [], 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, {}, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, ( x: number ): number => x, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, '10', p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, true, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, false, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, null, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, undefined, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, [], p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, {}, p, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, ( x: number ): number => x, p, 1, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, 10, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, true, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, false, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, null, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, undefined, 1, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, {}, 1, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, '10', 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, true, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, false, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, null, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, undefined, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, [], 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, {}, 1, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, ( x: number ): number => x, 1, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, 1, '10', a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, true, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, false, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, null, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, undefined, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, [], a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, {}, a, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, ( x: number ): number => x, a, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, 1, 1, 10, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, true, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, false, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, null, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, undefined, 1, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, {}, 1, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, 1, 1, a, '10', out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, true, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, false, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, null, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, undefined, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, [], out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, {}, out, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, ( x: number ): number => x, out, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, 10, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, true, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, false, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, null, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, undefined, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, {}, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, '10' ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, true ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, false ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, null ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, undefined ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, [] ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, {} ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff(); // $ExpectError + gediff( x.length ); // $ExpectError + gediff( x.length, x ); // $ExpectError + gediff( x.length, x, 1 ); // $ExpectError + gediff( x.length, x, 1, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectType Collection +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( '10', x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( true, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( false, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( null, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( undefined, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( [], x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( {}, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( ( x: number ): number => x, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection... +{ + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( 5, 10, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( 5, true, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( 5, false, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( 5, null, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( 5, undefined, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( 5, {}, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, '10', 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, true, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, false, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, null, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, undefined, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, [], 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, {}, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, ( x: number ): number => x, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, '10', 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, true, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, false, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, null, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, undefined, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, [], 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, {}, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, ( x: number ): number => x, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, '10', p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, true, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, false, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, null, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, undefined, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, [], p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, {}, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, ( x: number ): number => x, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, 10, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, true, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, false, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, null, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, undefined, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, {}, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, '10', 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, true, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, false, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, null, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, undefined, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, [], 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, {}, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, ( x: number ): number => x, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, '10', 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, true, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, false, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, null, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, undefined, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, [], 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, {}, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, ( x: number ): number => x, 1, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, '10', a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, true, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, false, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, null, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, undefined, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, [], a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, {}, a, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, ( x: number ): number => x, a, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, 10, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, true, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, false, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, null, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, undefined, 1, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, {}, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, '10', 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, true, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, false, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, null, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, undefined, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, [], 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, {}, 0, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, '10', out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, true, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, false, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, null, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, undefined, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, [], out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, {}, out, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a collection... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, 10, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, true, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, false, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, null, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, undefined, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, {}, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, '10', 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, true, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, false, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, null, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, undefined, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, [], 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, {}, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifteenth argument which is not a number... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, '10' ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, true ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, false ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, null ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, undefined ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, [] ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, {} ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; + const p = [ 1.0 ]; + const a = [ 22.0 ]; + const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gediff.ndarray(); // $ExpectError + gediff.ndarray( x.length ); // $ExpectError + gediff.ndarray( x.length, x ); // $ExpectError + gediff.ndarray( x.length, x, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js new file mode 100644 index 000000000000..a0ef948aefeb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var zeros = require( '@stdlib/array/zeros' ); +var gediff = require( './../lib' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Input array: ', x ); + +var p = discreteUniform( 2, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Prepend array: ', p ); + +var a = discreteUniform( 2, -100, 100, { + 'dtype': 'generic' +}); +console.log( 'Append array: ', a ); + +var out = zeros( 13 ); + +gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); +console.log( 'Output', out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js new file mode 100644 index 000000000000..8800e193c131 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -0,0 +1,111 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-params, max-len */ + +'use strict'; + +// MODULES // + +var gcopy = require( '@stdlib/blas/base/gcopy' ); + + +// MAIN // + +/** +* Calculates the differences between consecutive elements of a strided array using alternative indexing semantics and accessors. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Object} x - input array object +* @param {Collection} x.data - input array data +* @param {Array} x.accessors - array element accessors +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Object} prepend - prepend array object +* @param {Collection} prepend.data - prepend array data +* @param {Array} prepend.accessors - array element accessors +* @param {integer} strideP - stride length for `prepend` +* @param {NonNegativeInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Object} append - append array object +* @param {Collection} append.data - append array data +* @param {Array} append.accessors - array element accessors +* @param {integer} strideA - stride length for `append` +* @param {NonNegativeInteger} offsetA - starting index for `append` +* @param {Object} out - output array object +* @param {Collection} out.data - output array data +* @param {Array} out.accessors - array element accessors +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Object} output array object +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; +* var p = [ 10.0, 15.0 ]; +* var a = [ 30.0, 35.0 ]; +* var o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff( 5, arraylike2object( toAccessorArray( x ) ), 1, 0, 2, arraylike2object( toAccessorArray( p ) ), 1, 0, 2, arraylike2object( toAccessorArray( a ) ), 1, 0, arraylike2object( toAccessorArray( o ) ), 1, 0 ); +* // o => [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ] +*/ +function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { + var xbuf; + var obuf; + var oset; + var xget; + var prev; + var curr; + var ix; + var io; + var i; + + xbuf = x.data; + obuf = out.data; + xget = x.accessors[ 0 ]; + oset = out.accessors[ 1 ]; + + // Copy `prepend` into output array: + gcopy.ndarray( N1, prepend.data, strideP, offsetP, obuf, strideOut, offsetOut ); + + // Compute differences of input array: + ix = offsetX; + io = offsetOut + ( N1 * strideOut ); + prev = xget( xbuf, ix ); + for ( i = 1; i < N; i++ ) { + ix += strideX; + curr = xget( xbuf, ix ); + oset( obuf, io, curr - prev ); + prev = curr; + io += strideOut; + } + + // Copy `append` into output array: + gcopy.ndarray( N2, append.data, strideA, offsetA, obuf, strideOut, io ); + + return out; +} + + +// EXPORTS // + +module.exports = gediff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js new file mode 100644 index 000000000000..1775456dff9c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Calculate the differences between consecutive elements of a strided array. +* +* @module @stdlib/blas/ext/base/gediff +* +* @example +* var gediff = require( '@stdlib/blas/ext/base/gediff' ); +* +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* +* @example +* var gediff = require( '@stdlib/blas/ext/base/gediff' ); +* +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js new file mode 100644 index 000000000000..f44437873932 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-params, max-len */ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Calculates the differences between consecutive elements of a strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Collection} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Collection} append - append array +* @param {integer} strideA - stride length for `append` +* @param {Collection} out - output array +* @param {integer} strideOut - stride length for `out` +* @returns {Collection} output array +* +* @example +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +*/ +function gediff( N, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut ) { + var ox = stride2offset( N, strideX ); + var op = stride2offset( N1, strideP ); + var oa = stride2offset( N2, strideA ); + var oo = stride2offset( N + N1 + N2 - 1, strideOut ); + return ndarray( N, x, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo ); +} + + +// EXPORTS // + +module.exports = gediff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js new file mode 100644 index 000000000000..0ffe12294453 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js @@ -0,0 +1,113 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-params, max-len */ + +'use strict'; + +// MODULES // + +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var gcopy = require( '@stdlib/blas/base/gcopy' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {Collection} x - input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Collection} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {NonNegativeInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Collection} append - append array +* @param {integer} strideA - stride length for `append` +* @param {NonNegativeInteger} offsetA - starting index for `append` +* @param {Collection} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Collection} output array +* +* @example +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gediff( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); +* +* console.log( out ); +* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +*/ +function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { + var total; + var prev; + var curr; + var ox; + var oo; + var op; + var oa; + var ix; + var io; + var i; + + total = N + N1 + N2; + if ( total <= 1 ) { + return out; + } + + ox = arraylike2object( x ); + oo = arraylike2object( out ); + op = arraylike2object( prepend ); + oa = arraylike2object( append ); + if ( ox.accessorProtocol || oo.accessorProtocol || op.accessorProtocol || oa.accessorProtocol ) { + accessors( N, ox, strideX, offsetX, N1, op, strideP, offsetP, N2, oa, strideA, offsetA, oo, strideOut, offsetOut ); + return oo.data; + } + + // Copy `prepend` into output array: + gcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + + // Compute differences of input array: + ix = offsetX; + io = offsetOut + ( N1 * strideOut ); + prev = x[ ix ]; + for ( i = 1; i < N; i++ ) { + ix += strideX; + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + + // Copy `append` into output array: + gcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + + return out; +} + + +// EXPORTS // + +module.exports = gediff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/package.json b/lib/node_modules/@stdlib/blas/ext/base/gediff/package.json new file mode 100644 index 000000000000..fc1f4806b055 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/blas/ext/base/gediff", + "version": "0.0.0", + "description": "Calculate the differences between consecutive elements of a strided array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "diff", + "difference", + "gradient", + "strided", + "array", + "ndarray" + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.js new file mode 100644 index 000000000000..744552ee19ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var gediff = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gediff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof gediff.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js new file mode 100644 index 000000000000..7a5a6032eb33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js @@ -0,0 +1,193 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gediff = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gediff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( gediff.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates differences between consecutive elements of a strided array', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0 ]; + a = [ 30.0, 35.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 2, p, 1, 2, a, 1, o, 1 ); + expected = [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates differences between consecutive elements of a strided array (accessors)', function test( t ) { + var expected; + var xbuf; + var pbuf; + var abuf; + var obuf; + var x; + var p; + var a; + var o; + + xbuf = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + pbuf = [ 10.0, 15.0 ]; + abuf = [ 30.0, 35.0 ]; + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + x = toAccessorArray( xbuf ); + p = toAccessorArray( pbuf ); + a = toAccessorArray( abuf ); + o = toAccessorArray( obuf ); + + gediff( x.length, x, 1, 2, p, 1, 2, a, 1, o, 1 ); + expected = [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0 ]; + a = [ 30.0, 35.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 1, x, 1, 0, p, 1, 0, a, 1, o, 1 ); + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports stride parameters', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0, 25.0 ]; + a = [ 30.0, 35.0, 45.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 3, x, 2, 2, p, 2, 2, a, 2, o, 2 ); + expected = [ 10.0, 0.0, 25.0, 0.0, 8.0, 0.0, 8.0, 0.0, 30.0, 0.0, 45.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports stride parameters (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0, 15.0, 25.0 ] ); + a = toAccessorArray( [ 30.0, 35.0, 45.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 3, x, 2, 2, p, 2, 2, a, 2, o, 2 ); + expected = [ 10.0, 0.0, 25.0, 0.0, 8.0, 0.0, 8.0, 0.0, 30.0, 0.0, 45.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0, 25.0 ]; + a = [ 30.0, 35.0, 45.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 3, x, -2, 2, p, -2, 2, a, -2, o, -2 ); + expected = [ 30.0, 0.0, 45.0, 0.0, -8.0, 0.0, -8.0, 0.0, 10.0, 0.0, 25.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0, 15.0, 25.0 ] ); + a = toAccessorArray( [ 30.0, 35.0, 45.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 3, x, -2, 2, p, -2, 2, a, -2, o, -2 ); + expected = [ 30.0, 0.0, 45.0, 0.0, -8.0, 0.0, -8.0, 0.0, 10.0, 0.0, 25.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js new file mode 100644 index 000000000000..dd95a3bbbbfb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js @@ -0,0 +1,207 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var gediff = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gediff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 15', function test( t ) { + t.strictEqual( gediff.length, 15, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates differences between consecutive elements of a strided array', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0 ]; + a = [ 30.0, 35.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0 ); + expected = [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function calculates differences between consecutive elements of a strided array (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0, 15.0 ] ); + a = toAccessorArray( [ 30.0, 35.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( x.length, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0 ); + expected = [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0 ]; + a = [ 30.0, 35.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0 ); + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports stride parameters', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0, 25.0 ]; + a = [ 30.0, 35.0, 45.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 3, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0 ); + expected = [ 10.0, 0.0, 25.0, 0.0, 8.0, 0.0, 8.0, 0.0, 30.0, 0.0, 45.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0, 15.0, 25.0 ]; + a = [ 30.0, 35.0, 45.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 3, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10 ); + expected = [ 30.0, 0.0, 45.0, 0.0, -8.0, 0.0, -8.0, 0.0, 10.0, 0.0, 25.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0, 15.0, 25.0 ] ); + a = toAccessorArray( [ 30.0, 35.0, 45.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 3, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10 ); + expected = [ 30.0, 0.0, 45.0, 0.0, -8.0, 0.0, -8.0, 0.0, 10.0, 0.0, 25.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports offset parameters', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 0.0, 4.0, 8.0, 12.0, 16.0, 20.0 ]; + p = [ 10.0 ]; + a = [ 30.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( 3, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); + expected = [ 10.0, 4.0, 4.0, 30.0, 0.0, 0.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports offset parameters (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 0.0, 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0 ] ); + a = toAccessorArray( [ 30.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 3, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); + expected = [ 10.0, 4.0, 4.0, 30.0, 0.0, 0.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); From 6dab75c0d4bb42aab2b15ff07c6210e3e9a4623b Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 23 Apr 2026 00:13:59 +0500 Subject: [PATCH 02/10] refactor: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: skipped - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/gediff/README.md | 12 +- .../blas/ext/base/gediff/docs/repl.txt | 72 ++++----- .../ext/base/gediff/docs/types/index.d.ts | 40 +++-- .../blas/ext/base/gediff/docs/types/test.ts | 4 +- .../blas/ext/base/gediff/examples/index.js | 2 +- .../blas/ext/base/gediff/lib/accessors.js | 12 +- .../@stdlib/blas/ext/base/gediff/lib/main.js | 4 +- .../blas/ext/base/gediff/lib/ndarray.js | 12 +- .../blas/ext/base/gediff/test/test.main.js | 151 ++++++++++++++++++ .../blas/ext/base/gediff/test/test.ndarray.js | 150 +++++++++++++++++ 10 files changed, 391 insertions(+), 68 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md index 15c993a874d3..7ac7a9cb294d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -53,11 +53,11 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input array. - **strideX**: stride length for `x`. -- **N1**: number of elements to `prepend`. -- **prepend**: array containing values to prepend to the output array. +- **N1**: number of indexed elements to `prepend`. +- **prepend**: array containing values to prepend after computing differences. - **strideP**: stride length for `prepend`. -- **N2**: number of elements to `append`. -- **append**: array containing values to append to the output array. +- **N2**: number of indexed elements to `append`. +- **append**: array containing values to append after computing differences. - **strideA**: stride length for `append`. - **out**: output array. Must have `N + N1 + N2 - 1` elements. - **strideOut**: stride length for `out`. @@ -144,7 +144,7 @@ console.log( out ); ## Notes -- If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, both functions return the output array unchanged. +- If `N + N1 + N2 <= 1`, both functions return the output array unchanged. @@ -179,7 +179,7 @@ console.log( 'Append array: ', a ); var out = zeros( 13 ); gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); -console.log( 'Output', out ); +console.log( 'Output: ', out ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt index 933562003001..d596eef674df 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, x, sx, N1, p, sp, N2, a, sa, out, so ) +{{alias}}( N, x,sx, N1, p,sp, N2, a,sa, out,so ) Calculates the differences between consecutive elements of a strided array. The `N` and stride parameters determine which elements in the strided arrays @@ -8,52 +8,51 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - If the sum of `N`, `N1`, and `N2` is less than or equal to `1`, the function - returns the output array unchanged. + If `N + N1 + N2 <= 1`, the function returns the output array unchanged. Parameters ---------- N: integer Number of indexed elements. - x: ArrayLikeObject + x: Array|TypedArray Input array. sx: integer Stride length for `x`. N1: integer - Number of elements to `prepend`. + Number of indexed elements to prepend. - p: ArrayLikeObject - Array containing values to prepend to the output array. + p: Array|TypedArray + Array containing values to prepend after computing differences. sp: integer - Stride length for `prepend`. + Stride length for `p`. N2: integer - Number of elements to `append`. + Number of indexed elements to append. - a: ArrayLikeObject - Array containing values to append to the output array. + a: Array|TypedArray + Array containing values to append after computing differences. sa: integer - Stride length for `append`. + Stride length for `a`. - out: ArrayLikeObject - Output array. + out: Array|TypedArray + Output array. Must have `N + N1 + N2 - 1` indexed elements. so: integer Stride length for `out`. Returns ------- - out: ArrayLikeObject + out: Array|TypedArray Output array. Examples -------- - // Standard Usage: + // Standard usage: > var x = [ 1.0, -2.0, 2.0 ]; > var p = [ 0.0 ]; > var a = [ 3.0 ]; @@ -65,7 +64,7 @@ > x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; > p = [ 1.0 ]; > a = [ 11.0 ]; - > var out = [ 0.0, 0.0, 0.0, 0.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0 ]; > {{alias}}( 3, x, 2, 1, p, 1, 1, a, 1, out, 1 ) [ 1.0, 4.0, 4.0, 11.0 ] @@ -74,12 +73,12 @@ > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > p = [ 1.0 ]; > a = [ 11.0 ]; - > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; > {{alias}}( x1.length, x1, 1, 1, p, 1, 1, a, 1, out, 1 ) [ 1.0, 2.0, 2.0, 2.0, 11.0 ] -{{alias}}.ndarray( N, x, sx, ox, N1, p, sp, op, N2, a, sa, oa, out, so, oo ) +{{alias}}.ndarray( N, x,sx,ox, N1, p,sp,op, N2, a,sa,oa, out,so,oo ) Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. @@ -92,7 +91,7 @@ N: integer Number of indexed elements. - x: ArrayLikeObject + x: Array|TypedArray Input array. sx: integer @@ -102,31 +101,31 @@ Starting index for `x`. N1: integer - Number of elements to `prepend`. + Number of indexed elements to prepend. - p: ArrayLikeObject - Array containing values to prepend to the output array. + p: Array|TypedArray + Array containing values to prepend after computing differences. sp: integer - Stride length for `prepend`. + Stride length for `p`. op: integer - Starting index for `prepend`. + Starting index for `p`. N2: integer - Number of elements to `append`. + Number of indexed elements to append. - a: ArrayLikeObject - Array containing values to append to the output array. + a: Array|TypedArray + Array containing values to append after computing differences. sa: integer - Stride length for `append`. + Stride length for `a`. oa: integer - Starting index for `append`. + Starting index for `a`. - out: ArrayLikeObject - Output array. + out: Array|TypedArray + Output array. Must have `N + N1 + N2 - 1` indexed elements. so: integer Stride length for `out`. @@ -136,17 +135,17 @@ Returns ------- - out: ArrayLikeObject + out: Array|TypedArray Output array. Examples -------- - // Standard Usage: + // Standard usage: > var x = [ 1.0, -2.0, 2.0 ]; > var p = [ 0.0 ]; > var a = [ 3.0 ]; > var out = [ 0.0, 0.0, 0.0, 0.0 ]; - > {{alias}}.ndarray( 3, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ) + > {{alias}}.ndarray( 3, x,1,0, 1, p,1,0, 1, a,1,0, out,1,0 ) [ 0.0, -3.0, 4.0, 3.0 ] // Advanced indexing: @@ -154,8 +153,9 @@ > p = [ 0.0 ]; > a = [ 3.0 ]; > out = [ 0.0, 0.0, 0.0 ]; - > {{alias}}.ndarray( 2, x, 1, 1, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ) + > {{alias}}.ndarray( 2, x,1,1, 1, p,1,0, 1, a,1,0, out,1,0 ) [ 0.0, 4.0, 3.0 ] See Also -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts index 9f978c0cc5db..321c484daf38 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts @@ -20,7 +20,17 @@ /// -import { Collection } from '@stdlib/types/array'; +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; + +/** +* Output array. +*/ +type OutputArray = NumericArray | Collection | AccessorArrayLike; /** * Interface describing `gediff`. @@ -29,13 +39,17 @@ interface Routine { /** * Calculates the differences between consecutive elements of a strided array. * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - 1` elements. + * * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` - * @param N1 - number of indexed elements of prepend + * @param N1 - number of indexed elements to `prepend` * @param prepend - prepend array * @param strideP - stride length for `prepend` - * @param N2 - number of indexed elements of append + * @param N2 - number of indexed elements to `append` * @param append - append array * @param strideA - stride length for `append` * @param out - output array @@ -53,20 +67,24 @@ interface Routine { * console.log( out ); * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ - ( N: number, x: Collection, strideX: number, N1: number, prepend: Collection, strideP: number, N2: number, append: Collection, strideA: number, out: Collection, strideOut: number ): Collection; + ( N: number, x: InputArray, strideX: number, N1: number, prepend: InputArray, strideP: number, N2: number, append: InputArray, strideA: number, out: T, strideOut: number ): T; /** * Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - 1` elements. + * * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` - * @param N1 - number of indexed elements of prepend + * @param N1 - number of indexed elements to `prepend` * @param prepend - prepend array * @param strideP - stride length for `prepend` * @param offsetP - starting index for `prepend` - * @param N2 - number of indexed elements of append + * @param N2 - number of indexed elements to `append` * @param append - append array * @param strideA - stride length for `append` * @param offsetA - starting index for `append` @@ -86,19 +104,23 @@ interface Routine { * console.log( out ); * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ - ndarray( N: number, x: Collection, strideX: number, offsetX: number, N1: number, prepend: Collection, strideP: number, offsetP: number, N2: number, append: Collection, strideA: number, offsetA: number, out: Collection, strideOut: number, offsetOut: number ): Collection; + ndarray( N: number, x: InputArray, strideX: number, offsetX: number, N1: number, prepend: InputArray, strideP: number, offsetP: number, N2: number, append: InputArray, strideA: number, offsetA: number, out: T, strideOut: number, offsetOut: number ): T; } /** * Calculates the differences between consecutive elements of a strided array. * +* ## Notes +* +* - The `out` array must have `N + N1 + N2 - 1` elements. +* * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` -* @param N1 - number of indexed elements of prepend +* @param N1 - number of indexed elements to `prepend` * @param prepend - prepend array * @param strideP - stride length for `prepend` -* @param N2 - number of indexed elements of append +* @param N2 - number of indexed elements to `append` * @param append - append array * @param strideA - stride length for `append` * @param out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts index c6c7e48b446d..fb1e5f5703e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts @@ -224,7 +224,7 @@ import gediff = require( './index' ); gediff( x.length, x, 1, 1, p, 1, 1, a ); // $ExpectError gediff( x.length, x, 1, 1, p, 1, 1, a, 1 ); // $ExpectError gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out ); // $ExpectError - gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1, 10 ); // $ExpectError + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1, {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a collection... @@ -502,5 +502,5 @@ import gediff = require( './index' ); gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0 ); // $ExpectError gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out ); // $ExpectError gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1 ); // $ExpectError - gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, 10 ); // $ExpectError + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js index a0ef948aefeb..ebbd9a49e92a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js @@ -40,4 +40,4 @@ console.log( 'Append array: ', a ); var out = zeros( 13 ); gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); -console.log( 'Output', out ); +console.log( 'Output: ', out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js index 8800e193c131..ad0b293ca254 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -36,24 +36,24 @@ var gcopy = require( '@stdlib/blas/base/gcopy' ); * @param {Collection} x.data - input array data * @param {Array} x.accessors - array element accessors * @param {integer} strideX - stride length for `x` -* @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements to `prepend` * @param {Object} prepend - prepend array object * @param {Collection} prepend.data - prepend array data * @param {Array} prepend.accessors - array element accessors * @param {integer} strideP - stride length for `prepend` -* @param {NonNegativeInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements to `append` * @param {Object} append - append array object * @param {Collection} append.data - append array data * @param {Array} append.accessors - array element accessors * @param {integer} strideA - stride length for `append` -* @param {NonNegativeInteger} offsetA - starting index for `append` +* @param {PositiveInteger} offsetA - starting index for `append` * @param {Object} out - output array object * @param {Collection} out.data - output array data * @param {Array} out.accessors - array element accessors * @param {integer} strideOut - stride length for `out` -* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` * @returns {Object} output array object * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js index f44437873932..0b919834c8cb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js @@ -34,10 +34,10 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array * @param {integer} strideX - stride length for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} N1 - number of indexed elements to `prepend` * @param {Collection} prepend - prepend array * @param {integer} strideP - stride length for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} N2 - number of indexed elements to `append` * @param {Collection} append - append array * @param {integer} strideA - stride length for `append` * @param {Collection} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js index 0ffe12294453..d9f5afb4942c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js @@ -35,18 +35,18 @@ var accessors = require( './accessors.js' ); * @param {PositiveInteger} N - number of indexed elements * @param {Collection} x - input array * @param {integer} strideX - stride length for `x` -* @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements to `prepend` * @param {Collection} prepend - prepend array * @param {integer} strideP - stride length for `prepend` -* @param {NonNegativeInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements to `append` * @param {Collection} append - append array * @param {integer} strideA - stride length for `append` -* @param {NonNegativeInteger} offsetA - starting index for `append` +* @param {PositiveInteger} offsetA - starting index for `append` * @param {Collection} out - output array * @param {integer} strideOut - stride length for `out` -* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` * @returns {Collection} output array * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js index 7a5a6032eb33..af4fb8797ba7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js @@ -191,3 +191,154 @@ tape( 'the function supports negative stride parameters (accessors)', function t t.end(); }); + +tape( 'the function supports no prepend and no append', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 1.0, 3.0, 6.0, 10.0 ]; + p = []; + a = []; + o = [ 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, p, 1, 0, a, 1, o, 1 ); + expected = [ 2.0, 3.0, 4.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports no prepend and no append (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = toAccessorArray( [] ); + a = toAccessorArray( [] ); + obuf = [ 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 4, x, 1, 0, p, 1, 0, a, 1, o, 1 ); + expected = [ 2.0, 3.0, 4.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports multiple prepend and append values', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + // Multiple prepend (N1=2), no append: + x = [ 6.0, 8.0 ]; + p = [ 1.0, 3.0 ]; + a = []; + o = [ 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 2, p, 1, 0, a, 1, o, 1 ); + expected = [ 1.0, 3.0, 2.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = [ 2.0, 4.0 ]; + p = [ 1.0 ]; + a = [ 6.0, 10.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 1, p, 1, 2, a, 1, o, 1 ); + expected = [ 1.0, 2.0, 6.0, 10.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports multiple prepend and append values (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + // Multiple prepend (N1=2), no append: + x = toAccessorArray( [ 6.0, 8.0 ] ); + p = toAccessorArray( [ 1.0, 3.0 ] ); + a = toAccessorArray( [] ); + obuf = [ 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 2, p, 1, 0, a, 1, o, 1 ); + expected = [ 1.0, 3.0, 2.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = toAccessorArray( [ 2.0, 4.0 ] ); + p = toAccessorArray( [ 1.0 ] ); + a = toAccessorArray( [ 6.0, 10.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 1, p, 1, 2, a, 1, o, 1 ); + expected = [ 1.0, 2.0, 6.0, 10.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports append without prepend', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + // No prepend, x present, single append: + x = [ 2.0, 5.0 ]; + p = []; + a = [ 10.0 ]; + o = [ 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, p, 1, 1, a, 1, o, 1 ); + expected = [ 3.0, 10.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports append without prepend (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 2.0, 5.0 ] ); + p = toAccessorArray( [] ); + a = toAccessorArray( [ 10.0 ] ); + obuf = [ 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 0, p, 1, 1, a, 1, o, 1 ); + expected = [ 3.0, 10.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js index dd95a3bbbbfb..eac2ab420ca7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js @@ -205,3 +205,153 @@ tape( 'the function supports offset parameters (accessors)', function test( t ) t.end(); }); + +tape( 'the function supports no prepend and no append', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 1.0, 3.0, 6.0, 10.0 ]; + p = []; + a = []; + o = [ 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0 ); + expected = [ 2.0, 3.0, 4.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports no prepend and no append (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = toAccessorArray( [] ); + a = toAccessorArray( [] ); + obuf = [ 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 4, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0 ); + expected = [ 2.0, 3.0, 4.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports multiple prepend and append values', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + // Multiple prepend (N1=2), no append: + x = [ 6.0, 8.0 ]; + p = [ 1.0, 3.0 ]; + a = []; + o = [ 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0 ); + expected = [ 1.0, 3.0, 2.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = [ 2.0, 4.0 ]; + p = [ 1.0 ]; + a = [ 6.0, 10.0 ]; + o = [ 0.0, 0.0, 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, 1, p, 1, 0, 2, a, 1, 0, o, 1, 0 ); + expected = [ 1.0, 2.0, 6.0, 10.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports multiple prepend and append values (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + // Multiple prepend (N1=2), no append: + x = toAccessorArray( [ 6.0, 8.0 ] ); + p = toAccessorArray( [ 1.0, 3.0 ] ); + a = toAccessorArray( [] ); + obuf = [ 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0 ); + expected = [ 1.0, 3.0, 2.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = toAccessorArray( [ 2.0, 4.0 ] ); + p = toAccessorArray( [ 1.0 ] ); + a = toAccessorArray( [ 6.0, 10.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 0, 1, p, 1, 0, 2, a, 1, 0, o, 1, 0 ); + expected = [ 1.0, 2.0, 6.0, 10.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports append without prepend', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + + x = [ 2.0, 5.0 ]; + p = []; + a = [ 10.0 ]; + o = [ 0.0, 0.0 ]; + + out = gediff( x.length, x, 1, 0, 0, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); + expected = [ 3.0, 10.0 ]; + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports append without prepend (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 2.0, 5.0 ] ); + p = toAccessorArray( [] ); + a = toAccessorArray( [ 10.0 ] ); + obuf = [ 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 2, x, 1, 0, 0, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); + expected = [ 3.0, 10.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); From e1a9dc40ecc4172d2505c2b2aff08a957a151a1b Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 21 May 2026 01:06:06 +0500 Subject: [PATCH 03/10] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/gediff/README.md | 21 ++++++---- .../ext/base/gediff/benchmark/benchmark.js | 8 ++-- .../gediff/benchmark/benchmark.ndarray.js | 8 ++-- .../blas/ext/base/gediff/docs/repl.txt | 4 +- .../ext/base/gediff/docs/types/index.d.ts | 40 +++++-------------- .../blas/ext/base/gediff/docs/types/test.ts | 23 ++++++----- .../blas/ext/base/gediff/examples/index.js | 10 ++--- .../blas/ext/base/gediff/lib/accessors.js | 14 +++---- .../@stdlib/blas/ext/base/gediff/lib/index.js | 8 +--- .../@stdlib/blas/ext/base/gediff/lib/main.js | 20 +++++----- .../blas/ext/base/gediff/lib/ndarray.js | 28 ++++++------- .../blas/ext/base/gediff/test/test.main.js | 2 +- .../blas/ext/base/gediff/test/test.ndarray.js | 23 ++++++++++- 13 files changed, 103 insertions(+), 106 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md index 7ac7a9cb294d..54aa66644fb9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -34,6 +34,8 @@ var gediff = require( '@stdlib/blas/ext/base/gediff' ); #### gediff( N, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut ) + + Calculates the differences between consecutive elements of a strided array. ```javascript @@ -53,13 +55,13 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input array. - **strideX**: stride length for `x`. -- **N1**: number of indexed elements to `prepend`. +- **N1**: number of indexed elements to prepend. - **prepend**: array containing values to prepend after computing differences. - **strideP**: stride length for `prepend`. -- **N2**: number of indexed elements to `append`. +- **N2**: number of indexed elements to append. - **append**: array containing values to append after computing differences. - **strideA**: stride length for `append`. -- **out**: output array. Must have `N + N1 + N2 - 1` elements. +- **out**: output array. Must have `N + N1 + N2 - 1` indexed elements. - **strideOut**: stride length for `out`. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute differences of every other element: @@ -101,6 +103,8 @@ console.log( out ); #### gediff.ndarray( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) + + Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. ```javascript @@ -144,6 +148,7 @@ console.log( out ); ## Notes +- The output array must have `N + N1 + N2 - 1` indexed elements. - If `N + N1 + N2 <= 1`, both functions return the output array unchanged. @@ -164,22 +169,22 @@ var gediff = require( '@stdlib/blas/ext/base/gediff' ); var x = discreteUniform( 10, -100, 100, { 'dtype': 'generic' }); -console.log( 'Input array: ', x ); +console.log( 'Input array:', x ); var p = discreteUniform( 2, -100, 100, { 'dtype': 'generic' }); -console.log( 'Prepend array: ', p ); +console.log( 'Prepend array:', p ); var a = discreteUniform( 2, -100, 100, { 'dtype': 'generic' }); -console.log( 'Append array: ', a ); +console.log( 'Append array:', a ); -var out = zeros( 13 ); +var out = zeros( 13, 'generic' ); gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); -console.log( 'Output: ', out ); +console.log( 'Output:', out ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js index 4d22cb067779..8de4584521b0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -54,7 +55,6 @@ function createBenchmark( len ) { var a; var o; var N; - var i; N = len; N1 = 1; @@ -64,10 +64,8 @@ function createBenchmark( len ) { x = uniform( N, -100, 100, options ); p = uniform( N1, -100, 100, options ); a = uniform( N2, -100, 100, options ); - o = []; - for ( i = 0; i < ol; i++ ) { - o.push( 0.0 ); - } + o = zeros( ol, 'generic' ); + return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js index 8839933054ab..ecf90e7768bd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/benchmark/benchmark.ndarray.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var zeros = require( '@stdlib/array/zeros' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); @@ -54,7 +55,6 @@ function createBenchmark( len ) { var a; var o; var N; - var i; N = len; N1 = 1; @@ -64,10 +64,8 @@ function createBenchmark( len ) { x = uniform( N, -100, 100, options ); p = uniform( N1, -100, 100, options ); a = uniform( N2, -100, 100, options ); - o = []; - for ( i = 0; i < ol; i++ ) { - o.push( 0.0 ); - } + o = zeros( ol, 'generic' ); + return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt index d596eef674df..ca02dbb9096f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, x,sx, N1, p,sp, N2, a,sa, out,so ) +{{alias}}( N, x,sx, N1,p,sp, N2,a,sa, out,so ) Calculates the differences between consecutive elements of a strided array. The `N` and stride parameters determine which elements in the strided arrays @@ -78,7 +78,7 @@ [ 1.0, 2.0, 2.0, 2.0, 11.0 ] -{{alias}}.ndarray( N, x,sx,ox, N1, p,sp,op, N2, a,sa,oa, out,so,oo ) +{{alias}}.ndarray( N, x,sx,ox, N1,p,sp,op, N2,a,sa,oa, out,so,oo ) Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts index 321c484daf38..4047b51764b5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/index.d.ts @@ -39,17 +39,13 @@ interface Routine { /** * Calculates the differences between consecutive elements of a strided array. * - * ## Notes - * - * - The `out` array must have `N + N1 + N2 - 1` elements. - * * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` - * @param N1 - number of indexed elements to `prepend` + * @param N1 - number of indexed elements to prepend * @param prepend - prepend array * @param strideP - stride length for `prepend` - * @param N2 - number of indexed elements to `append` + * @param N2 - number of indexed elements to append * @param append - append array * @param strideA - stride length for `append` * @param out - output array @@ -63,28 +59,22 @@ interface Routine { * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); - * - * console.log( out ); - * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] + * // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ ( N: number, x: InputArray, strideX: number, N1: number, prepend: InputArray, strideP: number, N2: number, append: InputArray, strideA: number, out: T, strideOut: number ): T; /** * Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. * - * ## Notes - * - * - The `out` array must have `N + N1 + N2 - 1` elements. - * * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` - * @param N1 - number of indexed elements to `prepend` + * @param N1 - number of indexed elements to prepend * @param prepend - prepend array * @param strideP - stride length for `prepend` * @param offsetP - starting index for `prepend` - * @param N2 - number of indexed elements to `append` + * @param N2 - number of indexed elements to append * @param append - append array * @param strideA - stride length for `append` * @param offsetA - starting index for `append` @@ -100,9 +90,7 @@ interface Routine { * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); - * - * console.log( out ); - * // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] + * // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ ndarray( N: number, x: InputArray, strideX: number, offsetX: number, N1: number, prepend: InputArray, strideP: number, offsetP: number, N2: number, append: InputArray, strideA: number, offsetA: number, out: T, strideOut: number, offsetOut: number ): T; } @@ -110,17 +98,13 @@ interface Routine { /** * Calculates the differences between consecutive elements of a strided array. * -* ## Notes -* -* - The `out` array must have `N + N1 + N2 - 1` elements. -* * @param N - number of indexed elements * @param x - input array * @param strideX - stride length for `x` -* @param N1 - number of indexed elements to `prepend` +* @param N1 - number of indexed elements to prepend * @param prepend - prepend array * @param strideP - stride length for `prepend` -* @param N2 - number of indexed elements to `append` +* @param N2 - number of indexed elements to append * @param append - append array * @param strideA - stride length for `append` * @param out - output array @@ -134,9 +118,7 @@ interface Routine { * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] * * @example * var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; @@ -145,9 +127,7 @@ interface Routine { * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ declare var gediff: Routine; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts index fb1e5f5703e6..0b678d465468 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/docs/types/test.ts @@ -16,6 +16,7 @@ * limitations under the License. */ +import AccessorArray = require( '@stdlib/array/base/accessor' ); import gediff = require( './index' ); @@ -23,12 +24,13 @@ import gediff = require( './index' ); // The function returns a collection... { - const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - const p = [ 1.0 ]; - const a = [ 22.0 ]; - const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + const x = new Float64Array( 5 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 6 ); - gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectType Collection + gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectType Float64Array + gediff( x.length, new AccessorArray( x ), 1, 1, new AccessorArray( p ), 1, 1, new AccessorArray( a ), 1, new AccessorArray( out ), 1 ); // $ExpectType AccessorArray } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -229,12 +231,13 @@ import gediff = require( './index' ); // Attached to main export is an `ndarray` method which returns a collection... { - const x = [ 1.0, 2.0, 3.0, 4.0, 5.0 ]; - const p = [ 1.0 ]; - const a = [ 22.0 ]; - const out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + const x = new Float64Array( 5 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 6 ); - gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectType Collection + gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectType Float64Array + gediff.ndarray( x.length, new AccessorArray( x ), 1, 0, 1, new AccessorArray( p ), 1, 0, 1, new AccessorArray( a ), 1, 0, new AccessorArray( out ), 1, 0 ); // $ExpectType AccessorArray } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js index ebbd9a49e92a..d2c27485f140 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js @@ -25,19 +25,19 @@ var gediff = require( './../lib' ); var x = discreteUniform( 10, -100, 100, { 'dtype': 'generic' }); -console.log( 'Input array: ', x ); +console.log( 'Input array:', x ); var p = discreteUniform( 2, -100, 100, { 'dtype': 'generic' }); -console.log( 'Prepend array: ', p ); +console.log( 'Prepend array:', p ); var a = discreteUniform( 2, -100, 100, { 'dtype': 'generic' }); -console.log( 'Append array: ', a ); +console.log( 'Append array:', a ); -var out = zeros( 13 ); +var out = zeros( 13, 'generic' ); gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); -console.log( 'Output: ', out ); +console.log( 'Output:', out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js index ad0b293ca254..d44a38ad7e5c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -31,29 +31,29 @@ var gcopy = require( '@stdlib/blas/base/gcopy' ); * Calculates the differences between consecutive elements of a strided array using alternative indexing semantics and accessors. * * @private -* @param {PositiveInteger} N - number of indexed elements +* @param {NonNegativeInteger} N - number of indexed elements * @param {Object} x - input array object * @param {Collection} x.data - input array data * @param {Array} x.accessors - array element accessors * @param {integer} strideX - stride length for `x` -* @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements to `prepend` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {NonNegativeInteger} N1 - number of indexed elements to prepend * @param {Object} prepend - prepend array object * @param {Collection} prepend.data - prepend array data * @param {Array} prepend.accessors - array element accessors * @param {integer} strideP - stride length for `prepend` -* @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements to `append` +* @param {NonNegativeInteger} offsetP - starting index for `prepend` +* @param {NonNegativeInteger} N2 - number of indexed elements to append * @param {Object} append - append array object * @param {Collection} append.data - append array data * @param {Array} append.accessors - array element accessors * @param {integer} strideA - stride length for `append` -* @param {PositiveInteger} offsetA - starting index for `append` +* @param {NonNegativeInteger} offsetA - starting index for `append` * @param {Object} out - output array object * @param {Collection} out.data - output array data * @param {Array} out.accessors - array element accessors * @param {integer} strideOut - stride length for `out` -* @param {PositiveInteger} offsetOut - starting index for `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` * @returns {Object} output array object * * @example diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js index 1775456dff9c..55f3d4f33207 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/index.js @@ -32,9 +32,7 @@ * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] * * @example * var gediff = require( '@stdlib/blas/ext/base/gediff' ); @@ -45,9 +43,7 @@ * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js index 0b919834c8cb..9d642439513a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/main.js @@ -31,18 +31,18 @@ var ndarray = require( './ndarray.js' ); /** * Calculates the differences between consecutive elements of a strided array. * -* @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array +* @param {NonNegativeInteger} N - number of indexed elements +* @param {NumericArray} x - input array * @param {integer} strideX - stride length for `x` -* @param {PositiveInteger} N1 - number of indexed elements to `prepend` -* @param {Collection} prepend - prepend array +* @param {NonNegativeInteger} N1 - number of indexed elements to prepend +* @param {NumericArray} prepend - prepend array * @param {integer} strideP - stride length for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements to `append` -* @param {Collection} append - append array +* @param {NonNegativeInteger} N2 - number of indexed elements to append +* @param {NumericArray} append - append array * @param {integer} strideA - stride length for `append` -* @param {Collection} out - output array +* @param {NumericArray} out - output array * @param {integer} strideOut - stride length for `out` -* @returns {Collection} output array +* @returns {NumericArray} output array * * @example * var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; @@ -51,9 +51,7 @@ var ndarray = require( './ndarray.js' ); * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ function gediff( N, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut ) { var ox = stride2offset( N, strideX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js index d9f5afb4942c..ce7c3e4de4d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js @@ -32,22 +32,22 @@ var accessors = require( './accessors.js' ); /** * Calculates the differences between consecutive elements of a strided array using alternative indexing semantics. * -* @param {PositiveInteger} N - number of indexed elements -* @param {Collection} x - input array +* @param {NonNegativeInteger} N - number of indexed elements +* @param {NumericArray} x - input array * @param {integer} strideX - stride length for `x` -* @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements to `prepend` -* @param {Collection} prepend - prepend array +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {NonNegativeInteger} N1 - number of indexed elements to prepend +* @param {NumericArray} prepend - prepend array * @param {integer} strideP - stride length for `prepend` -* @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements to `append` -* @param {Collection} append - append array +* @param {NonNegativeInteger} offsetP - starting index for `prepend` +* @param {NonNegativeInteger} N2 - number of indexed elements to append +* @param {NumericArray} append - append array * @param {integer} strideA - stride length for `append` -* @param {PositiveInteger} offsetA - starting index for `append` -* @param {Collection} out - output array +* @param {NonNegativeInteger} offsetA - starting index for `append` +* @param {NumericArray} out - output array * @param {integer} strideOut - stride length for `out` -* @param {PositiveInteger} offsetOut - starting index for `out` -* @returns {Collection} output array +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {NumericArray} output array * * @example * var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; @@ -56,9 +56,7 @@ var accessors = require( './accessors.js' ); * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * * gediff( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); -* -* console.log( out ); -* // => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { var total; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js index af4fb8797ba7..6fe43c2b3cbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.main.js @@ -87,7 +87,7 @@ tape( 'the function calculates differences between consecutive elements of a str t.end(); }); -tape( 'if the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { +tape( 'if the sum of the `N`, `N1`, and `N2` parameters is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { var expected; var out; var x; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js index eac2ab420ca7..3ac387041bbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js @@ -80,7 +80,7 @@ tape( 'the function calculates differences between consecutive elements of a str t.end(); }); -tape( 'if the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { +tape( 'if the sum of the `N`, `N1`, and `N2` parameters is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { var expected; var out; var x; @@ -122,6 +122,27 @@ tape( 'the function supports stride parameters', function test( t ) { t.end(); }); +tape( 'the function supports stride parameters (accessors)', function test( t ) { + var expected; + var obuf; + var x; + var p; + var a; + var o; + + x = toAccessorArray( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = toAccessorArray( [ 10.0, 15.0, 25.0 ] ); + a = toAccessorArray( [ 30.0, 35.0, 45.0 ] ); + obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + o = toAccessorArray( obuf ); + + gediff( 3, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0 ); + expected = [ 10.0, 0.0, 25.0, 0.0, 8.0, 0.0, 8.0, 0.0, 30.0, 0.0, 45.0 ]; + t.deepEqual( obuf, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function supports negative stride parameters', function test( t ) { var expected; var out; From 680ad27892eda686212962f2f04b3fd035dbf649 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 21 May 2026 01:34:48 +0500 Subject: [PATCH 04/10] fix: apply suggestions from code review --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/blas/ext/base/gediff/README.md | 1 - .../@stdlib/blas/ext/base/gediff/lib/accessors.js | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md index 54aa66644fb9..4aca59bb4a8b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -148,7 +148,6 @@ console.log( out ); ## Notes -- The output array must have `N + N1 + N2 - 1` indexed elements. - If `N + N1 + N2 <= 1`, both functions return the output array unchanged. diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js index d44a38ad7e5c..7779e163bf8a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -60,13 +60,13 @@ var gcopy = require( '@stdlib/blas/base/gcopy' ); * var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); * var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); * -* var x = [ 4.0, 8.0, 12.0, 16.0, 20.0 ]; -* var p = [ 10.0, 15.0 ]; -* var a = [ 30.0, 35.0 ]; -* var o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* var x = [ 2.0, 4.0, 7.0, 11.0, 16.0 ]; +* var p = [ 1.0 ]; +* var a = [ 22.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; * -* gediff( 5, arraylike2object( toAccessorArray( x ) ), 1, 0, 2, arraylike2object( toAccessorArray( p ) ), 1, 0, 2, arraylike2object( toAccessorArray( a ) ), 1, 0, arraylike2object( toAccessorArray( o ) ), 1, 0 ); -* // o => [ 10.0, 15.0, 4.0, 4.0, 4.0, 4.0, 30.0, 35.0 ] +* gediff( x.length, arraylike2object( toAccessorArray( x ) ), 1, 0, 1, arraylike2object( toAccessorArray( p ) ), 1, 0, 1, arraylike2object( toAccessorArray( a ) ), 1, 0, arraylike2object( toAccessorArray( out ) ), 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 5.0, 22.0 ] */ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { var xbuf; From a152a967252b4e69d2878f7f486c802dd3808a4c Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:44:20 -0700 Subject: [PATCH 05/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gediff/lib/accessors.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js index 7779e163bf8a..08960e50af83 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -22,7 +22,7 @@ // MODULES // -var gcopy = require( '@stdlib/blas/base/gcopy' ); +var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; // MAIN // @@ -85,7 +85,7 @@ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, appe oset = out.accessors[ 1 ]; // Copy `prepend` into output array: - gcopy.ndarray( N1, prepend.data, strideP, offsetP, obuf, strideOut, offsetOut ); + gcopy( N1, prepend.data, strideP, offsetP, obuf, strideOut, offsetOut ); // Compute differences of input array: ix = offsetX; @@ -100,7 +100,7 @@ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, appe } // Copy `append` into output array: - gcopy.ndarray( N2, append.data, strideA, offsetA, obuf, strideOut, io ); + gcopy( N2, append.data, strideA, offsetA, obuf, strideOut, io ); return out; } From a25c13b7a25a4a9ed5ee65eca4ee6bb10853f7a1 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:44:49 -0700 Subject: [PATCH 06/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js index 08960e50af83..1ae33899a5a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/accessors.js @@ -28,7 +28,7 @@ var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; // MAIN // /** -* Calculates the differences between consecutive elements of a strided array using alternative indexing semantics and accessors. +* Calculates the differences between consecutive elements of a strided accessor array using alternative indexing semantics. * * @private * @param {NonNegativeInteger} N - number of indexed elements From 6c1f1e51e382ebfc812aa6bd4b204d031aa38c95 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:47:20 -0700 Subject: [PATCH 07/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gediff/lib/ndarray.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js index ce7c3e4de4d8..569ac2b78a79 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/lib/ndarray.js @@ -23,7 +23,7 @@ // MODULES // var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); -var gcopy = require( '@stdlib/blas/base/gcopy' ); +var gcopy = require( '@stdlib/blas/base/gcopy' ).ndarray; var accessors = require( './accessors.js' ); @@ -85,7 +85,7 @@ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, appe } // Copy `prepend` into output array: - gcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + gcopy( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); // Compute differences of input array: ix = offsetX; @@ -100,7 +100,7 @@ function gediff( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, appe } // Copy `append` into output array: - gcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + gcopy( N2, append, strideA, offsetA, out, strideOut, io ); return out; } From 60b1ad824b4571191d564d632e41cb3fd6a13a12 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:53:25 -0700 Subject: [PATCH 08/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gediff/test/test.ndarray.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js index 3ac387041bbf..d44b724ec26a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/test/test.ndarray.js @@ -193,13 +193,13 @@ tape( 'the function supports offset parameters', function test( t ) { var a; var o; - x = [ 0.0, 4.0, 8.0, 12.0, 16.0, 20.0 ]; + x = [ 0.0, 4.0, 7.0, 12.0, 16.0, 20.0 ]; p = [ 10.0 ]; a = [ 30.0 ]; o = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; out = gediff( 3, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); - expected = [ 10.0, 4.0, 4.0, 30.0, 0.0, 0.0 ]; + expected = [ 10.0, 5.0, 4.0, 30.0, 0.0, 0.0 ]; t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'returns expected value' ); @@ -214,14 +214,14 @@ tape( 'the function supports offset parameters (accessors)', function test( t ) var a; var o; - x = toAccessorArray( [ 0.0, 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + x = toAccessorArray( [ 0.0, 4.0, 7.0, 12.0, 16.0, 20.0 ] ); p = toAccessorArray( [ 10.0 ] ); a = toAccessorArray( [ 30.0 ] ); obuf = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; o = toAccessorArray( obuf ); gediff( 3, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, o, 1, 0 ); - expected = [ 10.0, 4.0, 4.0, 30.0, 0.0, 0.0 ]; + expected = [ 10.0, 5.0, 4.0, 30.0, 0.0, 0.0 ]; t.deepEqual( obuf, expected, 'returns expected value' ); t.end(); From df2ce1c5fd6569ee6670b5934b6dc928c4fc9ff4 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:56:24 -0700 Subject: [PATCH 09/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/gediff/README.md | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md index 4aca59bb4a8b..0686762d990d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -45,9 +45,7 @@ var a = [ 11.0 ]; var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; gediff( x.length, x, 1, 1, p, 1, 1, a, 1, out, 1 ); - -console.log( out ); -// => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] +// out => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] ``` The function has the following parameters: @@ -73,9 +71,7 @@ var a = [ 11.0 ]; var out = [ 0.0, 0.0, 0.0, 0.0 ]; gediff( 3, x, 2, 1, p, 1, 1, a, 1, out, 1 ); - -console.log( out ); -// => [ 1.0, 4.0, 4.0, 11.0 ] +// out => [ 1.0, 4.0, 4.0, 11.0 ] ``` Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. @@ -94,9 +90,7 @@ var a = [ 11.0 ]; var out = [ 0.0, 0.0, 0.0, 0.0, 0.0 ]; gediff( x1.length, x1, 1, 1, p, 1, 1, a, 1, out, 1 ); - -console.log( out ); -// => [ 1.0, 2.0, 2.0, 2.0, 11.0 ] +// out => [ 1.0, 2.0, 2.0, 2.0, 11.0 ] ``` @@ -114,9 +108,7 @@ var a = [ 11.0 ]; var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; gediff.ndarray( x.length, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); - -console.log( out ); -// => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] +// out => [ 1.0, 2.0, 2.0, 2.0, 2.0, 11.0 ] ``` The function has the following additional parameters: @@ -126,7 +118,7 @@ The function has the following additional parameters: - **offsetA**: starting index for `append`. - **offsetOut**: starting index for `out`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to access only the last three elements: +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements: ```javascript var x = [ 2.0, 4.0, 6.0, 8.0, 10.0 ]; @@ -135,9 +127,7 @@ var a = [ 11.0 ]; var out = [ 0.0, 0.0, 0.0, 0.0 ]; gediff.ndarray( 3, x, 1, x.length-3, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); - -console.log( out ); -// => [ 1.0, 2.0, 2.0, 11.0 ] +// out => [ 1.0, 2.0, 2.0, 11.0 ] ``` From 539fcfd1e0faf2a033d5074cf77d10ff353d9791 Mon Sep 17 00:00:00 2001 From: Athan Date: Wed, 20 May 2026 17:58:37 -0700 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/gediff/README.md | 2 +- lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md index 0686762d990d..e34339c4fd42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/README.md @@ -172,7 +172,7 @@ console.log( 'Append array:', a ); var out = zeros( 13, 'generic' ); -gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); +gediff( x.length, x, 1, p.length, p, 1, a.length, a, 1, out, 1 ); console.log( 'Output:', out ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js index d2c27485f140..fc4c1b33078e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gediff/examples/index.js @@ -39,5 +39,5 @@ console.log( 'Append array:', a ); var out = zeros( 13, 'generic' ); -gediff( x.length, x, 1, 2, p, 1, 2, a, 1, out, 1 ); +gediff( x.length, x, 1, p.length, p, 1, a.length, a, 1, out, 1 ); console.log( 'Output:', out );