diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/README.md b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/README.md new file mode 100644 index 000000000000..acec2020b93a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/README.md @@ -0,0 +1,204 @@ + + +# gtoeplitz + +> Generate a Toeplitz matrix. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gtoeplitz = require( '@stdlib/blas/ext/base/gtoeplitz' ); +``` + +#### gtoeplitz( order, N, r, strideR, c, strideC, out, ldo ) + +Generates a Toeplitz matrix. + +```javascript +var r = [ 1.0, 2.0, 3.0 ]; +var c = [ 1.0, 4.0, 5.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); +// out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +``` + +The function has the following parameters: + +- **order**: row-major (C-style) or column-major (Fortran-style) order. +- **N**: number of indexed elements in both `r` and `c`. +- **r**: first row of the matrix ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). +- **strideR**: stride length for `r`. +- **c**: first column of the matrix ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). +- **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)`. + +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, 1.0, 2.0, 3.0 ] ); +var c0 = new Float64Array( [ 999.0, 1.0, 4.0, 5.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 ); + +gtoeplitz( 'row-major', 3, r1, 1, c1, 1, out1, 3 ); +// out0 => [ 0.0, 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +``` + + + +#### gtoeplitz.ndarray( N, r, strideR, offsetR, c, strideC, offsetC, out, strideOut1, strideOut2, offsetOut ) + + + +Generates a Toeplitz matrix using alternative indexing semantics. + +```javascript +var r = [ 1.0, 2.0, 3.0 ]; +var c = [ 1.0, 4.0, 5.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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, 1.0, 0.0, 2.0, 0.0, 3.0 ]; +var c = [ 0.0, 1.0, 0.0, 4.0, 0.0, 5.0 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gtoeplitz.ndarray( 3, r, 2, 1, c, 2, 1, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `out` unchanged. +- If `r[0]` and `c[0]` differ, `c[0]` is used for the diagonal. +- 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 gtoeplitz = require( '@stdlib/blas/ext/base/gtoeplitz' ); + +var N = 4; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var r = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'r:', r ); + +var c = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'c:', c ); + +var out = zeros( N*N, 'generic' ); + +gtoeplitz( order, 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/gtoeplitz/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/benchmark/benchmark.js new file mode 100644 index 000000000000..070fa18c86e0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/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 gtoeplitz = 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++ ) { + r[ 0 ] += 0.1; + v = gtoeplitz( 'row-major', 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/gtoeplitz/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..8cb8e8903de5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/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 gtoeplitz = 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++ ) { + r[ 0 ] += 0.1; + v = gtoeplitz( 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/gtoeplitz/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/repl.txt new file mode 100644 index 000000000000..120447eb62ee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/repl.txt @@ -0,0 +1,132 @@ + +{{alias}}( order, N, r, strideR, c, strideC, out, ldo ) + Generates a Toeplitz matrix. + + The matrix is defined by its first row `r` and first column `c`. + + If `r[0]` and `c[0]` differ, `c[0]` is used for the diagonal. + + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. + + If `N` is equal to `0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Storage layout. + + N: integer + Number of indexed elements in both `r` and `c`. + + r: ArrayLikeObject + First row of the matrix. + + strideR: integer + Stride length for `r`. + + c: ArrayLikeObject + First column of the matrix. + + 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)`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Standard Usage: + > var r = [ 1.0, 2.0, 3.0 ]; + > var c = [ 1.0, 4.0, 5.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, r, 1, c, 1, out, 3 ) + [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + + // Using `N` and stride parameters: + > r = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + > c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 3, r, 2, c, 2, out, 3 ) + [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + + +{{alias}}.ndarray( N, r, sr, or, c, sc, oc, out, so1, so2, oo ) + Generates a Toeplitz matrix using alternative indexing semantics. + + The matrix is defined by its first row `r` and first column `c`. + + If `r[0]` and `c[0]` differ, `c[0]` is used for the diagonal. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + N: integer + Number of indexed elements in both `r` and `c`. + + r: ArrayLikeObject + First row of the matrix. + + sr: integer + Stride length for `r`. + + or: integer + Starting index for `r`. + + c: ArrayLikeObject + First column of the matrix. + + 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 = [ 1.0, 2.0, 3.0 ]; + > var c = [ 1.0, 4.0, 5.0 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + + // Using an index offset: + > r = [ 0.0, 1.0, 2.0, 3.0 ]; + > c = [ 0.0, 1.0, 4.0, 5.0 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, r, 1, 1, c, 1, 1, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/index.d.ts new file mode 100644 index 000000000000..884ad947058d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/index.d.ts @@ -0,0 +1,124 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// 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 `gtoeplitz`. +*/ +interface Routine { + /** + * Generates a Toeplitz matrix. + * + * @param order - storage layout + * @param N - number of indexed elements in both `r` and `c` + * @param r - first 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 = [ 1.0, 2.0, 3.0 ]; + * var c = [ 1.0, 4.0, 5.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); + * // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + */ + = OutputArray>( order: Layout, N: number, r: InputArray, strideR: number, c: InputArray, strideC: number, out: V, ldo: number ): V; + + /** + * Generates a Toeplitz matrix using alternative indexing semantics. + * + * @param N - number of indexed elements in both `r` and `c` + * @param r - first 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 = [ 1.0, 2.0, 3.0 ]; + * var c = [ 1.0, 4.0, 5.0 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); + * // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] + */ + ndarray = OutputArray>( 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 Toeplitz matrix. +* +* @param order - storage layout +* @param N - number of indexed elements in both `r` and `c` +* @param r - first 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 = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +* +* @example +* var r = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +*/ +declare var gtoeplitz: Routine; + + +// EXPORTS // + +export = gtoeplitz; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/test.ts new file mode 100644 index 000000000000..f059757cacb8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/docs/types/test.ts @@ -0,0 +1,374 @@ +/* +* @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 gtoeplitz = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); // $ExpectType Float64Array + gtoeplitz( 'row-major', 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 ); + + gtoeplitz( 10, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( true, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( false, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( null, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( undefined, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( [], 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( {}, 3, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( ( x: number ): number => x, 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 ); + + gtoeplitz( 'row-major', '10', r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', true, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', false, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', null, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', undefined, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', [], r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', {}, r, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', ( x: number ): number => x, r, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz( 'row-major', 3, 10, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, true, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, false, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, null, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, undefined, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, {}, 1, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, ( x: number ): number => x, 1, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function 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 ); + + gtoeplitz( 'row-major', 3, r, '10', c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, true, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, false, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, null, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, undefined, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, [], c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, {}, c, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, ( x: number ): number => x, c, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz( 'row-major', 3, r, 1, 10, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, true, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, false, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, null, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, undefined, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, {}, 1, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, ( x: number ): number => x, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz( 'row-major', 3, r, 1, c, '10', out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, true, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, false, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, null, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, undefined, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, [], out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, {}, out, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, ( x: number ): number => x, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + + gtoeplitz( 'row-major', 3, r, 1, c, 1, 10, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, true, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, false, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, null, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, undefined, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, {}, 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function 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 ); + + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, '10' ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, true ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, false ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, null ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, undefined ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, [] ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, {} ); // $ExpectError + gtoeplitz( 'row-major', 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 ); + + gtoeplitz(); // $ExpectError + gtoeplitz( 'row-major' ); // $ExpectError + gtoeplitz( 'row-major', 3 ); // $ExpectError + gtoeplitz( 'row-major', 3, r ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1 ); // $ExpectError + gtoeplitz( 'row-major', 3, r, 1, c, 1, out ); // $ExpectError + gtoeplitz( 'row-major', 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 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectType Float64Array + gtoeplitz.ndarray( 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 ); + + gtoeplitz.ndarray( '10', r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( true, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( false, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( null, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( undefined, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( [], r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( {}, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( ( 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 second argument which is not a collection... +{ + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, 10, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, true, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, false, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, null, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, undefined, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, {}, 1, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 third argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, '10', 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, true, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, false, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, null, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, undefined, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, [], 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, {}, 0, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 fourth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, '10', c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, true, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, false, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, null, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, undefined, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, [], c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, {}, c, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 fifth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, 10, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, true, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, false, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, null, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, undefined, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, {}, 1, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 sixth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, '10', 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, true, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, false, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, null, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, undefined, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, [], 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, {}, 0, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 a seventh argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, '10', out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, true, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, false, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, null, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, undefined, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, [], out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, {}, out, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 an eighth argument which is not a collection... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, 10, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, true, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, false, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, null, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, undefined, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, {}, 3, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 ninth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, '10', 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, true, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, false, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, null, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, undefined, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, [], 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, {}, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 a tenth argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, '10', 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, true, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, false, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, null, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, undefined, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, [], 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, {}, 0 ); // $ExpectError + gtoeplitz.ndarray( 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 an eleventh argument which is not a number... +{ + const r = new Float64Array( 3 ); + const c = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, '10' ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, true ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, false ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, null ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, undefined ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, [] ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, {} ); // $ExpectError + gtoeplitz.ndarray( 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 ); + + gtoeplitz.ndarray(); // $ExpectError + gtoeplitz.ndarray( 3 ); // $ExpectError + gtoeplitz.ndarray( 3, r ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1 ); // $ExpectError + gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/examples/index.js new file mode 100644 index 000000000000..c0ac8be44a88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/examples/index.js @@ -0,0 +1,45 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var 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 gtoeplitz = require( './../lib' ); + +var N = 4; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var r = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'r:', r ); + +var c = discreteUniform( N, 0, 10, { + 'dtype': 'generic' +}); +console.log( 'c:', c ); + +var out = zeros( N*N, 'generic' ); + +gtoeplitz( order, 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/gtoeplitz/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/accessors.js new file mode 100644 index 000000000000..0fdd2fa34c96 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/accessors.js @@ -0,0 +1,91 @@ +/** +* @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'; + +// MAIN // + +/** +* Generates a Toeplitz matrix using accessor arrays. +* +* @private +* @param {NonNegativeInteger} N - number of indexed elements in both `r` and `c` +* @param {Object} r - first row array object +* @param {integer} strideR - stride length for `r` +* @param {NonNegativeInteger} offsetR - starting index for `r` +* @param {Object} c - first column array object +* @param {integer} strideC - stride length for `c` +* @param {NonNegativeInteger} offsetC - starting index for `c` +* @param {Object} out - output array object +* @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 array object +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* var arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +* +* var r = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz( 3, arraylike2object( toAccessorArray ( r ) ), 1, 0, arraylike2object( toAccessorArray( c ) ), 1, 0, arraylike2object( toAccessorArray( out ) ), 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +*/ +function gtoeplitz( 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 io; + var ij; + var i; + var j; + + rbuf = r.data; + cbuf = c.data; + obuf = out.data; + getR = r.accessors[ 0 ]; + getC = c.accessors[ 0 ]; + oset = out.accessors[ 1 ]; + + io = offsetOut; + for ( i = 0; i < N; i++ ) { + ij = io; + for ( j = 0; j < N; j++ ) { + if ( j > i ) { + oset( obuf, ij, getR( rbuf, offsetR + ( ( j - i ) * strideR ) ) ); + } else { + oset( obuf, ij, getC( cbuf, offsetC + ( ( i - j ) * strideC ) ) ); + } + ij += strideOut2; + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gtoeplitz; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/index.js new file mode 100644 index 000000000000..592f46ffe513 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/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 Toeplitz matrix. +* +* @module @stdlib/blas/ext/base/gtoeplitz +* +* @example +* var gtoeplitz = require( '@stdlib/blas/ext/base/gtoeplitz' ); +* +* var r = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +* +* @example +* var gtoeplitz = require( '@stdlib/blas/ext/base/gtoeplitz' ); +* +* var r = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz.ndarray( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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/gtoeplitz/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/main.js new file mode 100644 index 000000000000..2dbae705d7dd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/main.js @@ -0,0 +1,90 @@ +/** +* @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 Toeplitz matrix. +* +* @param {(integer|string)} order - storage layout +* @param {NonNegativeInteger} N - number of indexed elements in both `r` and `c` +* @param {Collection} r - first 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} eighth argument must be a valid stride +* @returns {Collection} output matrix +* +* @example +* var r = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +*/ +function gtoeplitz( order, N, r, strideR, c, strideC, out, ldo ) { + var iscm; + 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 ) ); + } + if ( ldo < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, ldo ) ); + } + if ( N <= 0 ) { + return out; + } + or = stride2offset( N, strideR ); + oc = stride2offset( N, strideC ); + iscm = isColumnMajor( l ); + if ( iscm ) { + sa1 = 1; + sa2 = ldo; + } else { // order === 'row-major' + sa1 = ldo; + sa2 = 1; + } + return ndarray( N, r, strideR, or, c, strideC, oc, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = gtoeplitz; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/ndarray.js new file mode 100644 index 000000000000..6165ff33cc27 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/lib/ndarray.js @@ -0,0 +1,93 @@ +/** +* @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 accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Generates a Toeplitz matrix using alternative indexing semantics. +* +* @param {NonNegativeInteger} N - number of indexed elements in both `r` and `c` +* @param {Collection} r - first 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 = [ 1.0, 2.0, 3.0 ]; +* var c = [ 1.0, 4.0, 5.0 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gtoeplitz( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ] +*/ +function gtoeplitz( N, r, strideR, offsetR, c, strideC, offsetC, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var ro; + var co; + var oo; + var io; + var ij; + var i; + var j; + + if ( N <= 0 ) { + return out; + } + ro = arraylike2object( r ); + co = arraylike2object( c ); + oo = arraylike2object( out ); + if ( ro.accessorProtocol || co.accessorProtocol || oo.accessorProtocol ) { + accessors( N, ro, strideR, offsetR, co, strideC, offsetC, oo, strideOut1, strideOut2, offsetOut ); // eslint-disable-line max-len + return out; + } + io = offsetOut; + for ( i = 0; i < N; i++ ) { + ij = io; + for ( j = 0; j < N; j++ ) { + if ( j > i ) { + out[ ij ] = r[ offsetR + ( ( j - i ) * strideR ) ]; + } else { + out[ ij ] = c[ offsetC + ( ( i - j ) * strideC ) ]; + } + ij += strideOut2; + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gtoeplitz; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/package.json b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/package.json new file mode 100644 index 000000000000..8ab8ce5220ec --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/blas/ext/base/gtoeplitz", + "version": "0.0.0", + "description": "Generate a Toeplitz 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", + "toeplitz", + "matrix", + "strided", + "strided array", + "typed", + "array", + "ndarray", + "vector", + "gtoeplitz" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.js new file mode 100644 index 000000000000..4acd0d93b90b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/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 gtoeplitz = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gtoeplitz, '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 gtoeplitz.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.main.js new file mode 100644 index 000000000000..9c8a1876269a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.main.js @@ -0,0 +1,672 @@ +/** +* @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 gtoeplitz = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gtoeplitz, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( gtoeplitz.length, 8, '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() { + gtoeplitz( value, 3, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 4.0, 5.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() { + gtoeplitz( value, 3, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 4.0, 5.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 eighth 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() { + gtoeplitz( 'row-major', 3, [ 1.0, 2.0, 3.0 ], 1, [ 1.0, 4.0, 5.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 eighth 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() { + gtoeplitz( 'row-major', 3, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 1.0, 4.0, 5.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 `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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 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 Toeplitz matrix (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, r, 1, c, 1, out, 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, r, 2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, toAccessorArray( r ), 2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, r, 1, c, 2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, r, -2, c, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, toAccessorArray( r ), -2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, r, 1, c, -2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, r, 2, c, 1, out, 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, toAccessorArray( r ), 2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, r, 1, c, 2, out, 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, r, -2, c, 1, out, 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, toAccessorArray( r ), -2, toAccessorArray( c ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, r, 1, c, -2, out, 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 3, toAccessorArray( r ), 1, toAccessorArray( c ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 2, r, 1, c, 1, out, 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 3.0, + 1.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 = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'row-major', 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 2.0, + 0.0, + 0.0, + 3.0, + 1.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `N` (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 2, r, 1, c, 1, out, 4 ); + + expected = [ + 1.0, + 3.0, + 0.0, + 0.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports an `ldo` larger than `N` (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 'column-major', 2, toAccessorArray( r ), 1, toAccessorArray( c ), 1, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 3.0, + 0.0, + 0.0, + 2.0, + 1.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, 1.0, 2.0, 3.0 ] ); + c0 = new Float64Array( [ 0.0, 1.0, 4.0, 5.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 ); + + gtoeplitz( 'row-major', 3, r1, 1, c1, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 2.0, + 5.0, + 4.0, + 1.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.ndarray.js new file mode 100644 index 000000000000..0cccbbf0c8f8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gtoeplitz/test/test.ndarray.js @@ -0,0 +1,619 @@ +/** +* @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 gtoeplitz = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gtoeplitz, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( gtoeplitz.length, 11, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (row-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (column-major)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Toeplitz matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var r; + var c; + + r = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 2, 0, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 2, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, 2, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 2, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, -2, 4, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), -2, 4, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, -2, 4, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), -2, 4, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 2, 0, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 2, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, 2, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 1.0, 0.0, 4.0, 0.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 2, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, -2, 4, c, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), -2, 4, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, -2, 4, out, 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ 5.0, 0.0, 4.0, 0.0, 1.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), -2, 4, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 4.0, 5.0, 2.0, 1.0, 4.0, 3.0, 2.0, 1.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, + 1.0, // 0 + 2.0, // 1 + 3.0 // 2 + ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 1, c, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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, + 1.0, // 0 + 2.0, // 1 + 3.0 // 2 + ]; + c = [ 1.0, 4.0, 5.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 1, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ + 0.0, + 1.0, // 0 + 4.0, // 1 + 5.0 // 2 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, r, 1, 0, c, 1, 1, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0, 3.0 ]; + c = [ + 0.0, + 1.0, // 0 + 4.0, // 1 + 5.0 // 2 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 3, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 1, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 4.0, 1.0, 2.0, 5.0, 4.0, 1.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 = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 2, r, 1, 0, c, 1, 0, out, 2, 1, 2 ); + + expected = [ 0.0, 0.0, 1.0, 2.0, 3.0, 1.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 = [ 1.0, 2.0 ]; + c = [ 1.0, 3.0 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 2, toAccessorArray( r ), 1, 0, toAccessorArray( c ), 1, 0, toAccessorArray( out ), 2, 1, 2 ); + + expected = [ 0.0, 0.0, 1.0, 2.0, 3.0, 1.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, + 1.0, // 0 + 0.0, + 2.0 // 1 + ]; + c = [ + 0.0, + 1.0, // 0 + 0.0, + 3.0 // 1 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 2, r, 2, 1, c, 2, 1, out, 2, -1, 1 ); + + expected = [ 2.0, 1.0, 1.0, 3.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, + 1.0, // 0 + 0.0, + 2.0 // 1 + ]; + c = [ + 0.0, + 1.0, // 0 + 0.0, + 3.0 // 1 + ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gtoeplitz( 2, toAccessorArray( r ), 2, 1, toAccessorArray( c ), 2, 1, toAccessorArray( out ), 2, -1, 1 ); + + expected = [ 2.0, 1.0, 1.0, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +});