From fac1ecc5659a1ef28412b957c6fcabff44caf9b8 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sun, 18 Oct 2026 23:30:48 +0500 Subject: [PATCH] feat: add blas/ext/base/ghankel --- .../@stdlib/blas/ext/base/ghankel/README.md | 205 +++++ .../ext/base/ghankel/benchmark/benchmark.js | 107 +++ .../ghankel/benchmark/benchmark.ndarray.js | 107 +++ .../blas/ext/base/ghankel/docs/repl.txt | 139 +++ .../ext/base/ghankel/docs/types/index.d.ts | 127 +++ .../blas/ext/base/ghankel/docs/types/test.ts | 408 +++++++++ .../blas/ext/base/ghankel/examples/index.js | 46 + .../blas/ext/base/ghankel/lib/accessors.js | 142 +++ .../blas/ext/base/ghankel/lib/index.js | 61 ++ .../@stdlib/blas/ext/base/ghankel/lib/main.js | 97 ++ .../blas/ext/base/ghankel/lib/ndarray.js | 140 +++ .../blas/ext/base/ghankel/package.json | 69 ++ .../blas/ext/base/ghankel/test/test.js | 38 + .../blas/ext/base/ghankel/test/test.main.js | 852 ++++++++++++++++++ .../ext/base/ghankel/test/test.ndarray.js | 799 ++++++++++++++++ 15 files changed, 3337 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/README.md b/lib/node_modules/@stdlib/blas/ext/base/ghankel/README.md new file mode 100644 index 000000000000..4a46308b93db --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/README.md @@ -0,0 +1,205 @@ + + +# ghankel + +> Generate a Hankel matrix. + +
+ +
+ + + +
+ +## Usage + +```javascript +var ghankel = require( '@stdlib/blas/ext/base/ghankel' ); +``` + +#### ghankel( order, M, N, r, strideR, c, strideC, out, ldo ) + +Generates a Hankel matrix. + +```javascript +var r = [ 3.0, 4.0, 5.0 ]; +var c = [ 1.0, 2.0, 3.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); +// out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +``` + +The function has the following parameters: + +- **order**: row-major (C-style) or column-major (Fortran-style) order. +- **M**: number of indexed elements in `r` and number of rows in `out`. +- **N**: number of indexed elements in `c` and number of columns in `out`. +- **r**: last row of the matrix ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). If the first indexed element of `r` and the last indexed element of `c` differ, the last indexed element of `c` is used for the anti-diagonal. +- **strideR**: stride length for `r`. +- **c**: first column of the matrix ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). If the first indexed element of `r` and the last indexed element of `c` differ, the last indexed element of `c` is used for the anti-diagonal. +- **strideC**: stride length for `c`. +- **out**: output matrix. +- **ldo**: stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`). Must be greater than or equal to `max(1,N)` when `order` is row-major and `max(1,M)` when `order` is column-major. + +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 arrays: +var r0 = new Float64Array( [ 999.0, 3.0, 4.0, 5.0 ] ); +var c0 = new Float64Array( [ 999.0, 1.0, 2.0, 3.0 ] ); +var out0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create offset views: +var r1 = new Float64Array( r0.buffer, r0.BYTES_PER_ELEMENT*1 ); +var c1 = new Float64Array( c0.buffer, c0.BYTES_PER_ELEMENT*1 ); +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + +ghankel( 'row-major', 3, 3, r1, 1, c1, 1, out1, 3 ); +// out0 => [ 0.0, 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +``` + + + +#### ghankel.ndarray( M, N, r, strideR, offsetR, c, strideC, offsetC, out, strideOut1, strideOut2, offsetOut ) + + + +Generates a Hankel matrix using alternative indexing semantics. + +```javascript +var r = [ 3.0, 4.0, 5.0 ]; +var c = [ 1.0, 2.0, 3.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +``` + +The function has the following additional parameters: + +- **offsetR**: starting index for `r`. +- **offsetC**: starting index for `c`. +- **strideOut1**: stride length for the first dimension of `out`. +- **strideOut2**: stride length for the second dimension of `out`. +- **offsetOut**: starting index for `out`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to use every other element from the input arrays starting from the second element: + +```javascript +var r = [ 0.0, 3.0, 0.0, 4.0, 0.0, 5.0 ]; +var c = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +ghankel.ndarray( 3, 3, r, 2, 1, c, 2, 1, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +``` + +
+ + + +
+ +## Notes + +- If `M <= 0` or `N <= 0`, both functions return `out` unchanged. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var ghankel = require( '@stdlib/blas/ext/base/ghankel' ); + +var M = 4; +var N = 4; +var order = 'row-major'; +var shape = [ M, N ]; +var strides = shape2strides( shape, order ); + +var r = discreteUniform( M, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'r:', r ); + +var c = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'c:', c ); + +var out = zeros( M*N, 'generic' ); + +ghankel( order, M, N, r, 1, c, 1, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.js new file mode 100644 index 000000000000..8d4fe4dc66ac --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.js @@ -0,0 +1,107 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ghankel = require( './../lib/main.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var r = uniform( len, -10.0, 10.0, options ); + var c = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + c[ 0 ] += 0.1; + v = ghankel( 'row-major', len, len, r, 1, c, 1, out, len ); + if ( isnan( v[ i%v.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v[ i%v.length ] ) ) { + 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 = 3; // 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/ghankel/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..7ab53285deb6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/benchmark/benchmark.ndarray.js @@ -0,0 +1,107 @@ +/** +* @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 zeros = require( '@stdlib/array/zeros' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var ghankel = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var out = zeros( len * len, options.dtype ); + var r = uniform( len, -10.0, 10.0, options ); + var c = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + c[ 0 ] += 0.1; + v = ghankel( len, len, r, 1, 0, c, 1, 0, out, len, 1, 0 ); + if ( isnan( v[ i%v.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v[ i%v.length ] ) ) { + 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 = 3; // 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/ghankel/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/repl.txt new file mode 100644 index 000000000000..d7d8114b0ff4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/repl.txt @@ -0,0 +1,139 @@ + +{{alias}}( order, M, N, r, strideR, c, strideC, out, ldo ) + Generates a Hankel matrix. + + The `M`, `N`, and stride parameters determine which elements in the strided + arrays are accessed at runtime. + + If `M` or `N` is equal to `0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Storage layout. + + M: integer + Number of indexed elements in `r` and number of rows in `out`. + + N: integer + Number of indexed elements in `c` and number of columns in `out`. + + r: ArrayLikeObject + Last row of the matrix. If the first indexed element of `r` and the + last indexed element of `c` differ, the last indexed element of `c` is + used for the anti-diagonal. + + strideR: integer + Stride length for `r`. + + c: ArrayLikeObject + First column of the matrix. If the first indexed element of `r` and + the last indexed element of `c` differ, the last indexed element of `c` + is used for the anti-diagonal. + + strideC: integer + Stride length for `c`. + + out: ArrayLikeObject + Output array. + + ldo: integer + Stride length between successive contiguous vectors of the matrix `out` + (a.k.a., leading dimension of `out`). Must be greater than or equal to + `max(1,N)` when `order` is row-major and `max(1,M)` when `order` is + column-major. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Standard Usage: + > var r = [ 3.0, 4.0, 5.0 ]; + > var c = [ 1.0, 2.0, 3.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 3, 3, r, 1, c, 1, out, 3 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + + // Using `M`, `N`, and stride parameters: + > r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + > c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 3, 3, r, 2, c, 2, out, 3 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + + +{{alias}}.ndarray( M, N, r, sr, or, c, sc, oc, out, so1, so2, oo ) + Generates a Hankel matrix 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 + ---------- + M: integer + Number of indexed elements in `r` and number of rows in `out`. + + N: integer + Number of indexed elements in `c` and number of columns in `out`. + + r: ArrayLikeObject + Last row of the matrix. If the first indexed element of `r` and the + last indexed element of `c` differ, the last indexed element of `c` is + used for the anti-diagonal. + + sr: integer + Stride length for `r`. + + or: integer + Starting index for `r`. + + c: ArrayLikeObject + First column of the matrix. If the first indexed element of `r` and + the last indexed element of `c` differ, the last indexed element of `c` + is used for the anti-diagonal. + + sc: integer + Stride length for `c`. + + oc: integer + Starting index for `c`. + + out: ArrayLikeObject + Output array. + + so1: integer + Stride length for the first dimension of `out`. + + so2: integer + Stride length for the second dimension of `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Standard Usage: + > var r = [ 3.0, 4.0, 5.0 ]; + > var c = [ 1.0, 2.0, 3.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + + // Using an index offset: + > r = [ 0.0, 3.0, 4.0, 5.0 ]; + > c = [ 0.0, 1.0, 2.0, 3.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, 3, r, 1, 1, c, 1, 1, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/index.d.ts new file mode 100644 index 000000000000..b51e61fddbbf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/index.d.ts @@ -0,0 +1,127 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection, AccessorArrayLike } from '@stdlib/types/array'; +import { Layout } from '@stdlib/types/blas'; + +/** +* Input array. +*/ +type InputArray = Collection | AccessorArrayLike; + +/** +* Output array. +*/ +type OutputArray = Collection | AccessorArrayLike; + +/** +* Interface describing `ghankel`. +*/ +interface Routine { + /** + * Generates a Hankel matrix. + * + * @param order - storage layout + * @param M - number of indexed elements in `r` and number of rows in the output matrix + * @param N - number of indexed elements in `c` and number of columns in the output matrix + * @param r - last row of the matrix + * @param strideR - stride length for `r` + * @param c - first column of the matrix + * @param strideC - stride length for `c` + * @param out - output array + * @param ldo - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) + * @returns output array + * + * @example + * var r = [ 3.0, 4.0, 5.0 ]; + * var c = [ 1.0, 2.0, 3.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); + * // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + */ + = OutputArray>( order: Layout, M: number, N: number, r: InputArray, strideR: number, c: InputArray, strideC: number, out: V, ldo: number ): V; + + /** + * Generates a Hankel matrix using alternative indexing semantics. + * + * @param M - number of indexed elements in `r` and number of rows in the output matrix + * @param N - number of indexed elements in `c` and number of columns in the output matrix + * @param r - last row of the matrix + * @param strideR - stride length for `r` + * @param offsetR - starting index for `r` + * @param c - first column of the matrix + * @param strideC - stride length for `c` + * @param offsetC - starting index for `c` + * @param out - output array + * @param strideOut1 - stride length for the first dimension of `out` + * @param strideOut2 - stride length for the second dimension of `out` + * @param offsetOut - starting index for `out` + * @returns output array + * + * @example + * var r = [ 3.0, 4.0, 5.0 ]; + * var c = [ 1.0, 2.0, 3.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); + * // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] + */ + ndarray = OutputArray>( M: number, N: number, r: InputArray, strideR: number, offsetR: number, c: InputArray, strideC: number, offsetC: number, out: V, strideOut1: number, strideOut2: number, offsetOut: number ): V; +} + +/** +* Generates a Hankel matrix. +* +* @param order - storage layout +* @param M - number of indexed elements in `r` and number of rows in the output matrix +* @param N - number of indexed elements in `c` and number of columns in the output matrix +* @param r - last row of the matrix +* @param strideR - stride length for `r` +* @param c - first column of the matrix +* @param strideC - stride length for `c` +* @param out - output array +* @param ldo - stride length between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of `out`) +* @returns output array +* +* @example +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +* +* @example +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +*/ +declare var ghankel: Routine; + + +// EXPORTS // + +export = ghankel; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/test.ts new file mode 100644 index 000000000000..379e09f3fa06 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/docs/types/test.ts @@ -0,0 +1,408 @@ +/* +* @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 space-in-parens */ + +import AccessorArray = require( '@stdlib/array/base/accessor' ); +import ghankel = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); // $ExpectType Float64Array + ghankel( 'row-major', 3, 3, new AccessorArray( r ), 1, new AccessorArray( c ), 1, new AccessorArray( out ), 3 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the function is provided a first argument which is not a valid order... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 10, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( true, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( false, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( null, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( undefined, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( [], 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( {}, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( ( x: number ): number => x, 3, 3, r, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', '10', 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', true, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', false, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', null, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', undefined, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', [], 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', {}, 3, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', ( x: number ): number => x, 3, r, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, '10', r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, true, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, false, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, null, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, undefined, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, [], r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, {}, r, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, ( x: number ): number => x, r, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a collection... +{ + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, 10, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, true, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, false, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, null, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, undefined, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, {}, 1, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, ( x: number ): number => x, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r, '10', c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, true, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, false, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, null, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, undefined, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, [], c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, {}, c, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, ( x: number ): number => x, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r, 1, 10, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, true, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, false, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, null, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, undefined, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, {}, 1, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, ( x: number ): number => x, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r, 1, c, '10', out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, true, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, false, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, null, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, undefined, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, [], out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, {}, out, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, ( x: number ): number => x, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + + ghankel( 'row-major', 3, 3, r, 1, c, 1, 10, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, true, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, false, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, null, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, undefined, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, {}, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, '10' ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, true ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, false ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, null ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, undefined ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, [] ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, {} ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel(); // $ExpectError + ghankel( 'row-major' ); // $ExpectError + ghankel( 'row-major', 3 ); // $ExpectError + ghankel( 'row-major', 3, 3 ); // $ExpectError + ghankel( 'row-major', 3, 3, r ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1 ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out ); // $ExpectError + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectType Float64Array + ghankel.ndarray( 3, 3, new AccessorArray( r ), 1, 0, new AccessorArray( c ), 1, 0, new AccessorArray( out ), 3, 1, 0 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( '10', 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( true, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( false, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( null, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( undefined, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( [], 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( {}, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( ( x: number ): number => x, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, '10', r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, true, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, false, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, null, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, undefined, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, [], r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, {}, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, ( x: number ): number => x, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... +{ + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, 10, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, true, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, false, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, null, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, undefined, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, {}, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, ( x: number ): number => x, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, '10', 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, true, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, false, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, null, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, undefined, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, [], 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, {}, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, ( x: number ): number => x, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, '10', c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, true, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, false, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, null, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, undefined, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, [], c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, {}, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, ( x: number ): number => x, c, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, 10, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, true, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, false, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, null, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, undefined, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, {}, 1, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, ( x: number ): number => x, 1, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, '10', 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, true, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, false, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, null, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, undefined, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, [], 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, {}, 0, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, ( x: number ): number => x, 0, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, '10', out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, true, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, false, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, null, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, undefined, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, [], out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, {}, out, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, ( x: number ): number => x, out, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, 10, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, true, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, false, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, null, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, undefined, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, {}, 3, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, ( x: number ): number => x, 3, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, '10', 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, true, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, false, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, null, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, undefined, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, [], 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, {}, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eleventh argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, '10', 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, true, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, false, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, null, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, undefined, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, [], 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, {}, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, '10' ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, true ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, false ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, null ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, undefined ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, [] ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, {} ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + ghankel.ndarray(); // $ExpectError + ghankel.ndarray( 3 ); // $ExpectError + ghankel.ndarray( 3, 3 ); // $ExpectError + ghankel.ndarray( 3, 3, r ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1 ); // $ExpectError + ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/examples/index.js new file mode 100644 index 000000000000..78da965cc965 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/examples/index.js @@ -0,0 +1,46 @@ +/** +* @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 ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var ghankel = require( './../lib' ); + +var M = 4; +var N = 4; +var order = 'row-major'; +var shape = [ M, N ]; +var strides = shape2strides( shape, order ); + +var r = discreteUniform( M, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'r:', r ); + +var c = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'c:', c ); + +var out = zeros( M*N, 'generic' ); + +ghankel( order, M, N, r, 1, c, 1, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/accessors.js new file mode 100644 index 000000000000..aa9f80ac64e0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/accessors.js @@ -0,0 +1,142 @@ +/** +* @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 */ + +'use strict'; + +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); + + +// MAIN // + +/** +* Generates a Hankel matrix. +* +* @private +* @param {NonNegativeInteger} M - number of indexed elements in `r` and number of rows in the output matrix +* @param {NonNegativeInteger} N - number of indexed elements in `c` and number of columns in the output matrix +* @param {Object} r - last row of the matrix +* @param {integer} strideR - stride length for `r` +* @param {NonNegativeInteger} offsetR - starting index for `r` +* @param {Object} c - first column of the matrix +* @param {integer} strideC - stride length for `c` +* @param {NonNegativeInteger} offsetC - starting index for `c` +* @param {Object} out - output array +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Object} output matrix +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel( 3, 3, arraylike2object( toAccessorArray( r ) ), 1, 0, arraylike2object( toAccessorArray( c ) ), 1, 0, arraylike2object( toAccessorArray( out ) ), 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +*/ +function ghankel( M, N, r, strideR, offsetR, c, strideC, offsetC, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var rbuf; + var cbuf; + var obuf; + var getR; + var getC; + var oset; + var do0; + var do1; + var io; + var ro; + var co; + var i0; + var i1; + var f; + + rbuf = r.data; + cbuf = c.data; + obuf = out.data; + getR = r.accessors[ 0 ]; + getC = c.accessors[ 0 ]; + oset = out.accessors[ 1 ]; + + // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... + if ( isRowMajor( [ strideOut1, strideOut2 ] ) ) { + // Row-first iteration (inner loop walks columns): + do0 = strideOut2; + do1 = strideOut1 - ( N * strideOut2 ); + io = offsetOut; + for ( i1 = 0; i1 < M; i1++ ) { + // Anti-diagonals drawn from the first column: c[i1], c[i1+1], ..., c[N-1] + f = N - i1; + if ( f < 0 ) { + f = 0; + } + co = offsetC + ( i1 * strideC ); + for ( i0 = 0; i0 < f; i0++ ) { + oset( obuf, io, getC( cbuf, co ) ); + co += strideC; + io += do0; + } + // Anti-diagonals drawn from the last row: r[i1+f-N+1], r[i1+f-N+2], ..., r[i1] + ro = offsetR + ( ( i1 + f - N + 1 ) * strideR ); + for ( i0 = f; i0 < N; i0++ ) { + oset( obuf, io, getR( rbuf, ro ) ); + ro += strideR; + io += do0; + } + io += do1; + } + return out; + } + // Column-first iteration (inner loop walks rows): + do0 = strideOut1; + do1 = strideOut2 - ( M * strideOut1 ); + io = offsetOut; + for ( i1 = 0; i1 < N; i1++ ) { + // Anti-diagonals drawn from the first column: c[i1], c[i1+1], ..., c[min(N-1,i1+M-1)] + f = N - i1; + if ( f > M ) { + f = M; + } + co = offsetC + ( i1 * strideC ); + for ( i0 = 0; i0 < f; i0++ ) { + oset( obuf, io, getC( cbuf, co ) ); + co += strideC; + io += do0; + } + // Anti-diagonals drawn from the last row: r[1], r[2], ..., r[i1+M-N] + ro = offsetR + strideR; + for ( i0 = f; i0 < M; i0++ ) { + oset( obuf, io, getR( rbuf, ro ) ); + ro += strideR; + io += do0; + } + io += do1; + } + return out; +} + + +// EXPORTS // + +module.exports = ghankel; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/index.js new file mode 100644 index 000000000000..55d472fd2e04 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/index.js @@ -0,0 +1,61 @@ +/** +* @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'; + +/** +* Generate a Hankel matrix. +* +* @module @stdlib/blas/ext/base/ghankel +* +* @example +* var ghankel = require( '@stdlib/blas/ext/base/ghankel' ); +* +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +* +* @example +* var ghankel = require( '@stdlib/blas/ext/base/ghankel' ); +* +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel.ndarray( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/main.js new file mode 100644 index 000000000000..ee976c734ee0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/main.js @@ -0,0 +1,97 @@ +/** +* @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 isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var resolveLayout = require( '@stdlib/blas/base/layout-resolve-str' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Generates a Hankel matrix. +* +* @param {(integer|string)} order - storage layout +* @param {NonNegativeInteger} M - number of indexed elements in `r` and number of rows in the output matrix +* @param {NonNegativeInteger} N - number of indexed elements in `c` and number of columns in the output matrix +* @param {Collection} r - last row of the matrix +* @param {integer} strideR - stride length for `r` +* @param {Collection} c - first column of the matrix +* @param {integer} strideC - stride length for `c` +* @param {Collection} out - output array +* @param {PositiveInteger} ldo - stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`) +* @throws {TypeError} first argument must be a valid order +* @throws {RangeError} ninth argument must be a valid stride +* @returns {Collection} output matrix +* +* @example +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +*/ +function ghankel( order, M, N, r, strideR, c, strideC, out, ldo ) { + var iscm; + var vala; + var sa1; + var sa2; + var or; + var oc; + var l; + + l = resolveLayout( order ); + if ( l === null ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + iscm = isColumnMajor( l ); + if ( iscm ) { + vala = M; + } else { // order === 'row-major' + vala = N; + } + if ( ldo < max( 1, vala ) ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be greater than or equal to max(1,%d). Value: `%d`.', vala, ldo ) ); + } + if ( M <= 0 || N <= 0 ) { + return out; + } + or = stride2offset( M, strideR ); + oc = stride2offset( N, strideC ); + if ( iscm ) { + sa1 = 1; + sa2 = ldo; + } else { // order === 'row-major' + sa1 = ldo; + sa2 = 1; + } + return ndarray( M, N, r, strideR, or, c, strideC, oc, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = ghankel; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/ndarray.js new file mode 100644 index 000000000000..513f8ba9c6b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/lib/ndarray.js @@ -0,0 +1,140 @@ +/** +* @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 */ + +'use strict'; + +// MODULES // + +var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Generates a Hankel matrix using alternative indexing semantics. +* +* @param {NonNegativeInteger} M - number of indexed elements in `r` and number of rows in the output matrix +* @param {NonNegativeInteger} N - number of indexed elements in `c` and number of columns in the output matrix +* @param {Collection} r - last row of the matrix +* @param {integer} strideR - stride length for `r` +* @param {NonNegativeInteger} offsetR - starting index for `r` +* @param {Collection} c - first column of the matrix +* @param {integer} strideC - stride length for `c` +* @param {NonNegativeInteger} offsetC - starting index for `c` +* @param {Collection} out - output array +* @param {integer} strideOut1 - stride length for the first dimension of `out` +* @param {integer} strideOut2 - stride length for the second dimension of `out` +* @param {NonNegativeInteger} offsetOut - starting index for `out` +* @returns {Collection} output matrix +* +* @example +* var r = [ 3.0, 4.0, 5.0 ]; +* var c = [ 1.0, 2.0, 3.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* ghankel( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ] +*/ +function ghankel( M, N, r, strideR, offsetR, c, strideC, offsetC, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var do0; + var do1; + var oo; + var or; + var oc; + var io; + var ro; + var co; + var i0; + var i1; + var f; + + if ( M <= 0 || N <= 0 ) { + return out; + } + or = arraylike2object( r ); + oc = arraylike2object( c ); + oo = arraylike2object( out ); + if ( or.accessorProtocol || oc.accessorProtocol || oo.accessorProtocol ) { + accessors( M, N, or, strideR, offsetR, oc, strideC, offsetC, oo, strideOut1, strideOut2, offsetOut ); // eslint-disable-line max-len + return out; + } + // Note on variable naming convention: S#, do#, io, i# where # corresponds to the loop number, with `0` being the innermost loop... + if ( isRowMajor( [ strideOut1, strideOut2 ] ) ) { + // Row-first iteration (inner loop walks columns): + do0 = strideOut2; + do1 = strideOut1 - ( N * strideOut2 ); + io = offsetOut; + for ( i1 = 0; i1 < M; i1++ ) { + // Anti-diagonals drawn from the first column: c[i1], c[i1+1], ..., c[N-1] + f = N - i1; + if ( f < 0 ) { + f = 0; + } + co = offsetC + ( i1 * strideC ); + for ( i0 = 0; i0 < f; i0++ ) { + out[ io ] = c[ co ]; + co += strideC; + io += do0; + } + // Anti-diagonals drawn from the last row: r[i1+f-N+1], r[i1+f-N+2], ..., r[i1] + ro = offsetR + ( ( i1 + f - N + 1 ) * strideR ); + for ( i0 = f; i0 < N; i0++ ) { + out[ io ] = r[ ro ]; + ro += strideR; + io += do0; + } + io += do1; + } + return out; + } + // Column-first iteration (inner loop walks rows): + do0 = strideOut1; + do1 = strideOut2 - ( M * strideOut1 ); + io = offsetOut; + for ( i1 = 0; i1 < N; i1++ ) { + // Anti-diagonals drawn from the first column: c[i1], c[i1+1], ..., c[min(N-1,i1+M-1)] + f = N - i1; + if ( f > M ) { + f = M; + } + co = offsetC + ( i1 * strideC ); + for ( i0 = 0; i0 < f; i0++ ) { + out[ io ] = c[ co ]; + co += strideC; + io += do0; + } + // Anti-diagonals drawn from the last row: r[1], r[2], ..., r[i1+M-N] + ro = offsetR + strideR; + for ( i0 = f; i0 < M; i0++ ) { + out[ io ] = r[ ro ]; + ro += strideR; + io += do0; + } + io += do1; + } + return out; +} + + +// EXPORTS // + +module.exports = ghankel; diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/package.json b/lib/node_modules/@stdlib/blas/ext/base/ghankel/package.json new file mode 100644 index 000000000000..3fbd42e92421 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/ghankel", + "version": "0.0.0", + "description": "Generate a Hankel matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "extended", + "hankel", + "matrix", + "strided", + "strided array", + "typed", + "array", + "ndarray", + "vector", + "ghankel" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.js new file mode 100644 index 000000000000..fdf8486497cf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var ghankel = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ghankel, '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 ghankel.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.main.js new file mode 100644 index 000000000000..27e64b803111 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.main.js @@ -0,0 +1,852 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ghankel = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ghankel, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( ghankel.length, 9, 'has expected arity' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ghankel( value, 3, 3, [ 3.0, 4.0, 5.0 ], 1, [ 1.0, 2.0, 3.0 ], 1, [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], 3 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid first argument (accessors)', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ghankel( value, 3, 3, toAccessorArray( [ 3.0, 4.0, 5.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ), 3 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { + var values; + var i; + + values = [ + -3, + -2, + -1, + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ghankel( 'row-major', 3, 3, [ 3.0, 4.0, 5.0 ], 1, [ 1.0, 2.0, 3.0 ], 1, [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ], value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument (accessors)', function test( t ) { + var values; + var i; + + values = [ + -3, + -2, + -1, + 0, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ghankel( 'row-major', 3, 3, toAccessorArray( [ 3.0, 4.0, 5.0 ] ), 1, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ), value ); + }; + } +}); + +tape( 'if provided an `M` less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 0, 3, r, 1, c, 1, out, 3 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 0, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 0, r, 1, c, 1, out, 1 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 0, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 1 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 2, r, 1, c, 1, out, 2 ); + + expected = [ 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 2 ); + + expected = [ 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 2, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 4.0, 2.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 4.0, 2.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 2, 3, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 2, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 2, 3, r, 1, c, 1, out, 2 ); + + expected = [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 2, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 2 ); + + expected = [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, r, 2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, toAccessorArray( r ), 2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, r, 1, c, 2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, r, -2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, toAccessorArray( r ), -2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, r, 1, c, -2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, r, 2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, toAccessorArray( r ), 2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, r, 1, c, 2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, r, -2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, toAccessorArray( r ), -2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, r, 1, c, -2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 3, 3, toAccessorArray( r ), 1, toAccessorArray( c ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `N` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 2, 2, r, 1, c, 1, out, 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 2.0, + 3.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `N` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'row-major', 2, 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 2.0, + 3.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `M` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 2, 2, r, 1, c, 1, out, 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 2.0, + 3.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `M` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 'column-major', 2, 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 2.0, + 3.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var expected; + var out; + var r0; + var r1; + var c0; + var c1; + + r0 = new Float64Array( [ 0.0, 3.0, 4.0, 5.0 ] ); + c0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + + r1 = new Float64Array( r0.buffer, r0.BYTES_PER_ELEMENT*1 ); + c1 = new Float64Array( c0.buffer, c0.BYTES_PER_ELEMENT*1 ); + + out = new Float64Array( 9 ); + + ghankel( 'row-major', 3, 3, r1, 1, c1, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 2.0, + 3.0, + 2.0, + 3.0, + 4.0, + 3.0, + 4.0, + 5.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.ndarray.js new file mode 100644 index 000000000000..14ea04e0c476 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/ghankel/test/test.ndarray.js @@ -0,0 +1,799 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var ghankel = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ghankel, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( ghankel.length, 12, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 2, r, 1, 0, c, 1, 0, out, 2, 1, 0 ); + + expected = [ 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 2, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 2, 1, 0 ); + + expected = [ 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 2, r, 1, 0, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 4.0, 2.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M > N, column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 2, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 4.0, 2.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 3, r, 1, 0, c, 1, 0, out, 1, 2, 0 ); + + expected = [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Hankel matrix (M < N, column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 2, 0 ); + + expected = [ 1.0, 2.0, 2.0, 3.0, 3.0, 4.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 0, 3, r, 1, 0, c, 1, 0, out, 0, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 0, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 0, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 0, r, 1, 0, c, 1, 0, out, 0, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `N` less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 0, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 0, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 2, 0, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 2, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, 2, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 2, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, -2, 4, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), -2, 4, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, -2, 4, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), -2, 4, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 2, 0, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `r` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 0.0, 4.0, 0.0, 5.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 2, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, 2, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `c` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 2, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, -2, 4, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `r` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 5.0, 0.0, 4.0, 0.0, 3.0 ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), -2, 4, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, -2, 4, out, 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `c` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), -2, 4, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `r` offset', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ + 0.0, + 3.0, // 0 + 4.0, // 1 + 5.0 // 2 + ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 1, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `r` offset (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ + 0.0, + 3.0, // 0 + 4.0, // 1 + 5.0 // 2 + ]; + c = [ 1.0, 2.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 1, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `c` offset', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ + 0.0, + 1.0, // 0 + 2.0, // 1 + 3.0 // 2 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, r, 1, 0, c, 1, 1, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a `c` offset (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 3.0, 4.0, 5.0 ]; + c = [ + 0.0, + 1.0, // 0 + 2.0, // 1 + 3.0 // 2 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 3, 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 1, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an output offset', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 2, r, 1, 0, c, 1, 0, out, 2, 1, 2 ); + + expected = [ 0.0, 0.0, 1.0, 2.0, 2.0, 3.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an output offset (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 2.0, 3.0 ]; + c = [ 1.0, 2.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 2, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 2, 1, 2 ); + + expected = [ 0.0, 0.0, 1.0, 2.0, 2.0, 3.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]; + c = [ + 0.0, + 1.0, // 0 + 0.0, + 2.0 // 1 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 2, r, 2, 1, c, 2, 1, out, 2, -1, 1 ); + + expected = [ 2.0, 1.0, 3.0, 2.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns (accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ + 0.0, + 2.0, // 0 + 0.0, + 3.0 // 1 + ]; + c = [ + 0.0, + 1.0, // 0 + 0.0, + 2.0 // 1 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + ghankel( 2, 2, toAccessorArray( r ), 2, 1, toAccessorArray( c ), 2, 1, toAccessorArray( out ), 2, -1, 1 ); + + expected = [ 2.0, 1.0, 3.0, 2.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +});