From 8f383747be91839f8fbde8954808fd2c2ee48441 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 20 Feb 2026 01:16:17 +0500 Subject: [PATCH 01/35] feat: add blas/ext/base/ddiff --- .../@stdlib/blas/ext/base/ddiff/README.md | 391 ++++++++++ .../ext/base/ddiff/benchmark/benchmark.js | 124 ++++ .../base/ddiff/benchmark/benchmark.native.js | 129 ++++ .../base/ddiff/benchmark/benchmark.ndarray.js | 124 ++++ .../benchmark/benchmark.ndarray.native.js | 129 ++++ .../blas/ext/base/ddiff/benchmark/c/Makefile | 146 ++++ .../base/ddiff/benchmark/c/benchmark.length.c | 273 +++++++ .../@stdlib/blas/ext/base/ddiff/binding.gyp | 170 +++++ .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 188 +++++ .../blas/ext/base/ddiff/docs/types/index.d.ts | 153 ++++ .../blas/ext/base/ddiff/docs/types/test.ts | 685 ++++++++++++++++++ .../blas/ext/base/ddiff/examples/c/Makefile | 146 ++++ .../blas/ext/base/ddiff/examples/c/example.c | 45 ++ .../blas/ext/base/ddiff/examples/index.js | 45 ++ .../@stdlib/blas/ext/base/ddiff/include.gypi | 53 ++ .../include/stdlib/blas/ext/base/ddiff.h | 46 ++ .../@stdlib/blas/ext/base/ddiff/lib/ddiff.js | 77 ++ .../blas/ext/base/ddiff/lib/ddiff.native.js | 71 ++ .../@stdlib/blas/ext/base/ddiff/lib/index.js | 65 ++ .../@stdlib/blas/ext/base/ddiff/lib/main.js | 35 + .../@stdlib/blas/ext/base/ddiff/lib/native.js | 35 + .../blas/ext/base/ddiff/lib/ndarray.js | 252 +++++++ .../blas/ext/base/ddiff/lib/ndarray.native.js | 76 ++ .../@stdlib/blas/ext/base/ddiff/manifest.json | 78 ++ .../@stdlib/blas/ext/base/ddiff/package.json | 74 ++ .../@stdlib/blas/ext/base/ddiff/src/Makefile | 70 ++ .../@stdlib/blas/ext/base/ddiff/src/addon.c | 86 +++ .../@stdlib/blas/ext/base/ddiff/src/main.c | 247 +++++++ .../blas/ext/base/ddiff/test/test.ddiff.js | 218 ++++++ .../ext/base/ddiff/test/test.ddiff.native.js | 227 ++++++ .../@stdlib/blas/ext/base/ddiff/test/test.js | 82 +++ .../blas/ext/base/ddiff/test/test.ndarray.js | 248 +++++++ .../base/ddiff/test/test.ndarray.native.js | 257 +++++++ 33 files changed, 5045 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/include.gypi create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md new file mode 100644 index 000000000000..5678bdae5954 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -0,0 +1,391 @@ + + +# ddiff + +> Calculate the k-th discrete forward difference of a double-precision floating-point strided array. + +
+ +## Usage + +```javascript +var ddiff = require( '@stdlib/blas/ext/base/ddiff' ); +``` + + + +#### ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) + +Calculates the k-th discrete forward differences of a double-precision floating-point strided array. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); +var p = new Float64Array( [ 1.0 ] ); +var a = new Float64Array( [ 11.0 ] ); +var out = new Float64Array( 6 ); +var w = new Float64Array( 6 ); + +ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + +console.log( out ); +// out => [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **k**: number of times to recursively compute differences. +- **x**: input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: stride length for `x`. +- **N1**: number of elements to `prepend`. +- **prepend**: a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. +- **strideP**: stride length for `prepend`. +- **N2**: number of elements to `append`. +- **append**: a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. +- **strideA**: strides length for `append`. +- **out**: output [`Float64Array`][@stdlib/array/float64]. +- **strideOut**: stride length for `out`. +- **workspace**: workspace [`Float64Array`][@stdlib/array/float64]. +- **strideW**: stride length for `workspace`. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to differences of every other element: + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); +var p = new Float64Array( [ 1.0 ] ) +var a = new Float64Array( [ 11.0 ] ); +var out = new Float64Array( 4 ); +var w = new Float64Array( 4 ); + +ddiff( 3, 1, x, 2, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + +console.log( out ); +// out => [ 1.0, 4.0, 4.0, 1.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 = new Float64Array( [ 1.0 ] ) +var a = new Float64Array( [ 11.0 ] ); +var out = new Float64Array( 5 ); +var w = new Float64Array( 5 ); + +ddiff( x1.length, 1, x1, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + +console.log( out ); +// out => [ 3.0, 2.0, 2.0, 2.0, 11.0 ] +``` + + + +#### ddiff.ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) + +Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); +var p = new Float64Array( [ 1.0 ] ); +var a = new Float64Array( [ 11.0 ] ); +var out = new Float64Array( 6 ); +var w = new Float64Array( 6 ); + +ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + +console.log( out ); +// out => [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.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`. +- **offsetW**: starting index of `workspace`. + +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 Float64Array = require( '@stdlib/array/float64' ); + +var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); +var p = new Float64Array( [ 1.0 ] ) +var a = new Float64Array( [ 11.0 ] ); +var out = new Float64Array( 4 ); +var w = new Float64Array( 4 ); + +ddiff( 3, 1, x, 1, x.length-3, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + +console.log( out ); +// out => [ 5.0, 2.0, 2.0, 1.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `x` unchanged. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ddiff = require( '@stdlib/blas/ext/base/ddiff' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Input array: ', x ); + +var p = discreteUniform( 2, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Prepend array: ', p ); + +var a = discreteUniform( 2, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Append array: ', a ); + +var out = new Float64Array( 10 ); + +var w = new Float64Array( 13 ); + +ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, out, 1, w, 1 ); +console.log( 'Output', out ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/ext/base/ddiff.h" +``` + + + +#### stdlib_strided_ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, \*out, strideOut, workspace, strideW ) + +Calculates the k-th discrete forward differences of a double-precision floating-point strided array. + +```c +double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; +double p[] = { 1.0 }; +double a[] = { 11.0 }; +double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; +double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + +stdlib_strided_ddiff( 5, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **k**: `[in] CBLAS_INT` number of times to recursively compute differences. +- **x**: `[in] double` input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: `[in] CBLAS_INT` stride length for `x`. +- **N1**: `[in] CBLAS_INT` number of elements in `prepend`. +- **prepend**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. +- **N2**: `[in] CBLAS_INT` number of elements in `append`. +- **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. +- **strideA**: `[in] CBLAS_INT` strides length for `append`. +- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. +- **strideOut**: `[in] CBLAS_INT` stride length for `out`. +- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. +- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. + +```c +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, const double workspace, const CBLAS_INT strideW ); +``` + + + +#### stdlib_strided_ddiff_ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, \*out, strideOut, offsetOut, w, strideW, offsetW ) + +Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. + +```c +double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; +double p[] = { 1.0 }; +double a[] = { 11.0 }; +double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; +double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + +stdlib_strided_ddiff_ndarray( 5, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **k**: `[in] CBLAS_INT` number of times to recursively compute differences. +- **x**: `[in] double` input [`Float64Array`][@stdlib/array/float64]. +- **strideX**: `[in] CBLAS_INT` stride length for `x`. +- **offsetX**: `[in] CBLAS_INT` starting index for `x`. +- **N1**: `[in] CBLAS_INT` number of elements in `prepend`. +- **prepend**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. +- **offsetP**: `[in] CBLAS_INT` starting index for `prepend`. +- **N2**: `[in] CBLAS_INT` number of elements in `append`. +- **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. +- **strideA**: `[in] CBLAS_INT` strides length for `append`. +- **offsetA**: `[in] CBLAS_INT` starting index for `append`. +- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. +- **strideOut**: `[in] CBLAS_INT` stride length for `out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `out`. +- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. +- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. +- **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. + +```c +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/blas/ext/base/ddiff.h" +#include + +int main( void ) { + // Create a strided array: + double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + + // Define prepend values: + double p[] = { -1.0 }; + + // Define append values: + double a[] = { 10.0 }; + + // Define output array: + double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Define workspace: + double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Fill the array: + stdlib_strided_ddiff( 8, 3, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + // Print the result: + for ( int i = 0; i < 7; i++ ) { + printf( "out[ %i ] = %lf\n", i, out[ i ] ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js new file mode 100644 index 000000000000..410abdcfc8c9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js @@ -0,0 +1,124 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ddiff = require( './../lib/ddiff.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 w; + var o; + var k; + var N; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + w = new Float64Array( N+N1+N2-1 ); + o = new Float64Array( ol ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + ddiff( N, k, x, 1, N1, p, 1, N2, a, 1, o, 1, w, 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/ddiff/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2af38abe472a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js @@ -0,0 +1,129 @@ +/** +* @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 resolve = require( 'path' ).resolve; +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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; +var ddiff = tryRequire( resolve( __dirname, './../lib/ddiff.native.js' ) ); +var opts = { + 'skip': ( ddiff instanceof Error ) +}; + + +// 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 w; + var o; + var k; + var N; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + w = new Float64Array( N+N1+N2-1 ); + o = new Float64Array( ol ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + ddiff( N, k, x, 1, N1, p, 1, N2, a, 1, o, 1, w, 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::native:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..6da61d94c29e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js @@ -0,0 +1,124 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ddiff = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 w; + var o; + var k; + var N; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + w = new Float64Array( N+N1+N2-1 ); + o = new Float64Array( ol ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + ddiff( N, k, x, 1, 0, N1, p, 1, 0, N2, a, 1, 0, o, 1, 0, w, 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/ddiff/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js new file mode 100644 index 000000000000..3ef25a13da0b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js @@ -0,0 +1,129 @@ +/** +* @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 resolve = require( 'path' ).resolve; +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 Float64Array = require( '@stdlib/array/float64' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; +var ddiff = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ddiff instanceof Error ) +}; + + +// 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 w; + var o; + var k; + var N; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + + x = uniform( N, -100, 100, options ); + p = uniform( N1, -100, 100, options ); + a = uniform( N2, -100, 100, options ); + w = new Float64Array( N+N1+N2-1 ); + o = new Float64Array( ol ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + ddiff( N, k, x, 1, 0, N1, p, 1, 0, N2, a, 1, 0, o, 1, 0, w, 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::native:ndarray:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile new file mode 100644 index 000000000000..7280962b4c4d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.length.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..d44fbc873fa0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c @@ -0,0 +1,273 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/ddiff.h" +#include +#include +#include +#include +#include + +#define NAME "ddiff" +#define ITERATIONS 1000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, double elapsed ) { + double rate = (double)iterations / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", iterations ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static double rand_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark1( int iterations, int len ) { + double elapsed; + double *x; + double *p; + double *a; + double *o; + double *w; + double t; + int wl; + int ol; + int N1; + int N2; + int k; + int N; + int i; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + wl = N + N1 + N2 - 1; + + x = (double *) malloc( N * sizeof( double ) ); + for ( i = 0; i < N; i++ ) { + x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + + p = (double *) malloc( N1 * sizeof( double ) ); + a = (double *) malloc( N2 * sizeof( double ) ); + for ( i = 0; i < N1; i++ ) { + p[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + a[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + + w = (double *) malloc( wl * sizeof( double ) ); + for ( i = 0; i < wl; i++ ) { + w[ i ] = 0.0; + } + + o = (double *) malloc( ol * sizeof( double ) ); + for ( i = 0; i < ol; i++ ) { + o[ i ] = 0.0; + } + + t = tic(); + for ( i = 0; i < iterations; i++ ) { + stdlib_strided_ddiff( N, k, x, 1, N1, p, 1, N2, a, 1, o, 1, w, 1 ); + if ( o[ 0 ] != o[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( o[ ol-1 ] != o[ ol-1 ] ) { + printf( "should not return NaN\n" ); + } + free( x ); + free( p ); + free( a ); + free( w ); + free( o ); + return elapsed; +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + double *x; + double *p; + double *a; + double *o; + double *w; + double t; + int wl; + int ol; + int N1; + int N2; + int k; + int N; + int i; + + N = len; + N1 = 1; + N2 = 1; + k = 1; // worst case: N + N1 + N2 - 1 + ol = N + N1 + N2 - k; + wl = N + N1 + N2 - 1; + + x = (double *) malloc( N * sizeof( double ) ); + for ( i = 0; i < N; i++ ) { + x[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + + p = (double *) malloc( N1 * sizeof( double ) ); + a = (double *) malloc( N2 * sizeof( double ) ); + for ( i = 0; i < N1; i++ ) { + p[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + a[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + + w = (double *) malloc( wl * sizeof( double ) ); + for ( i = 0; i < wl; i++ ) { + w[ i ] = 0.0; + } + + o = (double *) malloc( ol * sizeof( double ) ); + for ( i = 0; i < ol; i++ ) { + o[ i ] = 0.0; + } + + t = tic(); + for ( i = 0; i < iterations; i++ ) { + stdlib_strided_ddiff_ndarray( N, k, x, 1, 0, N1, p, 1, 0, N2, a, 1, 0, o, 1, 0, w, 1, 0 ); + if ( o[ 0 ] != o[ 0 ] ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( o[ ol-1 ] != o[ ol-1 ] ) { + printf( "should not return NaN\n" ); + } + free( x ); + free( p ); + free( a ); + free( w ); + free( o ); + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:len=%d\n", NAME, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt new file mode 100644 index 000000000000..497f420a25cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -0,0 +1,188 @@ + +{{alias}}( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) + Calculates the k-th discrete forward differences of a double-precision + floating-point 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 `N <= 0`, the function returns `x` unchanged. + + Parameters + ---------- + N: integer + Number of indexed elements. + + k: integer + Number of times to recursively compute differences. + + x: Float64Array + Input array. + + strideX: integer + Stride length for `x`. + + N1: integer + Number of elements to `prepend`. + + prepend: Float64Array + Array containing values to prepend prior to computing differences. + + strideP: integer + Stride length for `prepend`. + + N2: integer + Number of elements to `append`. + + append: Float64Array + Array containing values to append prior to computing differences. + + strideA: integer + Stride length for `append`. + + out: Float64Array + Output array. + + strideOut: integer + Stride length for `Out`. + + workspace: Float64Array + Workspace array. + + strideW: integer + Stride length for `workspace`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); + > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 4 ); + > var w = new {{alias:@stdlib/array/float64}}( 4 ); + > {{alias}}( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ) + [ 1.0, -3.0, 4.0, 1.0 ] + + // Using `N` and stride parameters: + > x = new {{alias:@stdlib/array/float64}}( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + > p = new {{alias:@stdlib/array/float64}}( [ 1.0 ] ); + > a = new {{alias:@stdlib/array/float64}}( [ 11.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 4 ); + > var w = new {{alias:@stdlib/array/float64}}( 4 ); + > {{alias}}( 3, 1, x, 2, 1, p, 1, 1, a, 1, out, 1, w, 1 ) + [ 1.0, 4.0, 4.0, 1.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 = new {{alias:@stdlib/array/float64}}( [ 1.0 ] ); + > a = new {{alias:@stdlib/array/float64}}( [ 11.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 5 ); + > var w = new {{alias:@stdlib/array/float64}}( 5 ); + > {{alias}}( x1.length, 1, x1, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ) + [ 3.0, 2.0, 2.0, 2.0, 1.0 ] + + +{{alias}}.ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) + Calculates the k-th discrete forward differences of a double-precision + floating-point strided array using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of indexed elements. + + k: integer + Number of times to recursively compute differences. + + x: Float64Array + Input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + N1: integer + Number of elements to `prepend`. + + prepend: Float64Array + Array containing values to prepend prior to computing differences. + + strideP: integer + Stride length for `prepend`. + + offsetP: integer + Starting index for `prepend`. + + N2: integer + Number of elements to `append`. + + append: Float64Array + Array containing values to append prior to computing differences. + + strideA: integer + Stride length for `append`. + + offsetA: integer + Starting index for `append`. + + out: Float64Array + Output array. + + strideOut: integer + Stride length for `Out`. + + offsetOut: integer + Stride length for `Out`. + + workspace: Float64Array + Workspace array. + + strideW: integer + Stride length for `workspace`. + + offsetW: integer + Starting index for `workspace`. + + Returns + ------- + out: Float64Array + Output array. + + Examples + -------- + // Standard Usage: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); + > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 4 ); + > var w = new {{alias:@stdlib/array/float64}}( 4 ); + > {{alias}}.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ) + [ 1.0, -3.0, 4.0, 1.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); + > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); + > var out = new {{alias:@stdlib/array/float64}}( 3 ); + > var w = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}.ndarray( 2, 1, x, 1, x.length-2, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ) + [ -2.0, 4.0, 1.0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts new file mode 100644 index 000000000000..d69d36a691b2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts @@ -0,0 +1,153 @@ +/* +* @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 + +/** +* Interface describing `ddiff`. +*/ +interface Routine { + /** + * Calculates the k-th discrete forward difference of a double-precision floating-point strided array. + * + * @param N - number of indexed elements + * @param k - number of times to recursively compute differences + * @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` + * @param workspace - workspace array + * @param strideW - stride length for `workspace` + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + * var p = new Float64Array( [ 1.0 ] ); + * var a = new Float64Array( [ 22.0 ] ); + * var out = new Float64Array( 5 ); + * var w = new Float64Array( 6 ) + * + * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + * + * console.log( out ); + * // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + ( N: number, k: number, x: Float64Array, strideX: number, N1: number, prepend: Float64Array, strideP: number, N2: number, append: Float64Array, strideA: number, out: Float64Array, strideOut: number, workspace: Float64Array, strideW: number ): Float64Array; + + /** + * Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param k - number of times to recursively compute differences + * @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` + * @param workspace - workspace array + * @param strideW - stride length for `workspace` + * @param offsetW - starting index for `workspace` + * @returns output array + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + * var p = new Float64Array( [ 1.0 ] ); + * var a = new Float64Array( [ 22.0 ] ); + * var out = new Float64Array( 5 ); + * var w = new Float64Array( 6 ) + * + * ddiff.ndarray( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + * + * console.log( out ); + * // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] + */ + ndarray ( N: number, k: number, x: Float64Array, strideX: number, offsetX: number, N1: number, prepend: Float64Array, strideP: number, offsetP: number, N2: number, append: Float64Array, strideA: number, offsetA: number, out: Float64Array, strideOut: number, offsetOut: number, workspace: Float64Array, strideW: number, offsetW: number ): Float64Array; +} + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* +* @param N - number of indexed elements +* @param k - number of times to recursively compute differences +* @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` +* @param workspace - workspace array +* @param strideW - stride length for `workspace` +* @returns output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff.ndarray( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +declare var ddiff: Routine; + + +// EXPORTS // + +export = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts new file mode 100644 index 000000000000..a5188f29ccf8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts @@ -0,0 +1,685 @@ +/* +* @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 ddiff = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( '10', 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( true, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( false, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( null, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( undefined, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( [], 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( {}, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( ( x: number ): number => x, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, '10', x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, true, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, false, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, null, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, undefined, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, [], x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, {}, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, ( x: number ): number => x, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, '10', 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, true, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, false, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, null, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, undefined, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, [], 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, {}, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, ( x: number ): number => x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, '10', 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, true, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, false, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, null, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, undefined, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, [], 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, {}, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, ( x: number ): number => x, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, '10', p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, true, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, false, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, null, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, undefined, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, [], p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, {}, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, ( x: number ): number => x, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, '10', 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, true, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, false, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, null, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, undefined, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, [], 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, {}, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, ( x: number ): number => x, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, '10', 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, true, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, false, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, null, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, undefined, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, [], 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, {}, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, ( x: number ): number => x, 1, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eigth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, '10', a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, true, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, false, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, null, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, undefined, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, [], a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, {}, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, ( x: number ): number => x, a, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, '10', 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, true, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, false, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, null, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, undefined, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, [], 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, {}, 1, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, ( x: number ): number => x, 1, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, '10', out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, true, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, false, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, null, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, undefined, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, [], out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, {}, out, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, ( x: number ): number => x, out, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const w = new Float64Array( 9 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, '10', 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, true, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, false, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, null, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, undefined, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, [], 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, {}, 1, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, ( x: number ): number => x, 1, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelveth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, '10', w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, true, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, false, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, null, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, undefined, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, [], w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, {}, w, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, ( x: number ): number => x, w, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 9 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, '10', 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, true, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, false, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, null, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, undefined, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, [], 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, {}, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, '10' ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, true ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, false ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, null ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, undefined ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, [] ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, {} ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff(); // $ExpectError + ddiff( x.length ); // $ExpectError + ddiff( x.length, 1 ); // $ExpectError + ddiff( x.length, 1, x ); // $ExpectError + ddiff( x.length, 1, x, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1 ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w ); // $ExpectError + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1, {} ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( '10', 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( true, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( false, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( null, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( undefined, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( [], 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( {}, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( ( x: number ): number => x, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, '10', x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, true, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, false, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, null, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, undefined, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, [], x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, {}, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, ( x: number ): number => x, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, '10', 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, true, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, false, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, null, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, undefined, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, [], 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, {}, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, ( x: number ): number => x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, '10', 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, true, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, false, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, null, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, undefined, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, [], 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, {}, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, ( x: number ): number => x, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, '10', 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, true, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, false, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, null, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, undefined, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, [], 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, {}, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, ( x: number ): number => x, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, '10', p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, true, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, false, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 1, null, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, undefined, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, [], p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, {}, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, ( x: number ): number => x, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, '10', 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, true, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, false, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, null, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, undefined, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, [], 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, {}, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, ( x: number ): number => x, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eigth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, '10', 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, true, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, false, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, null, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, undefined, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, [], 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, {}, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, ( x: number ): number => x, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, '10', 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, true, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, false, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, null, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, undefined, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, [], 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, {}, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, ( x: number ): number => x, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, '10', a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, true, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, false, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, null, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, undefined, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, [], a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, {}, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, ( x: number ): number => x, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 9 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, '10', 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, true, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, false, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, null, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, undefined, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, [], 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, {}, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, ( x: number ): number => x, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelveth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, '10', 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, true, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, false, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, null, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, undefined, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, [], 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, {}, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, ( x: number ): number => x, 0, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 9 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, '10', out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, true, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, false, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, null, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, undefined, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, [], out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, {}, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, ( x: number ): number => x, out, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, '10', 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, true, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, false, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, null, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, undefined, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, [], 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, {}, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, ( x: number ): number => x, 1, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, '10', 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, true, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, false, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, null, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, undefined, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, [], 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, {}, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, ( x: number ): number => x, 0, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, '10', w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, true, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, false, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, null, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, undefined, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, [], w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, {}, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, ( x: number ): number => x, w, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventeenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, '10', 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, true, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, false, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, null, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, undefined, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, [], 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, {}, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a eighteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, '10', 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, true, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, false, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, null, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, undefined, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, [], 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, {}, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a nineteenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, '10' ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, true ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, false ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, null ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, undefined ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, [] ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, {} ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const p = new Float64Array( 1 ); + const a = new Float64Array( 1 ); + const out = new Float64Array( 11 ); + const w = new Float64Array( 11 ); + + ddiff.ndarray(); // $ExpectError + ddiff.ndarray( x.length ); // $ExpectError + ddiff.ndarray( x.length, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0, {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile new file mode 100644 index 000000000000..ff5293d3059f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c new file mode 100644 index 000000000000..e3e5c561834a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c @@ -0,0 +1,45 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/ddiff.h" +#include + +int main( void ) { + // Create a strided array: + double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + + // Define prepend values: + double p[] = { -1.0 }; + + // Define append values: + double a[] = { 10.0 }; + + // Define output array: + double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Define workspace: + double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; + + // Fill the array: + stdlib_strided_ddiff( 8, 3, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + // Print the result: + for ( int i = 0; i < 7; i++ ) { + printf( "out[ %i ] = %lf\n", i, out[ i ] ); + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js new file mode 100644 index 000000000000..fe1c0280d3b0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js @@ -0,0 +1,45 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ddiff = require( './../lib' ); + +var x = discreteUniform( 10, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Input array: ', x ); + +var p = discreteUniform( 2, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Prepend array: ', p ); + +var a = discreteUniform( 2, -100, 100, { + 'dtype': 'float64' +}); +console.log( 'Append array: ', a ); + +var out = new Float64Array( 10 ); + +var w = new Float64Array( 13 ); + +ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, out, 1, w, 1 ); +console.log( 'Output', out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include.gypi b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include.gypi @@ -0,0 +1,53 @@ +# @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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' [ 1, 1, 1, 1, 1 ] +*/ +function ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) { + var ox = stride2offset( N, strideX ); + var op = stride2offset( N1, strideP ); + var oa = stride2offset( N2, strideA ); + var oo = stride2offset( N + N1 + N2 - k, strideOut ); + var ow = stride2offset( N + N1 + N2 - 1, strideW ); + ndarray( N, k, x, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo, workspace, strideW, ow ); + return out; +} + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js new file mode 100644 index 000000000000..2001856b8e47 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js @@ -0,0 +1,71 @@ +/** +* @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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - number of times to recursively compute differences +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Float64Array} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Float64Array} append - append array +* @param {integer} strideA - stride length for `append` +* @param {Float64Array} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {Float64Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +function ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) { + addon( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ); + return out; +} + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js new file mode 100644 index 000000000000..f059ed607ee6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js @@ -0,0 +1,65 @@ +/** +* @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 k-th discrete forward difference of a double-precision floating-point strided array. +* +* @module @stdlib/blas/ext/base/ddiff +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var ddiff = require( '@stdlib/blas/ext/base/ddiff' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var ddiff; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ddiff = main; +} else { + ddiff = tmp; +} + + +// EXPORTS // + +module.exports = ddiff; + +// exports: { "ndarray": "ddiff.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/main.js new file mode 100644 index 000000000000..029900015701 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/main.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var ddiff = require( './ddiff.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ddiff, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/native.js new file mode 100644 index 000000000000..d347f3666b64 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/native.js @@ -0,0 +1,35 @@ +/** +* @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 setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var ddiff = require( './ddiff.native.js' ); +var ndarray = require( './ndarray.native.js' ); + + +// MAIN // + +setReadOnly( ddiff, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js new file mode 100644 index 000000000000..2fadef74919f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -0,0 +1,252 @@ +/** +* @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'; + +// FUNCTIONS // + +/** +* Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Float64Array} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Float64Array} append - append array +* @param {integer} strideA - stride length for `append` +* @param {PositiveInteger} offsetA - starting index for `append` +* @param {Float64Array} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` +* @returns {Float64Array} output array +*/ +function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { + var total; + var prev; + var curr; + var ix; + var io; + var ip; + var ia; + var i; + + total = N + N1 + N2; + if ( total <= 1 ) { + return out; + } + + if ( N1 === 0 && N2 === 0 ) { + ix = offsetX + ( ( N - 1 ) * strideX ); + io = offsetOut + ( ( N - 2 ) * strideOut ); + prev = x[ ix ]; + for ( i = N-2; i >= 0; i-- ) { + ix -= strideX; + curr = x[ ix ]; + out[ io ] = prev - curr; + prev = curr; + io -= strideOut; + } + return out; + } + + // Prepend + if ( N1 > 0 ) { + io = offsetOut; + ip = offsetP; + prev = prepend[ ip ]; + for ( i = 1; i < N1; i++ ) { + ip += strideP; + curr = prepend[ ip ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + if ( N > 0 ) { + curr = x[ offsetX ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } else if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } else if ( N > 0 ) { + prev = x[ offsetX ]; + } else { + prev = append[ offsetA ]; + } + + // x + if ( N > 0 ) { + ix = offsetX; + if ( N1 === 0 ) { + prev = x[ ix ]; + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } else { + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } + if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } + + // Append + if ( N2 > 0 ) { + ia = offsetA + strideA; + for ( i = 1; i < N2; i++ ) { + curr = append[ ia ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ia += strideA; + } + } + return out; +} + + +// MAIN // + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - number of times to recursively compute differences +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Float64Array} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Float64Array} append - append array +* @param {integer} strideA - stride length for `append` +* @param {PositiveInteger} offsetA - starting index for `append` +* @param {Float64Array} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` +* @param {Float64Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` +* @param {PositiveInteger} offsetW - starting index for `workspace` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) { + var total; + var ix; + var ip; + var ia; + var io; + var n; + var i; + + total = N + N1 + N2; + if ( total <= 1 ) { + return out; + } + + if ( k >= total ) { + return out; + } + + if ( k === 0 ) { + io = offsetOut; + ip = offsetP; + for ( i = 0; i < N1; i++ ) { + out[ io ] = prepend[ ip ]; + io += strideOut; + ip += strideP; + } + + ix = offsetX; + for ( i = 0; i < N; i++ ) { + out[ io ] = x[ ix ]; + io += strideOut; + ix += strideX; + } + + ia = offsetA; + for ( i = 0; i < N2; i++ ) { + out[ io ] = append[ ia ]; + io += strideOut; + ia += strideA; + } + } + + if ( k === 1 ) { + base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); + return out; + } + + base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + + n = total - 1; + for ( i = 1; i < k - 1; i++ ) { + base( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); + n -= 1; + } + + base( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); + return out; +} + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js new file mode 100644 index 000000000000..130555f1c442 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js @@ -0,0 +1,76 @@ +/** +* @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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {PositiveInteger} k - number of times to recursively compute differences +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Float64Array} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Float64Array} append - append array +* @param {integer} strideA - stride length for `append` +* @param {PositiveInteger} offsetA - starting index for `append` +* @param {Float64Array} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` +* @param {Float64Array} workspace - workspace array +* @param {integer} strideW - stride length for `workspace` +* @param {PositiveInteger} offsetW - starting index for `workspace` +* @returns {Float64Array} output array +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); +* var p = new Float64Array( [ 1.0 ] ); +* var a = new Float64Array( [ 22.0 ] ); +* var out = new Float64Array( 5 ); +* var w = new Float64Array( 6 ) +* +* ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +* +* console.log( out ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] +*/ +function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) { + addon.ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ); + return out; +} + + +// EXPORTS // + +module.exports = ddiff; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json new file mode 100644 index 000000000000..fb41f9fb7ad5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float64array" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/package.json b/lib/node_modules/@stdlib/blas/ext/base/ddiff/package.json new file mode 100644 index 000000000000..b0130193b6dd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/package.json @@ -0,0 +1,74 @@ +{ + "name": "@stdlib/blas/ext/base/ddiff", + "version": "0.0.0", + "description": "Calculate the k-th discrete forward difference of a double-precision floating-point strided array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "diff", + "difference", + "gradient", + "strided", + "array", + "float64", + "double", + "float64array" + ], + "__stdlib__": { + "wasm": false + } +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile new file mode 100644 index 000000000000..dd720a3de8f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2020 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c new file mode 100644 index 000000000000..f64803338ba4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c @@ -0,0 +1,86 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/ddiff.h" +#include "stdlib/blas/base/shared.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float64array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 14 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, k, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, N1, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, strideP, argv, 6 ); + STDLIB_NAPI_ARGV_INT64( env, N2, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, strideA, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 11 ); + STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 13 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, prepend, N1, strideP, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, append, N2, strideA, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, out, N+N1+N2-k, strideOut, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, workspace, N+N1+N2-1, strideW, argv, 12 ); + API_SUFFIX(stdlib_strided_ddiff)( N, k, X, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ); + return NULL; +} + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 19 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, k, argv, 1 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 3 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N1, argv, 5 ); + STDLIB_NAPI_ARGV_INT64( env, strideP, argv, 7 ); + STDLIB_NAPI_ARGV_INT64( env, offsetP, argv, 8 ); + STDLIB_NAPI_ARGV_INT64( env, N2, argv, 9 ); + STDLIB_NAPI_ARGV_INT64( env, strideA, argv, 11 ); + STDLIB_NAPI_ARGV_INT64( env, offsetA, argv, 12 ); + STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 14 ); + STDLIB_NAPI_ARGV_INT64( env, offsetOut, argv, 15 ); + STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 17 ); + STDLIB_NAPI_ARGV_INT64( env, offsetW, argv, 18 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, prepend, N1, strideP, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, append, N2, strideA, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, out, N+N1+N2-k, strideOut, argv, 13 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, workspace, N+N1+N2-1, strideW, argv, 16 ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c new file mode 100644 index 000000000000..7c81a744b5e6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -0,0 +1,247 @@ +/** +* @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. +*/ + +#include "stdlib/blas/ext/base/ddiff.h" +#include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/shared.h" + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* +* @param N number of indexed elements +* @param k number of times to recursively compute differences +* @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` +* @param workspace workspace array +* @param strideW stride length for `workspace` +*/ +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); + const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); + const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); + const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo, workspace, strideW, ow ); +} + +/** +* Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* +* @param N number of indexed elements +* @param k number of times to recursively compute differences +* @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` +*/ +static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { + CBLAS_INT total; + double prev; + double curr; + CBLAS_INT ix; + CBLAS_INT ip; + CBLAS_INT ia; + CBLAS_INT io; + CBLAS_INT i; + + total = N + N1 + N2; + if ( total <= 1 ) { + return; + } + + io = 0; + if ( N1 == 0 && N2 == 0 ) { + ix = offsetX + ( ( N - 1 ) * strideX ); + io = offsetOut + ( ( N - 2 ) * strideOut ); + prev = X[ ix ]; + for ( i = N-2; i >= 0; i-- ) { + ix -= strideX; + curr = X[ ix ]; + out[ io ] = prev - curr; + prev = curr; + io -= strideOut; + } + return; + } + + // Prepend + if ( N1 > 0 ) { + io = offsetOut; + ip = offsetP; + prev = prepend[ ip ]; + for ( i = 1; i < N1; i++ ) { + ip += strideP; + curr = prepend[ ip ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + if ( N > 0 ) { + curr = X[ offsetX ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } else if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } else if ( N > 0 ) { + prev = X[ offsetX ]; + } else { + prev = append[ offsetA ]; + } + + // x + if ( N > 0 ) { + ix = offsetX; + if ( N1 == 0 ) { + prev = X[ ix ]; + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = X[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } else { + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = X[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } + if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } + + // Append + if ( N2 > 0 ) { + ia = offsetA + strideA; + for ( i = 1; i < N2; i++ ) { + curr = append[ ia ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ia += strideA; + } + } + return; +} + +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* +* @param N number of indexed elements +* @param k number of times to recursively compute differences +* @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` +* @param workspace workspace array +* @param strideW stride length for `workspace` +* @param offsetW starting index for `workspace` +*/ +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { + CBLAS_INT total; + CBLAS_INT ix; + CBLAS_INT ip; + CBLAS_INT ia; + CBLAS_INT io; + CBLAS_INT n; + CBLAS_INT i; + + total = N + N1 + N2; + if ( total <= 1 || k >= total ) { + return; + } + + if ( k == 0 ) { + io = offsetOut; + ip = offsetP; + for ( i = 0; i < N1; i++ ) { + out[ io ] = prepend[ ip ]; + io += strideOut; + ip += strideP; + } + ix = offsetX; + for ( i = 0; i < N; i++ ) { + out[ io ] = X[ ix ]; + io += strideOut; + ix += strideX; + } + ia = offsetA; + for ( i = 0; i < N2; i++ ) { + out[ io ] = append[ ia ]; + io += strideOut; + ia += strideA; + } + } + + if ( k == 1 ) { + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); + return; + } + + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + + n = total - 1; + for ( i = 1; i < k - 1; i++ ) { + stdlib_strided_base_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); + n -= 1; + } + stdlib_strided_base_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); + return; +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js new file mode 100644 index 000000000000..9f60cd2be39d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js @@ -0,0 +1,218 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ddiff = require( './../lib/ddiff.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ddiff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 14', function test( t ) { + t.strictEqual( ddiff.length, 14, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 7 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 2, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + -16.0, + 15.0, + 0.0, + 0.0, + 0.0, + 6.0, + -5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 6 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 3, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 31.0, + -15.0, + 0.0, + 0.0, + 6.0, + -11.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 5 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + -46.0, + 15.0, + 0.0, + 6.0, + -17.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'if provided 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 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, 'return 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, 2, 2, p, 2, 2, a, 2, o, 2, w, 2 ); + expected = new Float64Array([ + 15.0, + 0.0, + -21.0, + 0.0, + 8.0, + 0.0, + 8.0, + 0.0, + 10.0, + 0.0, + 15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, -2, 2, p, -2, 2, a, -2, o, -2, w, -2 ); + expected = new Float64Array([ + -15.0, + 0.0, + 41.0, + 0.0, + -8.0, + 0.0, + -8.0, + 0.0, + 10.0, + 0.0, + -15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js new file mode 100644 index 000000000000..5e6e969e04cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js @@ -0,0 +1,227 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ddiff = tryRequire( resolve( __dirname, './../lib/ddiff.native.js' ) ); +var opts = { + 'skip': ( ddiff instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ddiff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 14', opts, function test( t ) { + t.strictEqual( ddiff.length, 14, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 7 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 2, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + -16.0, + 15.0, + 0.0, + 0.0, + 0.0, + 6.0, + -5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 6 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 3, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 31.0, + -15.0, + 0.0, + 0.0, + 6.0, + -11.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 5 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + -46.0, + 15.0, + 0.0, + 6.0, + -17.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + +tape( 'the function supports stride parameters', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, 2, 2, p, 2, 2, a, 2, o, 2, w, 2 ); + expected = new Float64Array([ + 15.0, + 0.0, + -21.0, + 0.0, + 8.0, + 0.0, + 8.0, + 0.0, + 10.0, + 0.0, + 15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, -2, 2, p, -2, 2, a, -2, o, -2, w, -2 ); + expected = new Float64Array([ + -15.0, + 0.0, + 41.0, + 0.0, + -8.0, + 0.0, + -8.0, + 0.0, + 10.0, + 0.0, + -15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.js new file mode 100644 index 000000000000..b36476b38039 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.js @@ -0,0 +1,82 @@ +/** +* @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 proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var ddiff = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ddiff, '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 ddiff.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var ddiff = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ddiff, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var ddiff; + var main; + + main = require( './../lib/ddiff.js' ); + + ddiff = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ddiff, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js new file mode 100644 index 000000000000..f2385b211b6a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js @@ -0,0 +1,248 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var ddiff = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ddiff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 19', function test( t ) { + t.strictEqual( ddiff.length, 19, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 7 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 2, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + -16.0, + 15.0, + 0.0, + 0.0, + 0.0, + 6.0, + -5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 6 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 3, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 31.0, + -15.0, + 0.0, + 0.0, + 6.0, + -11.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 5 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 4, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + -46.0, + 15.0, + 0.0, + 6.0, + -17.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'if provided 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 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, 'return 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0, w, 2, 0 ); + expected = new Float64Array([ + 15.0, + 0.0, + -21.0, + 0.0, + 8.0, + 0.0, + 8.0, + 0.0, + 10.0, + 0.0, + 15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10, w, -2, 10 ); // eslint-disable-line max-len + expected = new Float64Array([ + -15.0, + 0.0, + 41.0, + 0.0, + -8.0, + 0.0, + -8.0, + 0.0, + 10.0, + 0.0, + -15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return 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; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( 3, 1, x, 1, 2, 1, p, 1, 2, 1, a, 1, 2, o, 1, 2, w, 1, 2 ); + expected = new Float64Array([ + 0.0, + 0.0, + -13, + 4, + 4, + 25 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js new file mode 100644 index 000000000000..6312e95860b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js @@ -0,0 +1,257 @@ +/** +* @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 resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ddiff = tryRequire( resolve( __dirname, './../lib/ndarray.native.js' ) ); +var opts = { + 'skip': ( ddiff instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ddiff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 19', opts, function test( t ) { + t.strictEqual( ddiff.length, 19, 'returns expected value' ); + t.end(); +}); + +tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 7 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 2, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + -16.0, + 15.0, + 0.0, + 0.0, + 0.0, + 6.0, + -5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 6 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 3, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 31.0, + -15.0, + 0.0, + 0.0, + 6.0, + -11.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 5 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 4, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + -46.0, + 15.0, + 0.0, + 6.0, + -17.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + +tape( 'the function supports stride parameters', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0, w, 2, 0 ); + expected = new Float64Array([ + 15.0, + 0.0, + -21.0, + 0.0, + 8.0, + 0.0, + 8.0, + 0.0, + 10.0, + 0.0, + 15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'the function supports negative stride parameters', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 11 ); + w = new Float64Array( 11 ); + + out = ddiff( 3, 1, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10, w, -2, 10 ); // eslint-disable-line max-len + expected = new Float64Array([ + -15.0, + 0.0, + 41.0, + 0.0, + -8.0, + 0.0, + -8.0, + 0.0, + 10.0, + 0.0, + -15.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); + +tape( 'the function supports offset parameters', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); + a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( 3, 1, x, 1, 2, 1, p, 1, 2, 1, a, 1, 2, o, 1, 2, w, 1, 2 ); + expected = new Float64Array([ + 0.0, + 0.0, + -13, + 4, + 4, + 25 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + t.end(); +}); From c24bbdb81975cbf30df001ddf3e7948ace07020b Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Fri, 20 Feb 2026 01:45:13 +0500 Subject: [PATCH 02/35] docs: apply suggestions from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- .../@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile index 7280962b4c4d..0756dc7da20a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# 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. From a7c267553c7516ffa055a6e8c07b0d3e7dc3cbd8 Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Fri, 20 Feb 2026 01:45:23 +0500 Subject: [PATCH 03/35] docs: apply suggestions from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- .../@stdlib/blas/ext/base/ddiff/examples/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile index ff5293d3059f..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# 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. From d4b2ee63b5063eea2a68d4ef1ceb510cc2aadcdb Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Fri, 20 Feb 2026 01:45:33 +0500 Subject: [PATCH 04/35] docs: apply suggestions from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile index dd720a3de8f2..2caf905cedbe 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2020 The Stdlib Authors. +# 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. From bac88211565f2ea4aed699dd871b5a7f571bf46f Mon Sep 17 00:00:00 2001 From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> Date: Fri, 20 Feb 2026 01:52:55 +0500 Subject: [PATCH 05/35] docs: apply suggestion from code review Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com> --- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js index a497391d8f22..dbf67a53327d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js @@ -16,7 +16,7 @@ * limitations under the License. */ -/* eslint-disable max-params, max-len, stdlib/jsdoc-doctest */ +/* eslint-disable max-params, max-len */ 'use strict'; From 105d19940c79ad36b6c04bb2d648407458fd9b7d Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 26 Feb 2026 22:34:56 +0500 Subject: [PATCH 06/35] fix: apply suggestions from code review --- .../@stdlib/blas/ext/base/ddiff/README.md | 24 +++++----- .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 46 +++++++++---------- .../blas/ext/base/ddiff/examples/c/example.c | 8 ++-- .../include/stdlib/blas/ext/base/ddiff.h | 4 +- .../blas/ext/base/ddiff/lib/ndarray.js | 13 +++--- .../@stdlib/blas/ext/base/ddiff/src/main.c | 18 ++++---- 6 files changed, 57 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index 5678bdae5954..e6ef7c592c77 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -63,9 +63,9 @@ The function has the following parameters: - **N2**: number of elements to `append`. - **append**: a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. - **strideA**: strides length for `append`. -- **out**: output [`Float64Array`][@stdlib/array/float64]. +- **out**: output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. - **strideOut**: stride length for `out`. -- **workspace**: workspace [`Float64Array`][@stdlib/array/float64]. +- **workspace**: workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. - **strideW**: stride length for `workspace`. The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to differences of every other element: @@ -259,13 +259,13 @@ The function accepts the following arguments: - **N2**: `[in] CBLAS_INT` number of elements in `append`. - **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. - **strideA**: `[in] CBLAS_INT` strides length for `append`. -- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. +- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `out`. -- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. +- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `workspace`. ```c -void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, const double workspace, const CBLAS_INT strideW ); +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); ``` @@ -299,15 +299,15 @@ The function accepts the following arguments: - **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. - **strideA**: `[in] CBLAS_INT` strides length for `append`. - **offsetA**: `[in] CBLAS_INT` starting index for `append`. -- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. +- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `out`. -- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. +- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `workspace`. - **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. ```c -void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` @@ -334,13 +334,13 @@ void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, double int main( void ) { // Create a strided array: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; // Define prepend values: - double p[] = { -1.0 }; + const double p[] = { -1.0 }; // Define append values: - double a[] = { 10.0 }; + const double a[] = { 10.0 }; // Define output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -348,7 +348,7 @@ int main( void ) { // Define workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Fill the array: + // Compute forward differences: stdlib_strided_ddiff( 8, 3, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 497f420a25cb..3e29e4f954c6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) +{{alias}}( N, k, x,sx, N1,p,sp, N2,a,sa, out,so, w,sw ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. @@ -22,37 +22,37 @@ x: Float64Array Input array. - strideX: integer + sx: integer Stride length for `x`. N1: integer Number of elements to `prepend`. - prepend: Float64Array + p: Float64Array Array containing values to prepend prior to computing differences. - strideP: integer + sp: integer Stride length for `prepend`. N2: integer Number of elements to `append`. - append: Float64Array + a: Float64Array Array containing values to append prior to computing differences. - strideA: integer + sa: integer Stride length for `append`. out: Float64Array Output array. - strideOut: integer + so: integer Stride length for `Out`. - workspace: Float64Array + w: Float64Array Workspace array. - strideW: integer + sw: integer Stride length for `workspace`. Returns @@ -91,7 +91,7 @@ [ 3.0, 2.0, 2.0, 2.0, 1.0 ] -{{alias}}.ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) +{{alias}}.ndarray( N, k, x,sx,ox, N1,p,sp,op, N2,a,sa,oa, out,so,oo, w,sw,ow ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. @@ -110,52 +110,52 @@ x: Float64Array Input array. - strideX: integer + sx: integer Stride length for `x`. - offsetX: integer + ox: integer Starting index for `x`. N1: integer Number of elements to `prepend`. - prepend: Float64Array + p: Float64Array Array containing values to prepend prior to computing differences. - strideP: integer + sp: integer Stride length for `prepend`. - offsetP: integer + op: integer Starting index for `prepend`. N2: integer Number of elements to `append`. - append: Float64Array + a: Float64Array Array containing values to append prior to computing differences. - strideA: integer + sa: integer Stride length for `append`. - offsetA: integer + oa: integer Starting index for `append`. out: Float64Array Output array. - strideOut: integer + so: integer Stride length for `Out`. - offsetOut: integer + oo: integer Stride length for `Out`. - workspace: Float64Array + w: Float64Array Workspace array. - strideW: integer + sw: integer Stride length for `workspace`. - offsetW: integer + ow: integer Starting index for `workspace`. Returns diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c index e3e5c561834a..0b6fe9dc54a1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c @@ -21,13 +21,13 @@ int main( void ) { // Create a strided array: - double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; + const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; // Define prepend values: - double p[] = { -1.0 }; + const double p[] = { -1.0 }; // Define append values: - double a[] = { 10.0 }; + const double a[] = { 10.0 }; // Define output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -35,7 +35,7 @@ int main( void ) { // Define workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Fill the array: + // Compute forward differences: stdlib_strided_ddiff( 8, 3, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // Print the result: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h index f30cf0d876fa..255b86ba2bf4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h @@ -31,12 +31,12 @@ extern "C" { /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array. */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 2fadef74919f..7e979c8d53a6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -59,15 +59,15 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append } if ( N1 === 0 && N2 === 0 ) { - ix = offsetX + ( ( N - 1 ) * strideX ); - io = offsetOut + ( ( N - 2 ) * strideOut ); + ix = offsetX; + io = offsetOut; prev = x[ ix ]; - for ( i = N-2; i >= 0; i-- ) { - ix -= strideX; + for ( i = 1; i < N; i++ ) { + ix += strideX; curr = x[ ix ]; - out[ io ] = prev - curr; + out[ io ] = curr - prev; prev = curr; - io -= strideOut; + io += strideOut; } return out; } @@ -201,6 +201,7 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap return out; } + // If k >= total number of elements, the k-th forward difference results in an empty array, so this function is a no-op. if ( k >= total ) { return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 7c81a744b5e6..ba2cc091328d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -38,7 +38,7 @@ * @param workspace workspace array * @param strideW stride length for `workspace` */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); @@ -67,7 +67,7 @@ void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, dou * @param strideOut stride length for `out` * @param offsetOut starting index for `out` */ -static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { +static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; double prev; double curr; @@ -84,15 +84,15 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, double *X, con io = 0; if ( N1 == 0 && N2 == 0 ) { - ix = offsetX + ( ( N - 1 ) * strideX ); - io = offsetOut + ( ( N - 2 ) * strideOut ); + ix = offsetX; + io = offsetOut; prev = X[ ix ]; - for ( i = N-2; i >= 0; i-- ) { - ix -= strideX; + for ( i = 1; i < N; i++ ) { + ix += strideX; curr = X[ ix ]; - out[ io ] = prev - curr; + out[ io ] = curr - prev; prev = curr; - io -= strideOut; + io += strideOut; } return; } @@ -194,7 +194,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, double *X, con * @param strideW stride length for `workspace` * @param offsetW starting index for `workspace` */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; CBLAS_INT ix; CBLAS_INT ip; From 11bf0c80dca1306a40de1ecd386f8a827bc0bc8e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Thu, 26 Feb 2026 23:05:08 +0500 Subject: [PATCH 07/35] 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: 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: missing_dependencies - 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/ddiff/README.md | 12 +++---- .../blas/ext/base/ddiff/lib/ndarray.js | 34 ++++++------------- .../@stdlib/blas/ext/base/ddiff/manifest.json | 7 ++-- .../@stdlib/blas/ext/base/ddiff/src/main.c | 32 +++++------------ 4 files changed, 31 insertions(+), 54 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index e6ef7c592c77..7e3dad1039d4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -74,7 +74,7 @@ The `N` and stride parameters determine which elements in the strided array are var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); -var p = new Float64Array( [ 1.0 ] ) +var p = new Float64Array( [ 1.0 ] ); var a = new Float64Array( [ 11.0 ] ); var out = new Float64Array( 4 ); var w = new Float64Array( 4 ); @@ -96,7 +96,7 @@ 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 = new Float64Array( [ 1.0 ] ) +var p = new Float64Array( [ 1.0 ] ); var a = new Float64Array( [ 11.0 ] ); var out = new Float64Array( 5 ); var w = new Float64Array( 5 ); @@ -104,7 +104,7 @@ var w = new Float64Array( 5 ); ddiff( x1.length, 1, x1, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); console.log( out ); -// out => [ 3.0, 2.0, 2.0, 2.0, 11.0 ] +// out => [ 3.0, 2.0, 2.0, 2.0, 1.0 ] ``` @@ -122,7 +122,7 @@ var a = new Float64Array( [ 11.0 ] ); var out = new Float64Array( 6 ); var w = new Float64Array( 6 ); -ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); console.log( out ); // out => [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] @@ -142,12 +142,12 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float64Array = require( '@stdlib/array/float64' ); var x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); -var p = new Float64Array( [ 1.0 ] ) +var p = new Float64Array( [ 1.0 ] ); var a = new Float64Array( [ 11.0 ] ); var out = new Float64Array( 4 ); var w = new Float64Array( 4 ); -ddiff( 3, 1, x, 1, x.length-3, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); +ddiff.ndarray( 3, 1, x, 1, x.length-3, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); console.log( out ); // out => [ 5.0, 2.0, 2.0, 1.0 ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 7e979c8d53a6..803ace40585c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -20,6 +20,11 @@ 'use strict'; +// MODULES // + +var dcopy = require( '@stdlib/blas/base/dcopy' ); + + // FUNCTIONS // /** @@ -189,10 +194,6 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append */ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) { var total; - var ix; - var ip; - var ia; - var io; var n; var i; @@ -207,27 +208,14 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap } if ( k === 0 ) { - io = offsetOut; - ip = offsetP; - for ( i = 0; i < N1; i++ ) { - out[ io ] = prepend[ ip ]; - io += strideOut; - ip += strideP; - } + // Copy `prepend` into output array: + dcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); - ix = offsetX; - for ( i = 0; i < N; i++ ) { - out[ io ] = x[ ix ]; - io += strideOut; - ix += strideX; - } + // Copy `x` into output array: + dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut ); - ia = offsetA; - for ( i = 0; i < N2; i++ ) { - out[ io ] = append[ ia ]; - io += strideOut; - ia += strideA; - } + // Copy `append` into output array: + dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, offsetOut ); } if ( k === 1 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json b/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json index fb41f9fb7ad5..ca4986997d42 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/manifest.json @@ -38,6 +38,7 @@ "dependencies": [ "@stdlib/blas/base/shared", "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/dcopy", "@stdlib/napi/export", "@stdlib/napi/argv", "@stdlib/napi/argv-int64", @@ -56,7 +57,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/dcopy" ] }, { @@ -71,7 +73,8 @@ "libpath": [], "dependencies": [ "@stdlib/blas/base/shared", - "@stdlib/strided/base/stride2offset" + "@stdlib/strided/base/stride2offset", + "@stdlib/blas/base/dcopy" ] } ] diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index ba2cc091328d..14419f34c29d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -18,6 +18,7 @@ #include "stdlib/blas/ext/base/ddiff.h" #include "stdlib/strided/base/stride2offset.h" +#include "stdlib/blas/base/dcopy.h" #include "stdlib/blas/base/shared.h" /** @@ -196,10 +197,6 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * */ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; - CBLAS_INT ix; - CBLAS_INT ip; - CBLAS_INT ia; - CBLAS_INT io; CBLAS_INT n; CBLAS_INT i; @@ -209,25 +206,14 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN } if ( k == 0 ) { - io = offsetOut; - ip = offsetP; - for ( i = 0; i < N1; i++ ) { - out[ io ] = prepend[ ip ]; - io += strideOut; - ip += strideP; - } - ix = offsetX; - for ( i = 0; i < N; i++ ) { - out[ io ] = X[ ix ]; - io += strideOut; - ix += strideX; - } - ia = offsetA; - for ( i = 0; i < N2; i++ ) { - out[ io ] = append[ ia ]; - io += strideOut; - ia += strideA; - } + // Copy `prepend` into output array: + c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + + // Copy `x` into output array: + c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, offsetOut ); + + // Copy `append` into output array: + c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, offsetOut ); } if ( k == 1 ) { From 8c37f1ee981d389a4f56d83acc589fee8c89fde3 Mon Sep 17 00:00:00 2001 From: Athan Date: Fri, 27 Feb 2026 20:22:52 -0800 Subject: [PATCH 08/35] docs: update examples Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 3e29e4f954c6..9852de4bd7a7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -171,16 +171,16 @@ > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); > var out = new {{alias:@stdlib/array/float64}}( 4 ); > var w = new {{alias:@stdlib/array/float64}}( 4 ); - > {{alias}}.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ) + > {{alias}}.ndarray( 3, 1, x,1,0, 1, p,1,0, 1, a,1,0, out,1,0, w,1,0 ) [ 1.0, -3.0, 4.0, 1.0 ] // Advanced indexing: - > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); - > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); - > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); - > var out = new {{alias:@stdlib/array/float64}}( 3 ); - > var w = new {{alias:@stdlib/array/float64}}( 3 ); - > {{alias}}.ndarray( 2, 1, x, 1, x.length-2, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ) + > x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); + > p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); + > a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); + > out = new {{alias:@stdlib/array/float64}}( 3 ); + > w = new {{alias:@stdlib/array/float64}}( 3 ); + > {{alias}}.ndarray( 2, 1, x,1,1, 1, p,1,0, 1, a,1,0, out,1,0, w,1,0 ) [ -2.0, 4.0, 1.0 ] See Also From d47e5a756cee962ae46eebfaa38ae35afab13631 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 2 Mar 2026 02:19:14 +0500 Subject: [PATCH 09/35] 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 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: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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 --- --- .../blas/ext/base/ddiff/lib/ndarray.js | 9 +++- .../@stdlib/blas/ext/base/ddiff/src/main.c | 7 ++- .../blas/ext/base/ddiff/test/test.ddiff.js | 50 +++++++++++++++++++ .../ext/base/ddiff/test/test.ddiff.native.js | 50 +++++++++++++++++++ .../blas/ext/base/ddiff/test/test.ndarray.js | 50 +++++++++++++++++++ .../base/ddiff/test/test.ndarray.native.js | 50 +++++++++++++++++++ 6 files changed, 212 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 803ace40585c..4e2ebe92adbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -194,6 +194,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append */ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) { var total; + var io; var n; var i; @@ -212,10 +213,14 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap dcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); // Copy `x` into output array: - dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, offsetOut ); + io = offsetOut + ( N1 * strideOut ); + dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, io ); // Copy `append` into output array: - dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, offsetOut ); + io = offsetOut + ( ( N1 + N ) * strideOut ); + dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + + return out; } if ( k === 1 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 14419f34c29d..dcb7ea28a2d8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -197,6 +197,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * */ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; + CBLAS_INT io; CBLAS_INT n; CBLAS_INT i; @@ -210,10 +211,12 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); // Copy `x` into output array: - c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, offsetOut ); + io = offsetOut + ( N1 * strideOut ); + c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, io ); // Copy `append` into output array: - c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, offsetOut ); + io = offsetOut + ( ( N1 + N ) * strideOut ); + c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, io ); } if ( k == 1 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js index 9f60cd2be39d..52504eb8ef99 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js @@ -38,6 +38,38 @@ tape( 'the function has an arity of 14', function test( t ) { t.end(); }); +tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { var expected; var out; @@ -112,6 +144,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 9 ); + w = new Float64Array( 9 ); + + out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 10.0, + 15.0, + 4.0, + 8.0, + 12.0, + 16.0, + 20.0, + 30.0, + 35.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js index 5e6e969e04cb..422f23d1418c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js @@ -47,6 +47,38 @@ tape( 'the function has an arity of 14', opts, function test( t ) { t.end(); }); +tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { var expected; var out; @@ -121,6 +153,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 9 ); + w = new Float64Array( 9 ); + + out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 10.0, + 15.0, + 4.0, + 8.0, + 12.0, + 16.0, + 20.0, + 30.0, + 35.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js index f2385b211b6a..f83f3e1ccc18 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js @@ -38,6 +38,38 @@ tape( 'the function has an arity of 19', function test( t ) { t.end(); }); +tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { var expected; var out; @@ -112,6 +144,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 9 ); + w = new Float64Array( 9 ); + + out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 10.0, + 15.0, + 4.0, + 8.0, + 12.0, + 16.0, + 20.0, + 30.0, + 35.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js index 6312e95860b7..9ea526f93632 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js @@ -47,6 +47,38 @@ tape( 'the function has an arity of 19', opts, function test( t ) { t.end(); }); +tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var o; + var w; + + x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); + p = new Float64Array( [ 10.0, 15.0 ] ); + a = new Float64Array( [ 30.0, 35.0 ] ); + o = new Float64Array( 8 ); + w = new Float64Array( 8 ); + + out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 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, 'return expected value' ); + + t.end(); +}); + tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { var expected; var out; @@ -121,6 +153,24 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 9 ); + w = new Float64Array( 9 ); + + out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 10.0, + 15.0, + 4.0, + 8.0, + 12.0, + 16.0, + 20.0, + 30.0, + 35.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + t.end(); }); From 9e7b7086f17965b7322b1f8b0c6ad122454405b5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Mon, 2 Mar 2026 03:02:56 +0500 Subject: [PATCH 10/35] 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 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: 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: na - task: lint_license_headers status: passed --- --- .../blas/ext/base/ddiff/lib/ndarray.js | 2 + .../blas/ext/base/ddiff/test/test.ddiff.js | 75 +++++++++++++++++++ .../ext/base/ddiff/test/test.ddiff.native.js | 72 ++++++++++++++++++ .../blas/ext/base/ddiff/test/test.ndarray.js | 72 ++++++++++++++++++ .../base/ddiff/test/test.ndarray.native.js | 49 ++++++++++++ 5 files changed, 270 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 4e2ebe92adbf..f83e75bf6e1f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -102,8 +102,10 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append } } else if ( N > 0 ) { prev = x[ offsetX ]; + io = offsetX; } else { prev = append[ offsetA ]; + io = offsetA; } // x diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js index 52504eb8ef99..c96e3c2e7eaa 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js @@ -99,6 +99,81 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( x.length, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + out = ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + out = ddiff( 0, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + 15.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 7 ); w = new Float64Array( 8 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js index 422f23d1418c..81f4879d3b7b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js @@ -108,6 +108,78 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + out = ddiff( x.length, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + out = ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + out = ddiff( 0, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0, + 15.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 7 ); w = new Float64Array( 8 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js index f83f3e1ccc18..dbd442bcd3b0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js @@ -99,6 +99,78 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 5.0, + 15.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 1 ); + w = new Float64Array( 1 ); + + out = ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 7 ); w = new Float64Array( 8 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js index 9ea526f93632..277a5e57fc1a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js @@ -108,6 +108,55 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 5.0, + -11.0, + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0, + 10.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len + expected = new Float64Array([ + 4.0, + 4.0, + 4.0, + 4.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + + o = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); + expected = new Float64Array([ + 5.0, + 15.0, + 5.0 + ]); + t.deepEqual( o, expected, 'returns expected value' ); + t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 7 ); w = new Float64Array( 8 ); From 29ac5deef4763dd2074e1a79cfc55feb3ff7462c Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 3 Mar 2026 00:42:28 +0500 Subject: [PATCH 11/35] 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - 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: missing_dependencies - 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/ddiff/binding.gyp | 95 +++++++++++++++++++ .../@stdlib/blas/ext/base/ddiff/src/main.c | 4 +- .../base/ddiff/test/test.ndarray.native.js | 3 + 3 files changed, 101 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp b/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp index 0d6508a12e99..60dce9d0b31a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/binding.gyp @@ -29,6 +29,39 @@ # Target name should match the add-on export name: 'addon_target_name%': 'addon', + # Fortran compiler (to override -Dfortran_compiler=): + 'fortran_compiler%': 'gfortran', + + # Fortran compiler flags: + 'fflags': [ + # Specify the Fortran standard to which a program is expected to conform: + '-std=f95', + + # Indicate that the layout is free-form source code: + '-ffree-form', + + # Aggressive optimization: + '-O3', + + # Enable commonly used warning options: + '-Wall', + + # Warn if source code contains problematic language features: + '-Wextra', + + # Warn if a procedure is called without an explicit interface: + '-Wimplicit-interface', + + # Do not transform names of entities specified in Fortran source files by appending underscores (i.e., don't mangle names, thus allowing easier usage in C wrappers): + '-fno-underscoring', + + # Warn if source code contains Fortran 95 extensions and C-language constructs: + '-pedantic', + + # Compile but do not link (output is an object file): + '-c', + ], + # Set variables based on the host OS: 'conditions': [ [ @@ -128,6 +161,68 @@ }, ], # end condition (OS!="win") ], # end conditions + + # Define custom build actions for particular inputs: + 'rules': [ + { + # Define a rule for processing Fortran files: + 'extension': 'f', + + # Define the pathnames to be used as inputs when performing processing: + 'inputs': [ + # Full path of the current input: + '<(RULE_INPUT_PATH)' + ], + + # Define the outputs produced during processing: + 'outputs': [ + # Store an output object file in a directory for placing intermediate results (only accessible within a single target): + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).<(obj)' + ], + + # Define the rule for compiling Fortran based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + + # Rule to compile Fortran on Windows: + { + 'rule_name': 'compile_fortran_windows', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Windows...', + + 'process_outputs_as_sources': 0, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + }, + + # Rule to compile Fortran on non-Windows: + { + 'rule_name': 'compile_fortran_linux', + 'message': 'Compiling Fortran file <(RULE_INPUT_PATH) on Linux...', + + 'process_outputs_as_sources': 1, + + # Define the command-line invocation: + 'action': [ + '<(fortran_compiler)', + '<@(fflags)', + '-fPIC', # generate platform-independent code + '<@(_inputs)', + '-o', + '<@(_outputs)', + ], + } + ], # end condition (OS=="win") + ], # end conditions + }, # end rule (extension=="f") + ], # end rules }, # end target <(addon_target_name) # Target to copy a generated add-on to a standard location: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index dcb7ea28a2d8..d96d91f4fb97 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -123,8 +123,10 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * } } else if ( N > 0 ) { prev = X[ offsetX ]; + io = offsetX; } else { prev = append[ offsetA ]; + io = offsetA; } // x @@ -216,7 +218,7 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN // Copy `append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - c_dcopy_ndarray( N, append, strideA, offsetA, out, strideOut, io ); + c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io ); } if ( k == 1 ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js index 277a5e57fc1a..7631fd046955 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js @@ -135,6 +135,9 @@ tape( 'the function calculates the k-th discrete forward differences of a double t.deepEqual( o, expected, 'returns expected value' ); t.strictEqual( out, o, 'return expected value' ); + o = new Float64Array( 4 ); + w = new Float64Array( 4 ); + out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len expected = new Float64Array([ 4.0, From 57ae344bfd5064fc00b79a3a5e113354da439ef8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Tue, 3 Mar 2026 00:56:47 +0500 Subject: [PATCH 12/35] fix: bug in C --- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - 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: missing_dependencies - 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 --- --- lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index d96d91f4fb97..2f2c508a7941 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -219,6 +219,8 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN // Copy `append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + + return; } if ( k == 1 ) { From 55c25341eb2125f1a32953f00b2532b297afcc02 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 13 Mar 2026 00:57:19 +0500 Subject: [PATCH 13/35] 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 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: na - 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: missing_dependencies - 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/ddiff/README.md | 50 +- .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 20 +- .../blas/ext/base/ddiff/docs/types/index.d.ts | 6 +- .../include/stdlib/blas/ext/base/ddiff.h | 4 +- .../@stdlib/blas/ext/base/ddiff/lib/ddiff.js | 4 +- .../@stdlib/blas/ext/base/ddiff/lib/index.js | 2 +- .../blas/ext/base/ddiff/lib/ndarray.js | 6 +- .../@stdlib/blas/ext/base/ddiff/src/main.c | 68 +-- .../blas/ext/base/ddiff/test/test.ddiff.js | 428 ++++++++--------- .../ext/base/ddiff/test/test.ddiff.native.js | 427 ++++++++--------- .../blas/ext/base/ddiff/test/test.ndarray.js | 445 ++++++++---------- .../base/ddiff/test/test.ndarray.native.js | 437 ++++++++--------- 12 files changed, 837 insertions(+), 1060 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index 7e3dad1039d4..4c03848d09c5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -61,8 +61,8 @@ The function has the following parameters: - **prepend**: a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. - **strideP**: stride length for `prepend`. - **N2**: number of elements to `append`. -- **append**: a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. -- **strideA**: strides length for `append`. +- **append**: a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences. +- **strideA**: stride length for `append`. - **out**: output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. - **strideOut**: stride length for `out`. - **workspace**: workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. @@ -161,7 +161,7 @@ console.log( out ); ## Notes -- If `N <= 0`, both functions return `x` unchanged. +- If `N <= 0`, both functions return the output array unchanged. @@ -233,14 +233,14 @@ console.log( 'Output', out ); -#### stdlib_strided_ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, \*out, strideOut, workspace, strideW ) +#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*prepend, strideP, N2, \*append, strideA, \*Out, strideOut, \*Workspace, strideW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. ```c -double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; -double p[] = { 1.0 }; -double a[] = { 11.0 }; +const double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; +const double p[] = { 1.0 }; +const double a[] = { 11.0 }; double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -251,33 +251,33 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. -- **x**: `[in] double` input [`Float64Array`][@stdlib/array/float64]. +- **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `x`. - **N1**: `[in] CBLAS_INT` number of elements in `prepend`. -- **prepend**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. +- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. - **strideP**: `[in] CBLAS_INT` stride length for `prepend`. - **N2**: `[in] CBLAS_INT` number of elements in `append`. -- **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. -- **strideA**: `[in] CBLAS_INT` strides length for `append`. -- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. +- **append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `append`. +- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `out`. -- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. +- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `workspace`. ```c -void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); ``` -#### stdlib_strided_ddiff_ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, \*out, strideOut, offsetOut, w, strideW, offsetW ) +#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*prepend, strideP, offsetP, N2, \*append, strideA, offsetA, \*Out, strideOut, offsetOut, \*W, strideW, offsetW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. ```c -double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; -double p[] = { 1.0 }; -double a[] = { 11.0 }; +const double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; +const double p[] = { 1.0 }; +const double a[] = { 11.0 }; double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; @@ -288,26 +288,26 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. -- **x**: `[in] double` input [`Float64Array`][@stdlib/array/float64]. +- **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `x`. - **offsetX**: `[in] CBLAS_INT` starting index for `x`. - **N1**: `[in] CBLAS_INT` number of elements in `prepend`. -- **prepend**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. +- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. - **strideP**: `[in] CBLAS_INT` stride length for `prepend`. - **offsetP**: `[in] CBLAS_INT` starting index for `prepend`. - **N2**: `[in] CBLAS_INT` number of elements in `append`. -- **append**: `[in] double` a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences.. -- **strideA**: `[in] CBLAS_INT` strides length for `append`. +- **append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `append`. - **offsetA**: `[in] CBLAS_INT` starting index for `append`. -- **out**: `[in] double` output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. +- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `out`. -- **workspace**: `[in] double` workspace [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - 1` elements. +- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `workspace`. - **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. ```c -void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 9852de4bd7a7..4a817f23503f 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -9,7 +9,7 @@ Indexing is relative to the first index. To introduce an offset, use a typed array view. - If `N <= 0`, the function returns `x` unchanged. + If `N <= 0`, the function returns the output array unchanged. Parameters ---------- @@ -47,7 +47,7 @@ Output array. so: integer - Stride length for `Out`. + Stride length for `out`. w: Float64Array Workspace array. @@ -62,7 +62,7 @@ Examples -------- - // Standard Usage: + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); @@ -75,8 +75,8 @@ > x = new {{alias:@stdlib/array/float64}}( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); > p = new {{alias:@stdlib/array/float64}}( [ 1.0 ] ); > a = new {{alias:@stdlib/array/float64}}( [ 11.0 ] ); - > var out = new {{alias:@stdlib/array/float64}}( 4 ); - > var w = new {{alias:@stdlib/array/float64}}( 4 ); + > out = new {{alias:@stdlib/array/float64}}( 4 ); + > w = new {{alias:@stdlib/array/float64}}( 4 ); > {{alias}}( 3, 1, x, 2, 1, p, 1, 1, a, 1, out, 1, w, 1 ) [ 1.0, 4.0, 4.0, 1.0 ] @@ -85,8 +85,8 @@ > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); > p = new {{alias:@stdlib/array/float64}}( [ 1.0 ] ); > a = new {{alias:@stdlib/array/float64}}( [ 11.0 ] ); - > var out = new {{alias:@stdlib/array/float64}}( 5 ); - > var w = new {{alias:@stdlib/array/float64}}( 5 ); + > out = new {{alias:@stdlib/array/float64}}( 5 ); + > w = new {{alias:@stdlib/array/float64}}( 5 ); > {{alias}}( x1.length, 1, x1, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ) [ 3.0, 2.0, 2.0, 2.0, 1.0 ] @@ -144,10 +144,10 @@ Output array. so: integer - Stride length for `Out`. + Stride length for `out`. oo: integer - Stride length for `Out`. + Starting index for `out`. w: Float64Array Workspace array. @@ -165,7 +165,7 @@ Examples -------- - // Standard Usage: + // Standard usage: > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, -2.0, 2.0 ] ); > var p = new {{alias:@stdlib/array/float64}}( [ 0.0 ] ); > var a = new {{alias:@stdlib/array/float64}}( [ 3.0 ] ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts index d69d36a691b2..67405c7ac7a3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts @@ -48,7 +48,7 @@ interface Routine { * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); - * var w = new Float64Array( 6 ) + * var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); * @@ -88,14 +88,14 @@ interface Routine { * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); - * var w = new Float64Array( 6 ) + * var w = new Float64Array( 6 ); * * ddiff.ndarray( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); * * console.log( out ); * // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] */ - ndarray ( N: number, k: number, x: Float64Array, strideX: number, offsetX: number, N1: number, prepend: Float64Array, strideP: number, offsetP: number, N2: number, append: Float64Array, strideA: number, offsetA: number, out: Float64Array, strideOut: number, offsetOut: number, workspace: Float64Array, strideW: number, offsetW: number ): Float64Array; + ndarray( N: number, k: number, x: Float64Array, strideX: number, offsetX: number, N1: number, prepend: Float64Array, strideP: number, offsetP: number, N2: number, append: Float64Array, strideA: number, offsetA: number, out: Float64Array, strideOut: number, offsetOut: number, workspace: Float64Array, strideW: number, offsetW: number ): Float64Array; } /** diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h index 255b86ba2bf4..d88c49ef05d0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h @@ -31,12 +31,12 @@ extern "C" { /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array. */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js index dbf67a53327d..b93804217308 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js @@ -54,12 +54,12 @@ var ndarray = require( './ndarray.js' ); * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); * * console.log( out ); -* // out => [ 1, 1, 1, 1, 1 ] +* // out => [ 1.0, 1.0, 1.0, 1.0, 1.0 ] */ function ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) { var ox = stride2offset( N, strideX ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js index f059ed607ee6..706d13717606 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/index.js @@ -31,7 +31,7 @@ * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index f83e75bf6e1f..84825104bb29 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -102,10 +102,10 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append } } else if ( N > 0 ) { prev = x[ offsetX ]; - io = offsetX; + io = offsetOut; } else { prev = append[ offsetA ]; - io = offsetA; + io = offsetOut; } // x @@ -187,7 +187,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 2f2c508a7941..5248acbb6a7e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -34,18 +34,18 @@ * @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` -* @param workspace workspace array -* @param strideW stride length for `workspace` +* @param Out output array +* @param strideOut stride length for `Out` +* @param Workspace workspace array +* @param strideW stride length for `Workspace` */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ) { const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); - API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo, workspace, strideW, ow ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, Out, strideOut, oo, Workspace, strideW, ow ); } /** @@ -64,11 +64,11 @@ void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, con * @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` +* @param Out output array +* @param strideOut stride length for `Out` +* @param offsetOut starting index for `Out` */ -static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { +static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; double prev; double curr; @@ -91,7 +91,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * for ( i = 1; i < N; i++ ) { ix += strideX; curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -106,27 +106,27 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * for ( i = 1; i < N1; i++ ) { ip += strideP; curr = prepend[ ip ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } if ( N > 0 ) { curr = X[ offsetX ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } else if ( N2 > 0 ) { curr = append[ offsetA ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } } else if ( N > 0 ) { prev = X[ offsetX ]; - io = offsetX; + io = offsetOut; } else { prev = append[ offsetA ]; - io = offsetA; + io = offsetOut; } // x @@ -137,7 +137,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; @@ -146,7 +146,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; @@ -154,7 +154,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * } if ( N2 > 0 ) { curr = append[ offsetA ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -165,7 +165,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { curr = append[ ia ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ia += strideA; @@ -190,14 +190,14 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * * @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` -* @param workspace workspace array -* @param strideW stride length for `workspace` -* @param offsetW starting index for `workspace` +* @param Out output array +* @param strideOut stride length for `Out` +* @param offsetOut starting index for `Out` +* @param Workspace workspace array +* @param strideW stride length for `Workspace` +* @param offsetW starting index for `Workspace` */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; CBLAS_INT io; CBLAS_INT n; @@ -210,31 +210,31 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN if ( k == 0 ) { // Copy `prepend` into output array: - c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + c_dcopy_ndarray( N1, prepend, strideP, offsetP, Out, strideOut, offsetOut ); // Copy `x` into output array: io = offsetOut + ( N1 * strideOut ); - c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, io ); + c_dcopy_ndarray( N, X, strideX, offsetX, Out, strideOut, io ); // Copy `append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + c_dcopy_ndarray( N2, append, strideA, offsetA, Out, strideOut, io ); return; } if ( k == 1 ) { - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, Out, strideOut, offsetOut ); return; } - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, Workspace, strideW, offsetW ); n = total - 1; for ( i = 1; i < k - 1; i++ ) { - stdlib_strided_base_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); + stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, Workspace, strideW, offsetW ); n -= 1; } - stdlib_strided_base_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); + stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, Out, strideOut, offsetOut ); return; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js index c96e3c2e7eaa..ffed9f77726e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.js @@ -33,311 +33,257 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 14', function test( t ) { - t.strictEqual( ddiff.length, 14, 'returns expected value' ); +tape( 'the function calculates the first forward difference', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { +tape( 'the function calculates higher-order forward differences', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 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, 'return expected value' ); + // Second forward difference (k=2): + x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 22.0 ] ); + out = new Float64Array( 5 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Third forward difference (k=3): + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0, 15.0, 21.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 5 ); + + ddiff( x.length, 3, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { +tape( 'the function supports k=0 (copies input)', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); + x = new Float64Array( [ 2.0, 4.0, 6.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 5 ); + w = new Float64Array( 4 ); - out = ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); + ddiff( x.length, 0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); - out = ddiff( x.length, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 4 ); - w = new Float64Array( 4 ); + expected = new Float64Array( [ 1.0, 2.0, 4.0, 6.0, 7.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); - out = ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 3 ); - w = new Float64Array( 3 ); +tape( 'the function returns the output array unchanged for trivial cases', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; - out = ddiff( 0, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - 15.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // N <= 0: + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0, 0.0 ] ); + w = new Float64Array( 2 ); - o = new Float64Array( 1 ); + ddiff( 0, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); - o = new Float64Array( 1 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 2.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 7 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 2, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - -16.0, - 15.0, - 0.0, - 0.0, - 0.0, - 6.0, - -5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 3, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 31.0, - -15.0, - 0.0, - 0.0, - 6.0, - -11.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 5 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - -46.0, - 15.0, - 0.0, - 6.0, - -17.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 9 ); - w = new Float64Array( 9 ); - - out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 10.0, - 15.0, - 4.0, - 8.0, - 12.0, - 16.0, - 20.0, - 30.0, - 35.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( x.length, 5, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { +tape( 'the function supports no prepend and no append', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 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, 'return expected value' ); + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 3.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports stride parameters', function test( t ) { +tape( 'the function supports strides', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, 2, 2, p, 2, 2, a, 2, o, 2, w, 2 ); - expected = new Float64Array([ - 15.0, - 0.0, - -21.0, - 0.0, - 8.0, - 0.0, - 8.0, - 0.0, - 10.0, - 0.0, - 15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Negative strides: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, -1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 9.0, -2.0, -2.0, -2.0, -2.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + // Strided access (stride=2): + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 2, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 4.0, 4.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative stride parameters', function test( t ) { +tape( 'the function supports multiple prepend and append values', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, -2, 2, p, -2, 2, a, -2, o, -2, w, -2 ); - expected = new Float64Array([ - -15.0, - 0.0, - 41.0, - 0.0, - -8.0, - 0.0, - -8.0, - 0.0, - 10.0, - 0.0, - -15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Multiple prepend (N1=2), no append: + x = new Float64Array( [ 6.0, 8.0 ] ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 3.0, 2.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Multiple prepend (N1=2) and append (N2=1), no x: + x = new Float64Array( 0 ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 2, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 6.0, 10.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 2, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + t.deepEqual( out, 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 w; + + // No prepend, x present, single append: + x = new Float64Array( [ 2.0, 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 10.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( x.length, 1, x, 1, 0, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // No prepend, no x, only append (N2=3): + x = new Float64Array( 0 ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 1.0, 4.0, 9.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 0, p, 1, 3, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js index 81f4879d3b7b..6f29afc77df0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ddiff.native.js @@ -42,308 +42,257 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 14', opts, function test( t ) { - t.strictEqual( ddiff.length, 14, 'returns expected value' ); +tape( 'the function calculates the first forward difference', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { +tape( 'the function calculates higher-order forward differences', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 9, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 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, 'return expected value' ); + // Second forward difference (k=2): + x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 22.0 ] ); + out = new Float64Array( 5 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Third forward difference (k=3): + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0, 15.0, 21.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 5 ); + + ddiff( x.length, 3, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { +tape( 'the function supports k=0 (copies input)', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); - - out = ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - out = ddiff( x.length, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 4 ); + x = new Float64Array( [ 2.0, 4.0, 6.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 5 ); w = new Float64Array( 4 ); - out = ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 3 ); - w = new Float64Array( 3 ); + ddiff( x.length, 0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 2.0, 4.0, 6.0, 7.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array unchanged for trivial cases', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; - out = ddiff( 0, 1, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0, - 15.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // N <= 0: + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0, 0.0 ] ); + w = new Float64Array( 2 ); - o = new Float64Array( 1 ); + ddiff( 0, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 2, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); - o = new Float64Array( 1 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 2.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 0, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 7 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 2, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - -16.0, - 15.0, - 0.0, - 0.0, - 0.0, - 6.0, - -5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 3, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 31.0, - -15.0, - 0.0, - 0.0, - 6.0, - -11.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 5 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - -46.0, - 15.0, - 0.0, - 6.0, - -17.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 9 ); - w = new Float64Array( 9 ); - - out = ddiff( x.length, 0, x, 1, 2, p, 1, 2, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 10.0, - 15.0, - 4.0, - 8.0, - 12.0, - 16.0, - 20.0, - 30.0, - 35.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( x.length, 5, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', opts, function test( t ) { +tape( 'the function supports no prepend and no append', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( 1, 1, x, 1, 0, p, 1, 0, a, 1, o, 1, w, 1 ); - expected = new Float64Array([ - 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, 'return expected value' ); + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + ddiff( x.length, 1, x, 1, 0, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 3.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports stride parameters', opts, function test( t ) { +tape( 'the function supports strides', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, 2, 2, p, 2, 2, a, 2, o, 2, w, 2 ); - expected = new Float64Array([ - 15.0, - 0.0, - -21.0, - 0.0, - 8.0, - 0.0, - 8.0, - 0.0, - 10.0, - 0.0, - 15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Negative strides: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, -1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 9.0, -2.0, -2.0, -2.0, -2.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + // Strided access (stride=2): + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 2, 1, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 4.0, 4.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative stride parameters', opts, function test( t ) { +tape( 'the function supports multiple prepend and append values', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, -2, 2, p, -2, 2, a, -2, o, -2, w, -2 ); - expected = new Float64Array([ - -15.0, - 0.0, - 41.0, - 0.0, - -8.0, - 0.0, - -8.0, - 0.0, - 10.0, - 0.0, - -15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Multiple prepend (N1=2), no append: + x = new Float64Array( [ 6.0, 8.0 ] ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + ddiff( x.length, 1, x, 1, 2, p, 1, 0, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 3.0, 2.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Multiple prepend (N1=2) and append (N2=1), no x: + x = new Float64Array( 0 ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 2, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Prepend (N1=1), x, and multiple append (N2=2): + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 6.0, 10.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( x.length, 1, x, 1, 1, p, 1, 2, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports append without prepend', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + // No prepend, x present, single append: + x = new Float64Array( [ 2.0, 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 10.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( x.length, 1, x, 1, 0, p, 1, 1, a, 1, out, 1, w, 1 ); + + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // No prepend, no x, only append (N2=3): + x = new Float64Array( 0 ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 1.0, 4.0, 9.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 0, p, 1, 3, a, 1, out, 1, w, 1 ); + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js index dbd442bcd3b0..8363800de323 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.js @@ -33,338 +33,269 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 19', function test( t ) { - t.strictEqual( ddiff.length, 19, 'returns expected value' ); +tape( 'the function calculates the first forward difference', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { +tape( 'the function calculates higher-order forward differences', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 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, 'return expected value' ); + // Second forward difference (k=2): + x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 22.0 ] ); + out = new Float64Array( 5 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Third forward difference (k=3): + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0, 15.0, 21.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 5 ); + ddiff( x.length, 3, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', function test( t ) { +tape( 'the function supports k=0 (copies input)', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); - - out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 4 ); + x = new Float64Array( [ 2.0, 4.0, 6.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 5 ); w = new Float64Array( 4 ); - out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 3 ); - w = new Float64Array( 3 ); + ddiff( x.length, 0, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 4.0, 6.0, 7.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array unchanged for trivial cases', function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; - out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 5.0, - 15.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // N <= 0: + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0, 0.0 ] ); + w = new Float64Array( 2 ); - o = new Float64Array( 1 ); + ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); - o = new Float64Array( 1 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 2.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); w = new Float64Array( 1 ); - out = ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 7 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 2, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - -16.0, - 15.0, - 0.0, - 0.0, - 0.0, - 6.0, - -5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 3, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 31.0, - -15.0, - 0.0, - 0.0, - 6.0, - -11.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 5 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 4, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - -46.0, - 15.0, - 0.0, - 6.0, - -17.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 9 ); - w = new Float64Array( 9 ); - - out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 10.0, - 15.0, - 4.0, - 8.0, - 12.0, - 16.0, - 20.0, - 30.0, - 35.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( x.length, 5, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', function test( t ) { +tape( 'the function supports no prepend and no append', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 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, 'return expected value' ); + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 2.0, 3.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports stride parameters', function test( t ) { +tape( 'the function supports strides and offsets', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0, w, 2, 0 ); - expected = new Float64Array([ - 15.0, - 0.0, - -21.0, - 0.0, - 8.0, - 0.0, - 8.0, - 0.0, - 10.0, - 0.0, - 15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Offset for `x`: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 5.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Negative strides: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, -1, 4, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 9.0, -2.0, -2.0, -2.0, -2.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Strided access (stride=2): + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 2, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 1.0, 4.0, 4.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative stride parameters', function test( t ) { +tape( 'the function supports multiple prepend and append values', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10, w, -2, 10 ); // eslint-disable-line max-len - expected = new Float64Array([ - -15.0, - 0.0, - 41.0, - 0.0, - -8.0, - 0.0, - -8.0, - 0.0, - 10.0, - 0.0, - -15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Multiple prepend (N1=2), no append: + x = new Float64Array( [ 6.0, 8.0 ] ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 2.0, 3.0, 2.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Multiple prepend (N1=2) and append (N2=1), no x: + x = new Float64Array( 0 ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + // Prepend (N1=1), x, and multiple append (N2=2): + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 6.0, 10.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 2, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports offset parameters', function test( t ) { +tape( 'the function supports append without prepend', function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); + // No prepend, x present, single append: + x = new Float64Array( [ 2.0, 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 10.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // No prepend, no x, only append (N2=3): + x = new Float64Array( 0 ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 1.0, 4.0, 9.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); - out = ddiff( 3, 1, x, 1, 2, 1, p, 1, 2, 1, a, 1, 2, o, 1, 2, w, 1, 2 ); - expected = new Float64Array([ - 0.0, - 0.0, - -13, - 4, - 4, - 25 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 3, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js index 7631fd046955..dd7741c2fe6d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/test/test.ndarray.native.js @@ -42,318 +42,269 @@ tape( 'main export is a function', opts, function test( t ) { t.end(); }); -tape( 'the function has an arity of 19', opts, function test( t ) { - t.strictEqual( ddiff.length, 19, 'returns expected value' ); +tape( 'the function calculates the first forward difference', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function returns output unchanged if `k` is greater than or equal to total number of elements', function test( t ) { +tape( 'the function calculates higher-order forward differences', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 9, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 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, 'return expected value' ); + // Second forward difference (k=2): + x = new Float64Array( [ 2.0, 4.0, 7.0, 11.0, 16.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 22.0 ] ); + out = new Float64Array( 5 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 1.0, 1.0, 1.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Third forward difference (k=3): + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0, 15.0, 21.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 5 ); + + ddiff( x.length, 3, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function calculates the k-th discrete forward differences of a double-precision floating-point strided array', opts, function test( t ) { +tape( 'the function supports k=0 (copies input)', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); - - out = ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 5.0, - -11.0, - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0, - 10.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 4 ); + x = new Float64Array( [ 2.0, 4.0, 6.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 5 ); w = new Float64Array( 4 ); - out = ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 4.0, - 4.0, - 4.0, - 4.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 3 ); - w = new Float64Array( 3 ); + ddiff( x.length, 0, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 4.0, 6.0, 7.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output array unchanged for trivial cases', opts, function test( t ) { + var expected; + var out; + var x; + var p; + var a; + var w; + + // N <= 0: + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0, 0.0 ] ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); - out = ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 5.0, - 15.0, - 5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 7 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 2, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - -16.0, - 15.0, - 0.0, - 0.0, - 0.0, - 6.0, - -5.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 6 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 3, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 31.0, - -15.0, - 0.0, - 0.0, - 6.0, - -11.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 5 ); - w = new Float64Array( 8 ); - - out = ddiff( x.length, 4, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - -46.0, - 15.0, - 0.0, - 6.0, - -17.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); - - o = new Float64Array( 9 ); - w = new Float64Array( 9 ); - - out = ddiff( x.length, 0, x, 1, 0, 2, p, 1, 0, 2, a, 1, 0, o, 1, 0, w, 1, 0 ); // eslint-disable-line max-len - expected = new Float64Array([ - 10.0, - 15.0, - 4.0, - 8.0, - 12.0, - 16.0, - 20.0, - 30.0, - 35.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + expected = new Float64Array( [ 0.0, 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + x = new Float64Array( [ 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); + w = new Float64Array( 1 ); + + ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + x = new Float64Array( [ 1.0, 2.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( [ 0.0 ] ); + w = new Float64Array( 1 ); + + ddiff( x.length, 5, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 0.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'if provided the sum of `N`, `N1` & `N2` parameter is less than or equal to `1`, the function returns `out` unchanged', opts, function test( t ) { +tape( 'the function supports no prepend and no append', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0 ] ); - a = new Float64Array( [ 30.0, 35.0 ] ); - o = new Float64Array( 8 ); - w = new Float64Array( 8 ); - - out = ddiff( 1, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, o, 1, 0, w, 1, 0 ); - expected = new Float64Array([ - 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, 'return expected value' ); + x = new Float64Array( [ 1.0, 3.0, 6.0, 10.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 2.0, 3.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports stride parameters', opts, function test( t ) { +tape( 'the function supports strides and offsets', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, 2, 0, 2, p, 2, 0, 2, a, 2, 0, o, 2, 0, w, 2, 0 ); - expected = new Float64Array([ - 15.0, - 0.0, - -21.0, - 0.0, - 8.0, - 0.0, - 8.0, - 0.0, - 10.0, - 0.0, - 15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Offset for `x`: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 1, 2, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 5.0, 2.0, 2.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Negative strides: + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 6 ); + w = new Float64Array( 6 ); + + ddiff( x.length, 1, x, -1, 4, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 9.0, -2.0, -2.0, -2.0, -2.0, 9.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Strided access (stride=2): + x = new Float64Array( [ 2.0, 4.0, 6.0, 8.0, 10.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 11.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( 3, 1, x, 2, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 1.0, 4.0, 4.0, 1.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports negative stride parameters', opts, function test( t ) { +tape( 'the function supports multiple prepend and append values', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 11 ); - w = new Float64Array( 11 ); - - out = ddiff( 3, 1, x, -2, 4, 2, p, -2, 2, 2, a, -2, 2, o, -2, 10, w, -2, 10 ); // eslint-disable-line max-len - expected = new Float64Array([ - -15.0, - 0.0, - 41.0, - 0.0, - -8.0, - 0.0, - -8.0, - 0.0, - 10.0, - 0.0, - -15.0 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + // Multiple prepend (N1=2), no append: + x = new Float64Array( [ 6.0, 8.0 ] ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( 0 ); + out = new Float64Array( 3 ); + w = new Float64Array( 3 ); + + ddiff( x.length, 1, x, 1, 0, 2, p, 1, 0, 0, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 2.0, 3.0, 2.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // Multiple prepend (N1=2) and append (N2=1), no x: + x = new Float64Array( 0 ); + p = new Float64Array( [ 1.0, 3.0 ] ); + a = new Float64Array( [ 7.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( 0, 1, x, 1, 0, 2, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + // Prepend (N1=1), x, and multiple append (N2=2): + x = new Float64Array( [ 2.0, 4.0 ] ); + p = new Float64Array( [ 1.0 ] ); + a = new Float64Array( [ 6.0, 10.0 ] ); + out = new Float64Array( 4 ); + w = new Float64Array( 4 ); + + ddiff( x.length, 1, x, 1, 0, 1, p, 1, 0, 2, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 1.0, 2.0, 2.0, 4.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); -tape( 'the function supports offset parameters', opts, function test( t ) { +tape( 'the function supports append without prepend', opts, function test( t ) { var expected; var out; var x; var p; var a; - var o; var w; - x = new Float64Array( [ 4.0, 8.0, 12.0, 16.0, 20.0 ] ); - p = new Float64Array( [ 10.0, 15.0, 25.0 ] ); - a = new Float64Array( [ 30.0, 35.0, 45.0 ] ); - o = new Float64Array( 6 ); - w = new Float64Array( 6 ); + // No prepend, x present, single append: + x = new Float64Array( [ 2.0, 5.0 ] ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 10.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); + + ddiff( x.length, 1, x, 1, 0, 0, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); + + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); + + // No prepend, no x, only append (N2=3): + x = new Float64Array( 0 ); + p = new Float64Array( 0 ); + a = new Float64Array( [ 1.0, 4.0, 9.0 ] ); + out = new Float64Array( 2 ); + w = new Float64Array( 2 ); - out = ddiff( 3, 1, x, 1, 2, 1, p, 1, 2, 1, a, 1, 2, o, 1, 2, w, 1, 2 ); - expected = new Float64Array([ - 0.0, - 0.0, - -13, - 4, - 4, - 25 - ]); - t.deepEqual( o, expected, 'returns expected value' ); - t.strictEqual( out, o, 'return expected value' ); + ddiff( 0, 1, x, 1, 0, 0, p, 1, 0, 3, a, 1, 0, out, 1, 0, w, 1, 0 ); + expected = new Float64Array( [ 3.0, 5.0 ] ); + t.deepEqual( out, expected, 'returns expected value' ); t.end(); }); From 04a469440e31d97c07319763c585f46ef3ad4cc9 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 3 Apr 2026 20:31:27 +0500 Subject: [PATCH 14/35] 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 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - 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/ddiff/README.md | 63 ++++--- .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 9 +- .../blas/ext/base/ddiff/docs/types/index.d.ts | 4 +- .../blas/ext/base/ddiff/docs/types/test.ts | 58 +++---- .../blas/ext/base/ddiff/examples/c/example.c | 4 +- .../blas/ext/base/ddiff/examples/index.js | 3 +- .../include/stdlib/blas/ext/base/ddiff.h | 4 +- .../@stdlib/blas/ext/base/ddiff/lib/base.js | 154 ++++++++++++++++++ .../blas/ext/base/ddiff/lib/ddiff.native.js | 2 +- .../blas/ext/base/ddiff/lib/ndarray.js | 138 +--------------- .../blas/ext/base/ddiff/lib/ndarray.native.js | 2 +- .../@stdlib/blas/ext/base/ddiff/src/main.c | 116 +++++++------ 12 files changed, 289 insertions(+), 268 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index 4c03848d09c5..e6579382eeac 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -134,7 +134,7 @@ The function has the following additional parameters: - **offsetP**: starting index for `prepend`. - **offsetA**: starting index for `append`. - **offsetOut**: starting index for `out`. -- **offsetW**: starting index of `workspace`. +- **offsetW**: starting index for `workspace`. 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: @@ -194,11 +194,10 @@ var a = discreteUniform( 2, -100, 100, { console.log( 'Append array: ', a ); var out = new Float64Array( 10 ); - var w = new Float64Array( 13 ); ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, out, 1, w, 1 ); -console.log( 'Output', out ); +console.log( 'Output: ', out ); ``` @@ -233,7 +232,7 @@ console.log( 'Output', out ); -#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*prepend, strideP, N2, \*append, strideA, \*Out, strideOut, \*Workspace, strideW ) +#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*Prepend, strideP, N2, \*Append, strideA, \*Out, strideOut, \*Workspace, strideW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. @@ -252,25 +251,25 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. - **X**: `[in] double*` input array. -- **strideX**: `[in] CBLAS_INT` stride length for `x`. -- **N1**: `[in] CBLAS_INT` number of elements in `prepend`. -- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. -- **N2**: `[in] CBLAS_INT` number of elements in `append`. -- **append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `append`. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **N1**: `[in] CBLAS_INT` number of elements in `Prepend`. +- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. +- **N2**: `[in] CBLAS_INT` number of elements in `Append`. +- **Append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `Append`. - **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `out`. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. - **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. +- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. ```c -void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); ``` -#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*prepend, strideP, offsetP, N2, \*append, strideA, offsetA, \*Out, strideOut, offsetOut, \*W, strideW, offsetW ) +#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*Prepend, strideP, offsetP, N2, \*Append, strideA, offsetA, \*Out, strideOut, offsetOut, \*W, strideW, offsetW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. @@ -289,25 +288,25 @@ The function accepts the following arguments: - **N**: `[in] CBLAS_INT` number of indexed elements. - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. - **X**: `[in] double*` input array. -- **strideX**: `[in] CBLAS_INT` stride length for `x`. -- **offsetX**: `[in] CBLAS_INT` starting index for `x`. -- **N1**: `[in] CBLAS_INT` number of elements in `prepend`. -- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. -- **offsetP**: `[in] CBLAS_INT` starting index for `prepend`. -- **N2**: `[in] CBLAS_INT` number of elements in `append`. -- **append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `append`. -- **offsetA**: `[in] CBLAS_INT` starting index for `append`. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. +- **N1**: `[in] CBLAS_INT` number of elements in `Prepend`. +- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. +- **offsetP**: `[in] CBLAS_INT` starting index for `Prepend`. +- **N2**: `[in] CBLAS_INT` number of elements in `Append`. +- **Append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `Append`. +- **offsetA**: `[in] CBLAS_INT` starting index for `Append`. - **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `out`. -- **offsetOut**: `[in] CBLAS_INT` starting index for `out`. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. - **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. -- **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. +- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. +- **offsetW**: `[in] CBLAS_INT` starting index for `Workspace`. ```c -void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` @@ -342,10 +341,10 @@ int main( void ) { // Define append values: const double a[] = { 10.0 }; - // Define output array: + // Define an output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Define workspace: + // Define a workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Compute forward differences: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 4a817f23503f..00d8714e745c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -1,4 +1,3 @@ - {{alias}}( N, k, x,sx, N1,p,sp, N2,a,sa, out,so, w,sw ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. @@ -44,13 +43,13 @@ Stride length for `append`. out: Float64Array - Output array. + Output array. Must have `N + N1 + N2 - k` elements. so: integer Stride length for `out`. w: Float64Array - Workspace array. + Workspace array. Must have `N + N1 + N2 - 1` elements. sw: integer Stride length for `workspace`. @@ -141,7 +140,7 @@ Starting index for `append`. out: Float64Array - Output array. + Output array. Must have `N + N1 + N2 - k` elements. so: integer Stride length for `out`. @@ -150,7 +149,7 @@ Starting index for `out`. w: Float64Array - Workspace array. + Workspace array. Must have `N + N1 + N2 - 1` elements. sw: integer Stride length for `workspace`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts index 67405c7ac7a3..330089611030 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts @@ -124,7 +124,7 @@ interface Routine { * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); * @@ -138,7 +138,7 @@ interface Routine { * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff.ndarray( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts index a5188f29ccf8..531bc0c6e667 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts @@ -157,7 +157,7 @@ import ddiff = require( './index' ); ddiff( x.length, 1, x, 1, 1, p, ( x: number ): number => x, 1, a, 1, out, 1, w, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided an eigth argument which is not a number... +// The compiler throws an error if the function is provided an eighth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -210,7 +210,7 @@ import ddiff = require( './index' ); ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, ( x: number ): number => x, out, 1, w, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided an eleventth argument which is not a Float64Array... +// The compiler throws an error if the function is provided an eleventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -227,7 +227,7 @@ import ddiff = require( './index' ); ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, ( x: number ): number => x, 1, w, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided a twelveth argument which is not a number... +// The compiler throws an error if the function is provided a twelfth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -406,7 +406,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, ( x: number ): number => x, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a Float64Array... +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -417,14 +417,14 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, '10', p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, true, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, false, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 1, null, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, null, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, undefined, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, [], p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, {}, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError ddiff.ndarray( x.length, 1, x, 1, 0, ( x: number ): number => x, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); const a = new Float64Array( 1 ); @@ -441,7 +441,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, ( x: number ): number => x, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided an eigth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -459,7 +459,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, ( x: number ): number => x, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a Float64Array... +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -467,14 +467,14 @@ import ddiff = require( './index' ); const out = new Float64Array( 11 ); const w = new Float64Array( 11 ); - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, '10', 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, true, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, false, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, null, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, undefined, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, [], 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, {}, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, ( x: number ): number => x, 1, a, 0, 1, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, '10', 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, true, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, false, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, null, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, undefined, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, [], 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, {}, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, ( x: number ): number => x, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... @@ -495,24 +495,24 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, ( x: number ): number => x, a, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided an eleventth argument which is not a Float64Array... +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); const out = new Float64Array( 11 ); const w = new Float64Array( 9 ); - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, '10', 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, true, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, false, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, null, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, undefined, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, [], 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, {}, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError - ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, ( x: number ): number => x, 1, 0, out, 0, 1, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, '10', 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, true, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, false, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, null, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, undefined, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, [], 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, {}, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError + ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, ( x: number ): number => x, 1, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a twelveth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -530,7 +530,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, ( x: number ): number => x, 0, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a Float64Array... +// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -548,7 +548,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, ( x: number ): number => x, out, 1, 0, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a Float64Array... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); @@ -601,7 +601,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, ( x: number ): number => x, w, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a seventeenth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a seventeenth argument which is not a Float64Array... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c index 0b6fe9dc54a1..457db7655bbf 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c @@ -29,10 +29,10 @@ int main( void ) { // Define append values: const double a[] = { 10.0 }; - // Define output array: + // Define an output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Define workspace: + // Define a workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Compute forward differences: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js index fe1c0280d3b0..65b98bd980e9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/index.js @@ -38,8 +38,7 @@ var a = discreteUniform( 2, -100, 100, { console.log( 'Append array: ', a ); var out = new Float64Array( 10 ); - var w = new Float64Array( 13 ); ddiff( x.length, 4, x, 1, 2, p, 1, 2, a, 1, out, 1, w, 1 ); -console.log( 'Output', out ); +console.log( 'Output: ', out ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h index d88c49ef05d0..25375da46c1b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h @@ -31,12 +31,12 @@ extern "C" { /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array. */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js new file mode 100644 index 000000000000..0995c93b8754 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js @@ -0,0 +1,154 @@ +/** +* @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'; + +// MAIN // + +/** +* Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* +* @private +* @param {PositiveInteger} N - number of indexed elements +* @param {Float64Array} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveInteger} offsetX - starting index for `x` +* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {Float64Array} prepend - prepend array +* @param {integer} strideP - stride length for `prepend` +* @param {PositiveInteger} offsetP - starting index for `prepend` +* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {Float64Array} append - append array +* @param {integer} strideA - stride length for `append` +* @param {PositiveInteger} offsetA - starting index for `append` +* @param {Float64Array} out - output array +* @param {integer} strideOut - stride length for `out` +* @param {PositiveInteger} offsetOut - starting index for `out` +* @returns {Float64Array} output array +*/ +function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { + var total; + var prev; + var curr; + var ix; + var io; + var ip; + var ia; + var i; + + total = N + N1 + N2; + if ( total <= 1 ) { + return out; + } + + if ( N1 === 0 && N2 === 0 ) { + ix = offsetX; + io = offsetOut; + prev = x[ ix ]; + for ( i = 1; i < N; i++ ) { + ix += strideX; + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + return out; + } + + // Prepend + if ( N1 > 0 ) { + io = offsetOut; + ip = offsetP; + prev = prepend[ ip ]; + for ( i = 1; i < N1; i++ ) { + ip += strideP; + curr = prepend[ ip ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + if ( N > 0 ) { + curr = x[ offsetX ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } else if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } else if ( N > 0 ) { + prev = x[ offsetX ]; + io = offsetOut; + } else { + prev = append[ offsetA ]; + io = offsetOut; + } + + // x + if ( N > 0 ) { + ix = offsetX; + if ( N1 === 0 ) { + prev = x[ ix ]; + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } else { + ix += strideX; + for ( i = 1; i < N; i++ ) { + curr = x[ ix ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ix += strideX; + } + } + if ( N2 > 0 ) { + curr = append[ offsetA ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + } + } + + // Append + if ( N2 > 0 ) { + ia = offsetA + strideA; + for ( i = 1; i < N2; i++ ) { + curr = append[ ia ]; + out[ io ] = curr - prev; + prev = curr; + io += strideOut; + ia += strideA; + } + } + return out; +} + + +// EXPORTS // + +module.exports = base; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js index 2001856b8e47..34ef7c7c42c4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js @@ -53,7 +53,7 @@ var addon = require( './../src/addon.node' ); * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 84825104bb29..b3f690f94070 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -22,136 +22,8 @@ // MODULES // -var dcopy = require( '@stdlib/blas/base/dcopy' ); - - -// FUNCTIONS // - -/** -* Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. -* -* @private -* @param {PositiveInteger} N - number of indexed elements -* @param {Float64Array} x - input array -* @param {integer} strideX - stride length for `x` -* @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend -* @param {Float64Array} prepend - prepend array -* @param {integer} strideP - stride length for `prepend` -* @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append -* @param {Float64Array} append - append array -* @param {integer} strideA - stride length for `append` -* @param {PositiveInteger} offsetA - starting index for `append` -* @param {Float64Array} out - output array -* @param {integer} strideOut - stride length for `out` -* @param {PositiveInteger} offsetOut - starting index for `out` -* @returns {Float64Array} output array -*/ -function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ) { - var total; - var prev; - var curr; - var ix; - var io; - var ip; - var ia; - var i; - - total = N + N1 + N2; - if ( total <= 1 ) { - return out; - } - - if ( N1 === 0 && N2 === 0 ) { - ix = offsetX; - io = offsetOut; - prev = x[ ix ]; - for ( i = 1; i < N; i++ ) { - ix += strideX; - curr = x[ ix ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - } - return out; - } - - // Prepend - if ( N1 > 0 ) { - io = offsetOut; - ip = offsetP; - prev = prepend[ ip ]; - for ( i = 1; i < N1; i++ ) { - ip += strideP; - curr = prepend[ ip ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - } - if ( N > 0 ) { - curr = x[ offsetX ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - } else if ( N2 > 0 ) { - curr = append[ offsetA ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - } - } else if ( N > 0 ) { - prev = x[ offsetX ]; - io = offsetOut; - } else { - prev = append[ offsetA ]; - io = offsetOut; - } - - // x - if ( N > 0 ) { - ix = offsetX; - if ( N1 === 0 ) { - prev = x[ ix ]; - ix += strideX; - for ( i = 1; i < N; i++ ) { - curr = x[ ix ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - ix += strideX; - } - } else { - ix += strideX; - for ( i = 1; i < N; i++ ) { - curr = x[ ix ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - ix += strideX; - } - } - if ( N2 > 0 ) { - curr = append[ offsetA ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - } - } - - // Append - if ( N2 > 0 ) { - ia = offsetA + strideA; - for ( i = 1; i < N2; i++ ) { - curr = append[ ia ]; - out[ io ] = curr - prev; - prev = curr; - io += strideOut; - ia += strideA; - } - } - return out; -} +var dcopy = require( '@stdlib/blas/base/dcopy' ).ndarray; +var base = require( './base.js' ); // MAIN // @@ -212,15 +84,15 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap if ( k === 0 ) { // Copy `prepend` into output array: - dcopy.ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + dcopy( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); // Copy `x` into output array: io = offsetOut + ( N1 * strideOut ); - dcopy.ndarray( N, x, strideX, offsetX, out, strideOut, io ); + dcopy( N, x, strideX, offsetX, out, strideOut, io ); // Copy `append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - dcopy.ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + dcopy( N2, append, strideA, offsetA, out, strideOut, io ); return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js index 130555f1c442..4853fdd67feb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js @@ -58,7 +58,7 @@ var addon = require( './../src/addon.node' ); * var p = new Float64Array( [ 1.0 ] ); * var a = new Float64Array( [ 22.0 ] ); * var out = new Float64Array( 5 ); -* var w = new Float64Array( 6 ) +* var w = new Float64Array( 6 ); * * ddiff( x.length, 2, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, w, 1, 0 ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 5248acbb6a7e..66a2455a0aff 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -26,49 +26,48 @@ * * @param N number of indexed elements * @param k number of times to recursively compute differences -* @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 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` +* @param strideOut stride length for Out * @param Workspace workspace array -* @param strideW stride length for `Workspace` +* @param strideW stride length for Workspace */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ) { +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ) { const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); - API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, Out, strideOut, oo, Workspace, strideW, ow ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, Prepend, strideP, op, N2, Append, strideA, oa, Out, strideOut, oo, Workspace, strideW, ow ); } /** * Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. * * @param N number of indexed elements -* @param k number of times to recursively compute differences -* @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 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` +* @param strideOut stride length for Out +* @param offsetOut starting index for Out */ -static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { +static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; double prev; double curr; @@ -83,7 +82,6 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * return; } - io = 0; if ( N1 == 0 && N2 == 0 ) { ix = offsetX; io = offsetOut; @@ -102,10 +100,10 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * if ( N1 > 0 ) { io = offsetOut; ip = offsetP; - prev = prepend[ ip ]; + prev = Prepend[ ip ]; for ( i = 1; i < N1; i++ ) { ip += strideP; - curr = prepend[ ip ]; + curr = Prepend[ ip ]; Out[ io ] = curr - prev; prev = curr; io += strideOut; @@ -116,7 +114,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * prev = curr; io += strideOut; } else if ( N2 > 0 ) { - curr = append[ offsetA ]; + curr = Append[ offsetA ]; Out[ io ] = curr - prev; prev = curr; io += strideOut; @@ -125,7 +123,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * prev = X[ offsetX ]; io = offsetOut; } else { - prev = append[ offsetA ]; + prev = Append[ offsetA ]; io = offsetOut; } @@ -153,7 +151,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * } } if ( N2 > 0 ) { - curr = append[ offsetA ]; + curr = Append[ offsetA ]; Out[ io ] = curr - prev; prev = curr; io += strideOut; @@ -164,7 +162,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * if ( N2 > 0 ) { ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { - curr = append[ ia ]; + curr = Append[ ia ]; Out[ io ] = curr - prev; prev = curr; io += strideOut; @@ -179,25 +177,25 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * * * @param N number of indexed elements * @param k number of times to recursively compute differences -* @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 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` +* @param strideOut stride length for Out +* @param offsetOut starting index for Out * @param Workspace workspace array -* @param strideW stride length for `Workspace` -* @param offsetW starting index for `Workspace` +* @param strideW stride length for Workspace +* @param offsetW starting index for Workspace */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; CBLAS_INT io; CBLAS_INT n; @@ -209,32 +207,32 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN } if ( k == 0 ) { - // Copy `prepend` into output array: - c_dcopy_ndarray( N1, prepend, strideP, offsetP, Out, strideOut, offsetOut ); + // Copy `Prepend` into output array: + c_dcopy_ndarray( N1, Prepend, strideP, offsetP, Out, strideOut, offsetOut ); - // Copy `x` into output array: + // Copy `X` into output array: io = offsetOut + ( N1 * strideOut ); c_dcopy_ndarray( N, X, strideX, offsetX, Out, strideOut, io ); - // Copy `append` into output array: + // Copy `Append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - c_dcopy_ndarray( N2, append, strideA, offsetA, Out, strideOut, io ); + c_dcopy_ndarray( N2, Append, strideA, offsetA, Out, strideOut, io ); return; } if ( k == 1 ) { - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, Out, strideOut, offsetOut ); + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Out, strideOut, offsetOut ); return; } - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, Workspace, strideW, offsetW ); + stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Workspace, strideW, offsetW ); n = total - 1; for ( i = 1; i < k - 1; i++ ) { - stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, Workspace, strideW, offsetW ); + stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Workspace, strideW, offsetW ); n -= 1; } - stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, Out, strideOut, offsetOut ); + stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Out, strideOut, offsetOut ); return; } From dd84fbc1dc5908a9f2b851151dd5b16133192849 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Fri, 3 Apr 2026 20:46:40 +0500 Subject: [PATCH 15/35] 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 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: missing_dependencies - 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 --- --- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index b3f690f94070..818955086b19 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -77,7 +77,7 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap return out; } - // If k >= total number of elements, the k-th forward difference results in an empty array, so this function is a no-op. + // If k >= total number of elements, the k-th forward difference results in an empty array, so this function is a no-op... if ( k >= total ) { return out; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 66a2455a0aff..9821c227cd5b 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -202,6 +202,8 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN CBLAS_INT i; total = N + N1 + N2; + + // If k >= total number of elements, the k-th forward difference results in an empty array, so this function is a no-op... if ( total <= 1 || k >= total ) { return; } From 613fee5354d979909db899815172a09d74f815ab Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 19:33:58 -0700 Subject: [PATCH 16/35] refactor: reduce code duplication and add comments Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/ndarray.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 818955086b19..c2edbf18b3e6 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -76,12 +76,11 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap if ( total <= 1 ) { return out; } - - // If k >= total number of elements, the k-th forward difference results in an empty array, so this function is a no-op... + // If `k` is greater than or equal to the total number of elements, the k-th forward difference results in an empty array, so this function is a no-op... if ( k >= total ) { return out; } - + // If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array... if ( k === 0 ) { // Copy `prepend` into output array: dcopy( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); @@ -96,21 +95,22 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap return out; } + // Compute the first forward difference: + base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + // If `k` is one, we're finished... if ( k === 1 ) { - base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); return out; } - - base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); - + // Otherwise, recursively compute forward differences... n = total - 1; - for ( i = 1; i < k - 1; i++ ) { + for ( i = 1; i < k-1; i++ ) { base( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); n -= 1; } - + // For the last forward difference, ensure that results are written to the output array: base( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); + return out; } From 5bc564420599b41680705537e5a48d1a01de3397 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 19:36:19 -0700 Subject: [PATCH 17/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js | 4 ++-- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js index 34ef7c7c42c4..21cd2d8db33c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.native.js @@ -34,10 +34,10 @@ var addon = require( './../src/addon.node' ); * @param {PositiveInteger} k - number of times to recursively compute differences * @param {Float64Array} 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 for `prepend` * @param {Float64Array} 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 for `append` * @param {Float64Array} append - append array * @param {integer} strideA - stride length for `append` * @param {Float64Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index c2edbf18b3e6..3e5df0ee522c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -36,11 +36,11 @@ var base = require( './base.js' ); * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} N1 - number of indexed elements for `prepend` * @param {Float64Array} prepend - prepend array * @param {integer} strideP - stride length for `prepend` * @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} N2 - number of indexed elements for `append` * @param {Float64Array} append - append array * @param {integer} strideA - stride length for `append` * @param {PositiveInteger} offsetA - starting index for `append` From 456c789b8bd488e57f619002e5595e11747bfe65 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 20:49:06 -0700 Subject: [PATCH 18/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/base.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js index 0995c93b8754..1979b84b0ba1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js @@ -57,7 +57,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append if ( total <= 1 ) { return out; } - + // Calculate the forward difference over the input array... if ( N1 === 0 && N2 === 0 ) { ix = offsetX; io = offsetOut; @@ -71,8 +71,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append } return out; } - - // Prepend + // Calculate the forward difference over the list of prepended values... if ( N1 > 0 ) { io = offsetOut; ip = offsetP; @@ -102,8 +101,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append prev = append[ offsetA ]; io = offsetOut; } - - // x + // Calculate the forward difference over the input array... if ( N > 0 ) { ix = offsetX; if ( N1 === 0 ) { @@ -133,8 +131,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append io += strideOut; } } - - // Append + // Calculate the forward difference over the list of appended values... if ( N2 > 0 ) { ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { From f3e46f2bf0ce7b1b55db73037c516526a665019e Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 20:50:22 -0700 Subject: [PATCH 19/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js index 1979b84b0ba1..51bc294364d7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js @@ -23,18 +23,18 @@ // MAIN // /** -* Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. +* Calculates the forward difference of a double-precision floating-point strided array. * * @private * @param {PositiveInteger} N - number of indexed elements * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} N1 - number of indexed elements for `prepend` * @param {Float64Array} prepend - prepend array * @param {integer} strideP - stride length for `prepend` * @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} N2 - number of indexed elements for `append` * @param {Float64Array} append - append array * @param {integer} strideA - stride length for `append` * @param {PositiveInteger} offsetA - starting index for `append` From c54a447ea5e237c5c9d14458aad0cf1275dc995e Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 20:54:57 -0700 Subject: [PATCH 20/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/ndarray.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 3e5df0ee522c..929ae1a06c8e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -95,14 +95,15 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap return out; } - // Compute the first forward difference: - base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); - - // If `k` is one, we're finished... + // If `k` is equal to one, we can compute the forward difference while writing directly to the output array... if ( k === 1 ) { + base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); return out; } - // Otherwise, recursively compute forward differences... + // Compute the first forward difference: + base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + + // Recursively compute the next forward differences... n = total - 1; for ( i = 1; i < k-1; i++ ) { base( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); From 9a763a7dfe838981553ab026070e2dae6bb5a737 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 20:58:50 -0700 Subject: [PATCH 21/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index 929ae1a06c8e..c416f03a2f88 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -73,11 +73,9 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap var i; total = N + N1 + N2; - if ( total <= 1 ) { - return out; - } + // If `k` is greater than or equal to the total number of elements, the k-th forward difference results in an empty array, so this function is a no-op... - if ( k >= total ) { + if ( total <= 1 || k >= total ) { return out; } // If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array... From e5a93f56d7d8671e077ddc3414181c44d32162dd Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 21:00:29 -0700 Subject: [PATCH 22/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js index 4853fdd67feb..3194a1c358b3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js @@ -35,11 +35,11 @@ var addon = require( './../src/addon.node' ); * @param {Float64Array} x - input array * @param {integer} strideX - stride length for `x` * @param {PositiveInteger} offsetX - starting index for `x` -* @param {PositiveInteger} N1 - number of indexed elements of prepend +* @param {PositiveInteger} N1 - number of indexed elements for `prepend` * @param {Float64Array} prepend - prepend array * @param {integer} strideP - stride length for `prepend` * @param {PositiveInteger} offsetP - starting index for `prepend` -* @param {PositiveInteger} N2 - number of indexed elements of append +* @param {PositiveInteger} N2 - number of indexed elements for `append` * @param {Float64Array} append - append array * @param {integer} strideA - stride length for `append` * @param {PositiveInteger} offsetA - starting index for `append` From cdb8c38a904dde60e5e72da35bcf296cb87d2a59 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 21:01:36 -0700 Subject: [PATCH 23/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js index 3194a1c358b3..326b78c3393d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.native.js @@ -28,7 +28,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. * * @param {PositiveInteger} N - number of indexed elements * @param {PositiveInteger} k - number of times to recursively compute differences From 4049ecfa347d3dac05fdb64726270ab6c8147b63 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 6 Apr 2026 21:04:38 -0700 Subject: [PATCH 24/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 9821c227cd5b..a111a44fdcb8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -69,13 +69,13 @@ void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, con */ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; - double prev; - double curr; CBLAS_INT ix; CBLAS_INT ip; CBLAS_INT ia; CBLAS_INT io; CBLAS_INT i; + double prev; + double curr; total = N + N1 + N2; if ( total <= 1 ) { From 7e836acce58e321464ee6bfb6c8621c7fbedbdb1 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 8 Apr 2026 02:04:04 +0500 Subject: [PATCH 25/35] 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 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: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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/ddiff/README.md | 66 +++---- .../ext/base/ddiff/benchmark/benchmark.js | 2 +- .../base/ddiff/benchmark/benchmark.native.js | 2 +- .../base/ddiff/benchmark/benchmark.ndarray.js | 2 +- .../benchmark/benchmark.ndarray.native.js | 2 +- .../base/ddiff/benchmark/c/benchmark.length.c | 4 +- .../@stdlib/blas/ext/base/ddiff/docs/repl.txt | 10 +- .../blas/ext/base/ddiff/docs/types/index.d.ts | 27 ++- .../blas/ext/base/ddiff/examples/c/example.c | 8 +- .../include/stdlib/blas/ext/base/ddiff.h | 4 +- .../@stdlib/blas/ext/base/ddiff/lib/ddiff.js | 4 +- .../blas/ext/base/ddiff/lib/ndarray.js | 2 +- .../@stdlib/blas/ext/base/ddiff/src/main.c | 174 +++++++++--------- 13 files changed, 161 insertions(+), 146 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index e6579382eeac..2f6d1e60bc9d 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -57,10 +57,10 @@ The function has the following parameters: - **k**: number of times to recursively compute differences. - **x**: input [`Float64Array`][@stdlib/array/float64]. - **strideX**: stride length for `x`. -- **N1**: number of elements to `prepend`. +- **N1**: number of indexed elements to `prepend`. - **prepend**: a [`Float64Array`][@stdlib/array/float64] containing values to prepend prior to computing differences. - **strideP**: stride length for `prepend`. -- **N2**: number of elements to `append`. +- **N2**: number of indexed elements to `append`. - **append**: a [`Float64Array`][@stdlib/array/float64] containing values to append prior to computing differences. - **strideA**: stride length for `append`. - **out**: output [`Float64Array`][@stdlib/array/float64]. Must have `N + N1 + N2 - k` elements. @@ -136,7 +136,7 @@ The function has the following additional parameters: - **offsetOut**: starting index for `out`. - **offsetW**: starting index for `workspace`. -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, the offset parameters support indexing semantics based on starting indices. For example, to access only the last three elements: ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -232,7 +232,7 @@ console.log( 'Output: ', out ); -#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*Prepend, strideP, N2, \*Append, strideA, \*Out, strideOut, \*Workspace, strideW ) +#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*prepend, strideP, N2, \*append, strideA, \*out, strideOut, \*workspace, strideW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. @@ -252,24 +252,24 @@ The function accepts the following arguments: - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **N1**: `[in] CBLAS_INT` number of elements in `Prepend`. -- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. -- **N2**: `[in] CBLAS_INT` number of elements in `Append`. -- **Append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `Append`. -- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. -- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. +- **N1**: `[in] CBLAS_INT` number of indexed elements for `prepend`. +- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. +- **N2**: `[in] CBLAS_INT` number of indexed elements for `append`. +- **append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `append`. +- **out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **strideOut**: `[in] CBLAS_INT` stride length for `out`. +- **workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. ```c -void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); ``` -#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*Prepend, strideP, offsetP, N2, \*Append, strideA, offsetA, \*Out, strideOut, offsetOut, \*W, strideW, offsetW ) +#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*prepend, strideP, offsetP, N2, \*append, strideA, offsetA, \*out, strideOut, offsetOut, \*workspace, strideW, offsetW ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. @@ -290,23 +290,23 @@ The function accepts the following arguments: - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **N1**: `[in] CBLAS_INT` number of elements in `Prepend`. -- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. -- **offsetP**: `[in] CBLAS_INT` starting index for `Prepend`. -- **N2**: `[in] CBLAS_INT` number of elements in `Append`. -- **Append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `Append`. -- **offsetA**: `[in] CBLAS_INT` starting index for `Append`. -- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. -- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. -- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. -- **offsetW**: `[in] CBLAS_INT` starting index for `Workspace`. +- **N1**: `[in] CBLAS_INT` number of indexed elements for `prepend`. +- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. +- **offsetP**: `[in] CBLAS_INT` starting index for `prepend`. +- **N2**: `[in] CBLAS_INT` number of indexed elements for `append`. +- **append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `append`. +- **offsetA**: `[in] CBLAS_INT` starting index for `append`. +- **out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **strideOut**: `[in] CBLAS_INT` stride length for `out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `out`. +- **workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. +- **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. ```c -void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` @@ -335,10 +335,10 @@ int main( void ) { // Create a strided array: const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - // Define prepend values: + // Define a list of values to prepend: const double p[] = { -1.0 }; - // Define append values: + // Define a list of values to append: const double a[] = { 10.0 }; // Define an output array: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js index 410abdcfc8c9..d80913877e2a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.js @@ -61,7 +61,7 @@ function createBenchmark( len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; x = uniform( N, -100, 100, options ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js index 2af38abe472a..c194ec52fcbd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.native.js @@ -66,7 +66,7 @@ function createBenchmark( len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; x = uniform( N, -100, 100, options ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js index 6da61d94c29e..61f428f7cb4e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.js @@ -61,7 +61,7 @@ function createBenchmark( len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; x = uniform( N, -100, 100, options ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js index 3ef25a13da0b..cedfc2b3bea3 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/benchmark.ndarray.native.js @@ -66,7 +66,7 @@ function createBenchmark( len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; x = uniform( N, -100, 100, options ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c index d44fbc873fa0..631d37da43e1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/benchmark/c/benchmark.length.c @@ -113,7 +113,7 @@ static double benchmark1( int iterations, int len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; wl = N + N1 + N2 - 1; @@ -185,7 +185,7 @@ static double benchmark2( int iterations, int len ) { N = len; N1 = 1; N2 = 1; - k = 1; // worst case: N + N1 + N2 - 1 + k = 1; ol = N + N1 + N2 - k; wl = N + N1 + N2 - 1; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 00d8714e745c..0e9264eb791a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -43,13 +43,13 @@ Stride length for `append`. out: Float64Array - Output array. Must have `N + N1 + N2 - k` elements. + Output array. Must have `N + N1 + N2 - k` indexed elements. so: integer Stride length for `out`. w: Float64Array - Workspace array. Must have `N + N1 + N2 - 1` elements. + Workspace array. Must have `N + N1 + N2 - 1` indexed elements. sw: integer Stride length for `workspace`. @@ -90,7 +90,7 @@ [ 3.0, 2.0, 2.0, 2.0, 1.0 ] -{{alias}}.ndarray( N, k, x,sx,ox, N1,p,sp,op, N2,a,sa,oa, out,so,oo, w,sw,ow ) +{{alias}}.ndarray( N, k, x,sx,ox, N1, p,sp,op, N2, a,sa,oa, out,so,oo, w,sw,ow ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. @@ -140,7 +140,7 @@ Starting index for `append`. out: Float64Array - Output array. Must have `N + N1 + N2 - k` elements. + Output array. Must have `N + N1 + N2 - k` indexed elements. so: integer Stride length for `out`. @@ -149,7 +149,7 @@ Starting index for `out`. w: Float64Array - Workspace array. Must have `N + N1 + N2 - 1` elements. + Workspace array. Must have `N + N1 + N2 - 1` indexed elements. sw: integer Stride length for `workspace`. diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts index 330089611030..65431be2ec3a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts @@ -29,10 +29,10 @@ interface Routine { * @param k - number of times to recursively compute differences * @param x - input array * @param strideX - stride length for `x` - * @param N1 - number of indexed elements of prepend + * @param N1 - number of indexed elements for `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 for `append` * @param append - append array * @param strideA - stride length for `append` * @param out - output array @@ -41,6 +41,11 @@ interface Routine { * @param strideW - stride length for `workspace` * @returns output array * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - k` elements. + * - The `workspace` array must have `N + N1 + N2 - 1` elements. + * * @example * var Float64Array = require( '@stdlib/array/float64' ); * @@ -65,11 +70,11 @@ interface Routine { * @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 for `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 for `append` * @param append - append array * @param strideA - stride length for `append` * @param offsetA - starting index for `append` @@ -81,6 +86,11 @@ interface Routine { * @param offsetW - starting index for `workspace` * @returns output array * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - k` elements. + * - The `workspace` array must have `N + N1 + N2 - 1` elements. + * * @example * var Float64Array = require( '@stdlib/array/float64' ); * @@ -105,10 +115,10 @@ interface Routine { * @param k - number of times to recursively compute differences * @param x - input array * @param strideX - stride length for `x` -* @param N1 - number of indexed elements of prepend +* @param N1 - number of indexed elements for `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 for `append` * @param append - append array * @param strideA - stride length for `append` * @param out - output array @@ -117,6 +127,11 @@ interface Routine { * @param strideW - stride length for `workspace` * @returns output array * +* ## Notes +* +* - The `out` array must have `N + N1 + N2 - k` elements. +* - The `workspace` array must have `N + N1 + N2 - 1` elements. +* * @example * var Float64Array = require( '@stdlib/array/float64' ); * diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c index 457db7655bbf..5f9360d0b304 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c @@ -23,16 +23,16 @@ int main( void ) { // Create a strided array: const double x[] = { 1.0, -2.0, 3.0, -4.0, 5.0, -6.0, 7.0, -8.0 }; - // Define prepend values: + // Define a list of values to prepend: const double p[] = { -1.0 }; - // Define append values: + // Define a list of values to append: const double a[] = { 10.0 }; - // Define an output array: + // Define the output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Define a workspace: + // Define the workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Compute forward differences: diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h index 25375da46c1b..255b86ba2bf4 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h @@ -31,12 +31,12 @@ extern "C" { /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array. */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); /** * Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js index b93804217308..63e370c5f6c2 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ddiff.js @@ -35,10 +35,10 @@ var ndarray = require( './ndarray.js' ); * @param {PositiveInteger} k - number of times to recursively compute differences * @param {Float64Array} 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 for `prepend` * @param {Float64Array} 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 for `append` * @param {Float64Array} append - append array * @param {integer} strideA - stride length for `append` * @param {Float64Array} out - output array diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js index c416f03a2f88..e442f8aa56c9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/ndarray.js @@ -100,7 +100,7 @@ function ddiff( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, ap } // Compute the first forward difference: base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); - + // Recursively compute the next forward differences... n = total - 1; for ( i = 1; i < k-1; i++ ) { diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index a111a44fdcb8..65da5af602e1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -21,53 +21,27 @@ #include "stdlib/blas/base/dcopy.h" #include "stdlib/blas/base/shared.h" -/** -* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. -* -* @param N number of indexed elements -* @param k number of times to recursively compute differences -* @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 -* @param Workspace workspace array -* @param strideW stride length for Workspace -*/ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ) { - const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); - const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); - const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); - const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); - const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); - API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, Prepend, strideP, op, N2, Append, strideA, oa, Out, strideOut, oo, Workspace, strideW, ow ); -} - /** * Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. * +* @private * @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 +* @param N1 number of indexed elements for prepend +* @param prepend prepend array +* @param strideP stride length for prepend +* @param offsetP starting index for prepend +* @param N2 number of indexed elements for 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 */ -static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { +static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; CBLAS_INT ix; CBLAS_INT ip; @@ -81,7 +55,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * if ( total <= 1 ) { return; } - + // Calculate the forward difference over the input array... if ( N1 == 0 && N2 == 0 ) { ix = offsetX; io = offsetOut; @@ -89,33 +63,32 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * for ( i = 1; i < N; i++ ) { ix += strideX; curr = X[ ix ]; - Out[ io ] = curr - prev; + out[ io ] = curr - prev; prev = curr; io += strideOut; } return; } - - // Prepend + // Calculate the forward difference over the list of prepended values... if ( N1 > 0 ) { io = offsetOut; ip = offsetP; - prev = Prepend[ ip ]; + prev = prepend[ ip ]; for ( i = 1; i < N1; i++ ) { ip += strideP; - curr = Prepend[ ip ]; - Out[ io ] = curr - prev; + curr = prepend[ ip ]; + out[ io ] = curr - prev; prev = curr; io += strideOut; } if ( N > 0 ) { curr = X[ offsetX ]; - Out[ io ] = curr - prev; + out[ io ] = curr - prev; prev = curr; io += strideOut; } else if ( N2 > 0 ) { - curr = Append[ offsetA ]; - Out[ io ] = curr - prev; + curr = append[ offsetA ]; + out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -123,11 +96,10 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * prev = X[ offsetX ]; io = offsetOut; } else { - prev = Append[ offsetA ]; + prev = append[ offsetA ]; io = offsetOut; } - - // x + // Calculate the forward difference over the input array... if ( N > 0 ) { ix = offsetX; if ( N1 == 0 ) { @@ -135,7 +107,7 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - Out[ io ] = curr - prev; + out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; @@ -144,26 +116,25 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - Out[ io ] = curr - prev; + out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; } } if ( N2 > 0 ) { - curr = Append[ offsetA ]; - Out[ io ] = curr - prev; + curr = append[ offsetA ]; + out[ io ] = curr - prev; prev = curr; io += strideOut; } } - - // Append + // Calculate the forward difference over the list of appended values... if ( N2 > 0 ) { ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { - curr = Append[ ia ]; - Out[ io ] = curr - prev; + curr = append[ ia ]; + out[ io ] = curr - prev; prev = curr; io += strideOut; ia += strideA; @@ -172,6 +143,33 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * return; } +/** +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. +* +* @param N number of indexed elements +* @param k number of times to recursively compute differences +* @param X input array +* @param strideX stride length for X +* @param N1 number of indexed elements for prepend +* @param prepend prepend array +* @param strideP stride length for prepend +* @param N2 number of indexed elements for append +* @param append append array +* @param strideA stride length for append +* @param out output array +* @param strideOut stride length for out +* @param workspace workspace array +* @param strideW stride length for workspace +*/ +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); + const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); + const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); + const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo, workspace, strideW, ow ); +} + /** * Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. * @@ -180,22 +178,22 @@ static void stdlib_strided_base_ddiff_ndarray( const CBLAS_INT N, const double * * @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 -* @param Workspace workspace array -* @param strideW stride length for Workspace -* @param offsetW starting index for Workspace +* @param N1 number of indexed elements for prepend +* @param prepend prepend array +* @param strideP stride length for prepend +* @param offsetP starting index for prepend +* @param N2 number of indexed elements for 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 +* @param workspace workspace array +* @param strideW stride length for workspace +* @param offsetW starting index for workspace */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; CBLAS_INT io; CBLAS_INT n; @@ -207,34 +205,36 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN if ( total <= 1 || k >= total ) { return; } - + // If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array... if ( k == 0 ) { - // Copy `Prepend` into output array: - c_dcopy_ndarray( N1, Prepend, strideP, offsetP, Out, strideOut, offsetOut ); + // Copy `prepend` into output array: + c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); // Copy `X` into output array: io = offsetOut + ( N1 * strideOut ); - c_dcopy_ndarray( N, X, strideX, offsetX, Out, strideOut, io ); + c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, io ); - // Copy `Append` into output array: + // Copy `append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - c_dcopy_ndarray( N2, Append, strideA, offsetA, Out, strideOut, io ); + c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io ); return; } - + // If `k` is equal to one, we can compute the forward difference while writing directly to the output array... if ( k == 1 ) { - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Out, strideOut, offsetOut ); + stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); return; } + // Compute the first forward difference: + stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); - stdlib_strided_base_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Workspace, strideW, offsetW ); - + // Recursively compute the next forward differences... n = total - 1; for ( i = 1; i < k - 1; i++ ) { - stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Workspace, strideW, offsetW ); + stdlib_strided_internal_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); n -= 1; } - stdlib_strided_base_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Out, strideOut, offsetOut ); + // For the last forward difference, ensure that results are written to the output array: + stdlib_strided_internal_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); return; } From 7e103e663cee0c53d00ebc91d7f135fb52458d56 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 8 Apr 2026 02:20:41 +0500 Subject: [PATCH 26/35] 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - 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 --- --- lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index 0e9264eb791a..bbf8bd447088 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -1,3 +1,4 @@ + {{alias}}( N, k, x,sx, N1,p,sp, N2,a,sa, out,so, w,sw ) Calculates the k-th discrete forward differences of a double-precision floating-point strided array. From cfd7e0859a7428621e77c3e18b6f1a9470305c43 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 8 Apr 2026 02:40:14 +0500 Subject: [PATCH 27/35] 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 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 --- --- lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js index 51bc294364d7..4524031e3140 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/lib/base.js @@ -57,7 +57,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append if ( total <= 1 ) { return out; } - // Calculate the forward difference over the input array... + // Compute forward differences: if ( N1 === 0 && N2 === 0 ) { ix = offsetX; io = offsetOut; @@ -71,7 +71,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append } return out; } - // Calculate the forward difference over the list of prepended values... + // Compute forward differences over the list of prepended values: if ( N1 > 0 ) { io = offsetOut; ip = offsetP; @@ -101,7 +101,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append prev = append[ offsetA ]; io = offsetOut; } - // Calculate the forward difference over the input array... + // Compute forward differences over the input array: if ( N > 0 ) { ix = offsetX; if ( N1 === 0 ) { @@ -131,7 +131,7 @@ function base( N, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append io += strideOut; } } - // Calculate the forward difference over the list of appended values... + // Compute forward differences over the list of appended values: if ( N2 > 0 ) { ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { From bcdc53dfa38001444187433357164fdfb9e1d202 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 20:40:48 -0700 Subject: [PATCH 28/35] docs: update comment Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/examples/c/example.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c index 5f9360d0b304..b4c8afcab6ad 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/examples/c/example.c @@ -32,7 +32,7 @@ int main( void ) { // Define the output array: double out[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; - // Define the workspace: + // Define a workspace: double w[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; // Compute forward differences: From c2edbea3553946e5ecfb643648004d5c692d265e Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 20:44:44 -0700 Subject: [PATCH 29/35] docs: fix notes placement Signed-off-by: Athan --- .../blas/ext/base/ddiff/docs/types/index.d.ts | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts index 65431be2ec3a..37810a76306e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/index.d.ts @@ -25,6 +25,11 @@ interface Routine { /** * Calculates the k-th discrete forward difference of a double-precision floating-point strided array. * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - k` elements. + * - The `workspace` array must have `N + N1 + N2 - 1` elements. + * * @param N - number of indexed elements * @param k - number of times to recursively compute differences * @param x - input array @@ -41,11 +46,6 @@ interface Routine { * @param strideW - stride length for `workspace` * @returns output array * - * ## Notes - * - * - The `out` array must have `N + N1 + N2 - k` elements. - * - The `workspace` array must have `N + N1 + N2 - 1` elements. - * * @example * var Float64Array = require( '@stdlib/array/float64' ); * @@ -65,6 +65,11 @@ interface Routine { /** * Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. * + * ## Notes + * + * - The `out` array must have `N + N1 + N2 - k` elements. + * - The `workspace` array must have `N + N1 + N2 - 1` elements. + * * @param N - number of indexed elements * @param k - number of times to recursively compute differences * @param x - input array @@ -86,11 +91,6 @@ interface Routine { * @param offsetW - starting index for `workspace` * @returns output array * - * ## Notes - * - * - The `out` array must have `N + N1 + N2 - k` elements. - * - The `workspace` array must have `N + N1 + N2 - 1` elements. - * * @example * var Float64Array = require( '@stdlib/array/float64' ); * @@ -111,6 +111,11 @@ interface Routine { /** * Calculates the k-th discrete forward difference of a double-precision floating-point strided array. * +* ## Notes +* +* - The `out` array must have `N + N1 + N2 - k` elements. +* - The `workspace` array must have `N + N1 + N2 - 1` elements. +* * @param N - number of indexed elements * @param k - number of times to recursively compute differences * @param x - input array @@ -127,11 +132,6 @@ interface Routine { * @param strideW - stride length for `workspace` * @returns output array * -* ## Notes -* -* - The `out` array must have `N + N1 + N2 - k` elements. -* - The `workspace` array must have `N + N1 + N2 - 1` elements. -* * @example * var Float64Array = require( '@stdlib/array/float64' ); * From 7c084ef5332e80b08fd72480a3a0f748bb95d945 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 21:08:13 -0700 Subject: [PATCH 30/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/README.md | 9 +++++---- .../blas/ext/base/ddiff/docs/types/test.ts | 16 ++++++++-------- .../ddiff/include/stdlib/blas/ext/base/ddiff.h | 8 ++++---- .../@stdlib/blas/ext/base/ddiff/src/main.c | 1 - 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index 2f6d1e60bc9d..805621c0cabb 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -34,7 +34,7 @@ var ddiff = require( '@stdlib/blas/ext/base/ddiff' ); #### ddiff( N, k, x, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ) -Calculates the k-th discrete forward differences of a double-precision floating-point strided array. +Calculates the k-th discrete forward difference of a double-precision floating-point strided array. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -111,7 +111,7 @@ console.log( out ); #### ddiff.ndarray( N, k, x, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ) -Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. +Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -161,6 +161,7 @@ console.log( out ); ## Notes +- When `k <= 1`, the workspace array is unused and thus ignored. - If `N <= 0`, both functions return the output array unchanged. @@ -234,7 +235,7 @@ console.log( 'Output: ', out ); #### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*prepend, strideP, N2, \*append, strideA, \*out, strideOut, \*workspace, strideW ) -Calculates the k-th discrete forward differences of a double-precision floating-point strided array. +Calculates the k-th discrete forward difference of a double-precision floating-point strided array. ```c const double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; @@ -271,7 +272,7 @@ void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X #### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*prepend, strideP, offsetP, N2, \*append, strideA, offsetA, \*out, strideOut, offsetOut, \*workspace, strideW, offsetW ) -Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. +Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. ```c const double x[] = { 2.0, 4.0, 6.0, 8.0, 10.0 }; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts index 531bc0c6e667..6897696c709e 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts @@ -40,14 +40,14 @@ import ddiff = require( './index' ); const out = new Float64Array( 11 ); const w = new Float64Array( 11 ); - ddiff( '10', 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( true, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( false, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( null, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( undefined, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( [], 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( {}, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError - ddiff( ( x: number ): number => x, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( '10', 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( true, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( false, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( null, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( undefined, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( [], 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( {}, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError + ddiff( ( x: number ): number => x, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a number... diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h index 255b86ba2bf4..d35d8c83e1f1 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/include/stdlib/blas/ext/base/ddiff.h @@ -29,14 +29,14 @@ extern "C" { #endif /** -* Calculates the k-th discrete forward differences of a double-precision floating-point strided array. +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array. */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); /** -* Calculates the k-th discrete forward differences of a double-precision floating-point strided array using alternative indexing semantics. +* Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); #ifdef __cplusplus diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 65da5af602e1..43834953875c 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -24,7 +24,6 @@ /** * Calculates the forward difference of a double-precision floating-point strided array using alternative indexing semantics. * -* @private * @param N number of indexed elements * @param X input array * @param strideX stride length for X From 68da62189ad741fecc8d1193ec9df4a4a40e2af8 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 21:11:50 -0700 Subject: [PATCH 31/35] docs: update signatures Signed-off-by: Athan --- .../@stdlib/blas/ext/base/ddiff/README.md | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index 805621c0cabb..d6da901fcbd5 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -233,7 +233,7 @@ console.log( 'Output: ', out ); -#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*prepend, strideP, N2, \*append, strideA, \*out, strideOut, \*workspace, strideW ) +#### stdlib_strided_ddiff( N, k, \*X, strideX, N1, \*Prepend, strideP, N2, \*Append, strideA, \*Out, strideOut, \*Workspace, strideW ) Calculates the k-th discrete forward difference of a double-precision floating-point strided array. @@ -253,24 +253,24 @@ The function accepts the following arguments: - **k**: `[in] CBLAS_INT` number of times to recursively compute differences. - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. -- **N1**: `[in] CBLAS_INT` number of indexed elements for `prepend`. -- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. -- **N2**: `[in] CBLAS_INT` number of indexed elements for `append`. -- **append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `append`. -- **out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `out`. -- **workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. +- **N1**: `[in] CBLAS_INT` number of indexed elements for `Prepend`. +- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. +- **N2**: `[in] CBLAS_INT` number of indexed elements for `Append`. +- **Append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `Append`. +- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. ```c -void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ); +void stdlib_strided_ddiff( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ); ``` -#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*prepend, strideP, offsetP, N2, \*append, strideA, offsetA, \*out, strideOut, offsetOut, \*workspace, strideW, offsetW ) +#### stdlib_strided_ddiff_ndarray( N, k, \*X, strideX, offsetX, N1, \*Prepend, strideP, offsetP, N2, \*Append, strideA, offsetA, \*Out, strideOut, offsetOut, \*Workspace, strideW, offsetW ) Calculates the k-th discrete forward difference of a double-precision floating-point strided array using alternative indexing semantics. @@ -291,23 +291,23 @@ The function accepts the following arguments: - **X**: `[in] double*` input array. - **strideX**: `[in] CBLAS_INT` stride length for `X`. - **offsetX**: `[in] CBLAS_INT` starting index for `X`. -- **N1**: `[in] CBLAS_INT` number of indexed elements for `prepend`. -- **prepend**: `[in] double*` array containing values to prepend prior to computing differences. -- **strideP**: `[in] CBLAS_INT` stride length for `prepend`. -- **offsetP**: `[in] CBLAS_INT` starting index for `prepend`. -- **N2**: `[in] CBLAS_INT` number of indexed elements for `append`. -- **append**: `[in] double*` array containing values to append prior to computing differences. -- **strideA**: `[in] CBLAS_INT` stride length for `append`. -- **offsetA**: `[in] CBLAS_INT` starting index for `append`. -- **out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. -- **strideOut**: `[in] CBLAS_INT` stride length for `out`. -- **offsetOut**: `[in] CBLAS_INT` starting index for `out`. -- **workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. -- **strideW**: `[in] CBLAS_INT` stride length for `workspace`. -- **offsetW**: `[in] CBLAS_INT` starting index for `workspace`. +- **N1**: `[in] CBLAS_INT` number of indexed elements for `Prepend`. +- **Prepend**: `[in] double*` array containing values to prepend prior to computing differences. +- **strideP**: `[in] CBLAS_INT` stride length for `Prepend`. +- **offsetP**: `[in] CBLAS_INT` starting index for `Prepend`. +- **N2**: `[in] CBLAS_INT` number of indexed elements for `Append`. +- **Append**: `[in] double*` array containing values to append prior to computing differences. +- **strideA**: `[in] CBLAS_INT` stride length for `Append`. +- **offsetA**: `[in] CBLAS_INT` starting index for `Append`. +- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **strideOut**: `[in] CBLAS_INT` stride length for `Out`. +- **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. +- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. +- **offsetW**: `[in] CBLAS_INT` starting index for `Workspace`. ```c -void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); +void stdlib_strided_ddiff_ndarray( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ); ``` From f292f02224ba1cc69f0dbaf8dafaa666055e47af Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 21:14:55 -0700 Subject: [PATCH 32/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md index d6da901fcbd5..b91ed3b0c5b0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/README.md @@ -259,9 +259,9 @@ The function accepts the following arguments: - **N2**: `[in] CBLAS_INT` number of indexed elements for `Append`. - **Append**: `[in] double*` array containing values to append prior to computing differences. - **strideA**: `[in] CBLAS_INT` stride length for `Append`. -- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **Out**: `[out] double*` output array. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `Out`. -- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **Workspace**: `[out] double*` workspace array. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. ```c @@ -299,10 +299,10 @@ The function accepts the following arguments: - **Append**: `[in] double*` array containing values to append prior to computing differences. - **strideA**: `[in] CBLAS_INT` stride length for `Append`. - **offsetA**: `[in] CBLAS_INT` starting index for `Append`. -- **Out**: `[inout] double*` output array. Must have `N + N1 + N2 - k` elements. +- **Out**: `[out] double*` output array. Must have `N + N1 + N2 - k` elements. - **strideOut**: `[in] CBLAS_INT` stride length for `Out`. - **offsetOut**: `[in] CBLAS_INT` starting index for `Out`. -- **Workspace**: `[inout] double*` workspace array. Must have `N + N1 + N2 - 1` elements. +- **Workspace**: `[out] double*` workspace array. Must have `N + N1 + N2 - 1` elements. - **strideW**: `[in] CBLAS_INT` stride length for `Workspace`. - **offsetW**: `[in] CBLAS_INT` starting index for `Workspace`. From f714b52ce84348104ba7f1c345313349e8248ef1 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 21:18:05 -0700 Subject: [PATCH 33/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts index 6897696c709e..3bf977cfe1b8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts @@ -29,7 +29,7 @@ import ddiff = require( './index' ); const out = new Float64Array( 11 ); const w = new Float64Array( 11 ); - ddiff( x.length, 1.0, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectType Float64Array + ddiff( x.length, 1, x, 1, 1, p, 1, 1, a, 1, out, 1, w, 1 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a number... From 0b9d74e17d09aeaafec91aeec33fa39ed48f25a2 Mon Sep 17 00:00:00 2001 From: Athan Date: Thu, 9 Apr 2026 21:20:19 -0700 Subject: [PATCH 34/35] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts index 3bf977cfe1b8..61a80bc1fec0 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/types/test.ts @@ -618,7 +618,7 @@ import ddiff = require( './index' ); ddiff.ndarray( x.length, 1, x, 1, 0, 1, p, 1, 0, 1, a, 1, 0, out, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a eighteenth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an eighteenth argument which is not a number... { const x = new Float64Array( 10 ); const p = new Float64Array( 1 ); From 4316627429e79b362f8e04496d5a26edbbda2ebd Mon Sep 17 00:00:00 2001 From: headlessNode Date: Wed, 15 Apr 2026 13:23:08 +0500 Subject: [PATCH 35/35] 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 status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - 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: missing_dependencies - 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/ddiff/docs/repl.txt | 26 ++-- .../@stdlib/blas/ext/base/ddiff/src/addon.c | 20 +-- .../@stdlib/blas/ext/base/ddiff/src/main.c | 122 +++++++++--------- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt index bbf8bd447088..858101b322da 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/docs/repl.txt @@ -26,22 +26,22 @@ Stride length for `x`. N1: integer - Number of elements to `prepend`. + Number of elements to prepend. p: Float64Array Array containing values to prepend prior to computing differences. sp: integer - Stride length for `prepend`. + Stride length for `p`. N2: integer - Number of elements to `append`. + Number of elements to append. a: Float64Array Array containing values to append prior to computing differences. sa: integer - Stride length for `append`. + Stride length for `a`. out: Float64Array Output array. Must have `N + N1 + N2 - k` indexed elements. @@ -53,7 +53,7 @@ Workspace array. Must have `N + N1 + N2 - 1` indexed elements. sw: integer - Stride length for `workspace`. + Stride length for `w`. Returns ------- @@ -117,28 +117,28 @@ Starting index for `x`. N1: integer - Number of elements to `prepend`. + Number of elements to prepend. p: Float64Array Array containing values to prepend prior to 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 elements to append. a: Float64Array Array containing values to append prior to computing differences. sa: integer - Stride length for `append`. + Stride length for `a`. oa: integer - Starting index for `append`. + Starting index for `a`. out: Float64Array Output array. Must have `N + N1 + N2 - k` indexed elements. @@ -153,10 +153,10 @@ Workspace array. Must have `N + N1 + N2 - 1` indexed elements. sw: integer - Stride length for `workspace`. + Stride length for `w`. ow: integer - Starting index for `workspace`. + Starting index for `w`. Returns ------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c index f64803338ba4..c36d3d4aac30 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/addon.c @@ -43,11 +43,11 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideOut, argv, 11 ); STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 13 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, prepend, N1, strideP, argv, 5 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, append, N2, strideA, argv, 8 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, out, N+N1+N2-k, strideOut, argv, 10 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, workspace, N+N1+N2-1, strideW, argv, 12 ); - API_SUFFIX(stdlib_strided_ddiff)( N, k, X, strideX, N1, prepend, strideP, N2, append, strideA, out, strideOut, workspace, strideW ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Prepend, N1, strideP, argv, 5 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Append, N2, strideA, argv, 8 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, N+N1+N2-k, strideOut, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Workspace, N+N1+N2-1, strideW, argv, 12 ); + API_SUFFIX(stdlib_strided_ddiff)( N, k, X, strideX, N1, Prepend, strideP, N2, Append, strideA, Out, strideOut, Workspace, strideW ); return NULL; } @@ -75,11 +75,11 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV_INT64( env, strideW, argv, 17 ); STDLIB_NAPI_ARGV_INT64( env, offsetW, argv, 18 ); STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 2 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, prepend, N1, strideP, argv, 6 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, append, N2, strideA, argv, 10 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, out, N+N1+N2-k, strideOut, argv, 13 ); - STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, workspace, N+N1+N2-1, strideW, argv, 16 ); - API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut, workspace, strideW, offsetW ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Prepend, N1, strideP, argv, 6 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Append, N2, strideA, argv, 10 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, N+N1+N2-k, strideOut, argv, 13 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Workspace, N+N1+N2-1, strideW, argv, 16 ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Out, strideOut, offsetOut, Workspace, strideW, offsetW ); return NULL; } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c index 43834953875c..b55a32a20d3a 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c +++ b/lib/node_modules/@stdlib/blas/ext/base/ddiff/src/main.c @@ -28,19 +28,19 @@ * @param X input array * @param strideX stride length for X * @param offsetX starting index for X -* @param N1 number of indexed elements for prepend -* @param prepend prepend array -* @param strideP stride length for prepend -* @param offsetP starting index for prepend -* @param N2 number of indexed elements for 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 +* @param N1 number of indexed elements for Prepend +* @param Prepend prepend array +* @param strideP stride length for Prepend +* @param offsetP starting index for Prepend +* @param N2 number of indexed elements for 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 */ -static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { +static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut ) { CBLAS_INT total; CBLAS_INT ix; CBLAS_INT ip; @@ -62,7 +62,7 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub for ( i = 1; i < N; i++ ) { ix += strideX; curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -72,22 +72,22 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub if ( N1 > 0 ) { io = offsetOut; ip = offsetP; - prev = prepend[ ip ]; + prev = Prepend[ ip ]; for ( i = 1; i < N1; i++ ) { ip += strideP; - curr = prepend[ ip ]; - out[ io ] = curr - prev; + curr = Prepend[ ip ]; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } if ( N > 0 ) { curr = X[ offsetX ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } else if ( N2 > 0 ) { - curr = append[ offsetA ]; - out[ io ] = curr - prev; + curr = Append[ offsetA ]; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -95,7 +95,7 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub prev = X[ offsetX ]; io = offsetOut; } else { - prev = append[ offsetA ]; + prev = Append[ offsetA ]; io = offsetOut; } // Calculate the forward difference over the input array... @@ -106,7 +106,7 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; @@ -115,15 +115,15 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub ix += strideX; for ( i = 1; i < N; i++ ) { curr = X[ ix ]; - out[ io ] = curr - prev; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ix += strideX; } } if ( N2 > 0 ) { - curr = append[ offsetA ]; - out[ io ] = curr - prev; + curr = Append[ offsetA ]; + Out[ io ] = curr - prev; prev = curr; io += strideOut; } @@ -132,8 +132,8 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub if ( N2 > 0 ) { ia = offsetA + strideA; for ( i = 1; i < N2; i++ ) { - curr = append[ ia ]; - out[ io ] = curr - prev; + curr = Append[ ia ]; + Out[ io ] = curr - prev; prev = curr; io += strideOut; ia += strideA; @@ -149,24 +149,24 @@ static void stdlib_strided_internal_ddiff_ndarray( const CBLAS_INT N, const doub * @param k number of times to recursively compute differences * @param X input array * @param strideX stride length for X -* @param N1 number of indexed elements for prepend -* @param prepend prepend array -* @param strideP stride length for prepend -* @param N2 number of indexed elements for append -* @param append append array -* @param strideA stride length for append -* @param out output array -* @param strideOut stride length for out -* @param workspace workspace array +* @param N1 number of indexed elements for Prepend +* @param Prepend prepend array +* @param strideP stride length for Prepend +* @param N2 number of indexed elements for Append +* @param Append append array +* @param strideA stride length for Append +* @param Out output array +* @param strideOut stride length for Out +* @param Workspace workspace array * @param strideW stride length for workspace */ -void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, double *out, const CBLAS_INT strideOut, double *workspace, const CBLAS_INT strideW ) { +void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, double *Out, const CBLAS_INT strideOut, double *Workspace, const CBLAS_INT strideW ) { const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); const CBLAS_INT op = stdlib_strided_stride2offset( N1, strideP ); const CBLAS_INT oa = stdlib_strided_stride2offset( N2, strideA ); const CBLAS_INT oo = stdlib_strided_stride2offset( N+N1+N2-k, strideOut ); const CBLAS_INT ow = stdlib_strided_stride2offset( N+N1+N2-1, strideW ); - API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, prepend, strideP, op, N2, append, strideA, oa, out, strideOut, oo, workspace, strideW, ow ); + API_SUFFIX(stdlib_strided_ddiff_ndarray)( N, k, X, strideX, ox, N1, Prepend, strideP, op, N2, Append, strideA, oa, Out, strideOut, oo, Workspace, strideW, ow ); } /** @@ -177,22 +177,22 @@ void API_SUFFIX(stdlib_strided_ddiff)( const CBLAS_INT N, const CBLAS_INT k, con * @param X input array * @param strideX stride length for X * @param offsetX starting index for X -* @param N1 number of indexed elements for prepend -* @param prepend prepend array -* @param strideP stride length for prepend -* @param offsetP starting index for prepend -* @param N2 number of indexed elements for 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 -* @param workspace workspace array -* @param strideW stride length for workspace -* @param offsetW starting index for workspace +* @param N1 number of indexed elements for Prepend +* @param Prepend prepend array +* @param strideP stride length for Prepend +* @param offsetP starting index for Prepend +* @param N2 number of indexed elements for 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 +* @param Workspace workspace array +* @param strideW stride length for Workspace +* @param offsetW starting index for Workspace */ -void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { +void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_INT k, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, const CBLAS_INT N1, const double *Prepend, const CBLAS_INT strideP, const CBLAS_INT offsetP, const CBLAS_INT N2, const double *Append, const CBLAS_INT strideA, const CBLAS_INT offsetA, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut, double *Workspace, const CBLAS_INT strideW, const CBLAS_INT offsetW ) { CBLAS_INT total; CBLAS_INT io; CBLAS_INT n; @@ -206,34 +206,34 @@ void API_SUFFIX(stdlib_strided_ddiff_ndarray)( const CBLAS_INT N, const CBLAS_IN } // If `k` is equal to zero, there are no differences to compute, so we merely copy the various arrays into the output array... if ( k == 0 ) { - // Copy `prepend` into output array: - c_dcopy_ndarray( N1, prepend, strideP, offsetP, out, strideOut, offsetOut ); + // Copy `Prepend` into output array: + c_dcopy_ndarray( N1, Prepend, strideP, offsetP, Out, strideOut, offsetOut ); // Copy `X` into output array: io = offsetOut + ( N1 * strideOut ); - c_dcopy_ndarray( N, X, strideX, offsetX, out, strideOut, io ); + c_dcopy_ndarray( N, X, strideX, offsetX, Out, strideOut, io ); - // Copy `append` into output array: + // Copy `Append` into output array: io = offsetOut + ( ( N1 + N ) * strideOut ); - c_dcopy_ndarray( N2, append, strideA, offsetA, out, strideOut, io ); + c_dcopy_ndarray( N2, Append, strideA, offsetA, Out, strideOut, io ); return; } // If `k` is equal to one, we can compute the forward difference while writing directly to the output array... if ( k == 1 ) { - stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, out, strideOut, offsetOut ); + stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Out, strideOut, offsetOut ); return; } // Compute the first forward difference: - stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, prepend, strideP, offsetP, N2, append, strideA, offsetA, workspace, strideW, offsetW ); + stdlib_strided_internal_ddiff_ndarray( N, X, strideX, offsetX, N1, Prepend, strideP, offsetP, N2, Append, strideA, offsetA, Workspace, strideW, offsetW ); // Recursively compute the next forward differences... n = total - 1; for ( i = 1; i < k - 1; i++ ) { - stdlib_strided_internal_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, workspace, strideW, offsetW ); + stdlib_strided_internal_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Workspace, strideW, offsetW ); n -= 1; } // For the last forward difference, ensure that results are written to the output array: - stdlib_strided_internal_ddiff_ndarray( n, workspace, strideW, offsetW, 0, prepend, strideP, offsetP, 0, append, strideA, offsetA, out, strideOut, offsetOut ); + stdlib_strided_internal_ddiff_ndarray( n, Workspace, strideW, offsetW, 0, Prepend, strideP, offsetP, 0, Append, strideA, offsetA, Out, strideOut, offsetOut ); return; }