diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/README.md b/lib/node_modules/@stdlib/blas/ext/base/gleslie/README.md new file mode 100644 index 000000000000..bb6f531f5b90 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/README.md @@ -0,0 +1,203 @@ + + +# gleslie + +> Generate a Leslie matrix. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gleslie = require( '@stdlib/blas/ext/base/gleslie' ); +``` + +#### gleslie( order, N, f, strideF, s, strideS, out, ldo ) + +Generates a Leslie matrix. + +```javascript +var f = [ 1.0, 2.0, 3.0 ]; +var s = [ 0.4, 0.5 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); +// out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +``` + +The function has the following parameters: + +- **order**: row-major (C-style) or column-major (Fortran-style) order. +- **N**: number of fecundity coefficients (i.e., the number of rows and columns of the output matrix). +- **f**: fecundity coefficients ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). +- **strideF**: stride length for `f`. +- **s**: survival coefficients ([`Array`][mdn-array] or [`typed array`][mdn-typed-array]). Must have at least `N-1` indexed elements. +- **strideS**: stride length for `s`. +- **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 f0 = new Float64Array( [ 999.0, 1.0, 2.0, 3.0 ] ); +var s0 = new Float64Array( [ 999.0, 0.4, 0.5 ] ); +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 f1 = new Float64Array( f0.buffer, f0.BYTES_PER_ELEMENT*1 ); +var s1 = new Float64Array( s0.buffer, s0.BYTES_PER_ELEMENT*1 ); +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + +gleslie( 'row-major', 3, f1, 1, s1, 1, out1, 3 ); +// out0 => [ 0.0, 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +``` + + + +#### gleslie.ndarray( N, f, strideF, offsetF, s, strideS, offsetS, out, strideOut1, strideOut2, offsetOut ) + + + +Generates a Leslie matrix using alternative indexing semantics. + +```javascript +var f = [ 1.0, 2.0, 3.0 ]; +var s = [ 0.4, 0.5 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +``` + +The function has the following additional parameters: + +- **offsetF**: starting index for `f`. +- **offsetS**: starting index for `s`. +- **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 fecundity array starting from the second element: + +```javascript +var f = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; +var s = [ 0.0, 0.4, 0.0, 0.5 ]; +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gleslie.ndarray( 3, f, 2, 1, s, 2, 1, out, 3, 1, 0 ); +// out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N <= 0`, both functions return `out` unchanged. +- The output matrix is zero except for the first row, which contains the fecundity coefficients `f`, and the first sub-diagonal, which contains the survival coefficients `s`. +- 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 uniform = require( '@stdlib/random/array/uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var gleslie = require( '@stdlib/blas/ext/base/gleslie' ); + +var N = 4; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var opts = { + 'dtype': 'generic' +}; +var f = uniform( N, 0.0, 10.0, opts ); +console.log( 'f:', f ); + +var s = uniform( N - 1, 0.0, 1.0, opts ); +console.log( 's:', s ); + +var out = zeros( N*N, 'generic' ); + +gleslie( order, N, f, 1, s, 1, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/benchmark/benchmark.js new file mode 100644 index 000000000000..04508db7ac3d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 gleslie = 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 f = uniform( len, 0.0, 10.0, options ); + var s = uniform( len - 1, 0.0, 1.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++ ) { + f[ 0 ] += 0.1; + v = gleslie( 'row-major', len, f, 1, s, 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/gleslie/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..ed8c8a19e304 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 gleslie = 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 f = uniform( len, 0.0, 10.0, options ); + var s = uniform( len - 1, 0.0, 1.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++ ) { + f[ 0 ] += 0.1; + v = gleslie( len, f, 1, 0, s, 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/gleslie/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/repl.txt new file mode 100644 index 000000000000..1111b8c55b62 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/repl.txt @@ -0,0 +1,126 @@ + +{{alias}}( order, N, f, strideF, s, strideS, out, ldo ) + Generates a Leslie matrix. + + The `N` and stride parameters determine which elements in the strided arrays + are accessed at runtime. + + If `N` is less than or equal to `0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Storage layout. + + N: integer + Number of fecundity coefficients (i.e., the number of rows and columns + of the output matrix). + + f: ArrayLikeObject + Fecundity coefficients. + + strideF: integer + Stride length for `f`. + + s: ArrayLikeObject + Survival coefficients. Must have at least `N-1` indexed elements. + + strideS: integer + Stride length for `s`. + + 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 f = [ 1.0, 2.0, 3.0 ]; + > var s = [ 0.4, 0.5 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 3, f, 1, s, 1, out, 3 ) + [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + + // Using `N` and stride parameters: + > f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + > s = [ 0.4, 0.0, 0.5 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}( 'row-major', 3, f, 2, s, 2, out, 3 ) + [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + + +{{alias}}.ndarray( N, f, sf, of, s, ss, os, out, so1, so2, oo ) + Generates a Leslie 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 + ---------- + N: integer + Number of fecundity coefficients (i.e., the number of rows and columns + of the output matrix). + + f: ArrayLikeObject + Fecundity coefficients. + + sf: integer + Stride length for `f`. + + of: integer + Starting index for `f`. + + s: ArrayLikeObject + Survival coefficients. Must have at least `N-1` indexed elements. + + ss: integer + Stride length for `s`. + + os: integer + Starting index for `s`. + + 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 f = [ 1.0, 2.0, 3.0 ]; + > var s = [ 0.4, 0.5 ]; + > var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + + // Using an index offset: + > f = [ 0.0, 1.0, 2.0, 3.0 ]; + > s = [ 0.0, 0.4, 0.5 ]; + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 3, f, 1, 1, s, 1, 1, out, 3, 1, 0 ) + [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/types/index.d.ts new file mode 100644 index 000000000000..d7a96099f7fc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 `gleslie`. +*/ +interface Routine { + /** + * Generates a Leslie matrix. + * + * @param order - storage layout + * @param N - number of fecundity coefficients + * @param f - fecundity coefficients + * @param strideF - stride length for `f` + * @param s - survival coefficients + * @param strideS - stride length for `s` + * @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 f = [ 1.0, 2.0, 3.0 ]; + * var s = [ 0.4, 0.5 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); + * // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + */ + = OutputArray>( order: Layout, N: number, f: InputArray, strideF: number, s: InputArray, strideS: number, out: V, ldo: number ): V; + + /** + * Generates a Leslie matrix using alternative indexing semantics. + * + * @param N - number of fecundity coefficients + * @param f - fecundity coefficients + * @param strideF - stride length for `f` + * @param offsetF - starting index for `f` + * @param s - survival coefficients + * @param strideS - stride length for `s` + * @param offsetS - starting index for `s` + * @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 f = [ 1.0, 2.0, 3.0 ]; + * var s = [ 0.4, 0.5 ]; + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); + * // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] + */ + ndarray = OutputArray>( N: number, f: InputArray, strideF: number, offsetF: number, s: InputArray, strideS: number, offsetS: number, out: V, strideOut1: number, strideOut2: number, offsetOut: number ): V; +} + +/** +* Generates a Leslie matrix. +* +* @param order - storage layout +* @param N - number of fecundity coefficients +* @param f - fecundity coefficients +* @param strideF - stride length for `f` +* @param s - survival coefficients +* @param strideS - stride length for `s` +* @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 f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +* +* @example +* var f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +*/ +declare var gleslie: Routine; + + +// EXPORTS // + +export = gleslie; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gleslie/docs/types/test.ts new file mode 100644 index 000000000000..58bdca2b12e2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 gleslie = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); // $ExpectType Float64Array + gleslie( 'row-major', 3, new AccessorArray( f ), 1, new AccessorArray( s ), 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 10, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( true, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( false, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( null, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( undefined, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( [], 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( {}, 3, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( ( x: number ): number => x, 3, f, 1, s, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', '10', f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', true, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', false, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', null, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', undefined, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', [], f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', {}, f, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', ( x: number ): number => x, f, 1, s, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a collection... +{ + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, 10, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, true, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, false, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, null, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, undefined, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, {}, 1, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, ( x: number ): number => x, 1, s, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f, '10', s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, true, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, false, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, null, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, undefined, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, [], s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, {}, s, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, ( x: number ): number => x, s, 1, out, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a collection... +{ + const f = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f, 1, 10, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, true, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, false, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, null, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, undefined, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, {}, 1, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f, 1, s, '10', out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, true, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, false, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, null, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, undefined, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, [], out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, {}, out, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, ( 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + + gleslie( 'row-major', 3, f, 1, s, 1, 10, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, true, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, false, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, null, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, undefined, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, {}, 3 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f, 1, s, 1, out, '10' ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, true ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, false ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, null ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, undefined ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, [] ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, {} ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie(); // $ExpectError + gleslie( 'row-major' ); // $ExpectError + gleslie( 'row-major', 3 ); // $ExpectError + gleslie( 'row-major', 3, f ); // $ExpectError + gleslie( 'row-major', 3, f, 1 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1 ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out ); // $ExpectError + gleslie( 'row-major', 3, f, 1, s, 1, out, 3, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a collection... +{ + const f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectType Float64Array + gleslie.ndarray( 3, new AccessorArray( f ), 1, 0, new AccessorArray( s ), 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( '10', f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( true, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( false, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( null, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( undefined, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( [], f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( {}, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( ( x: number ): number => x, f, 1, 0, s, 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 s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, 10, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, true, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, false, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, null, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, undefined, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, {}, 1, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, ( x: number ): number => x, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, '10', 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, true, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, false, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, null, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, undefined, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, [], 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, {}, 0, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, ( x: number ): number => x, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, '10', s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, true, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, false, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, null, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, undefined, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, [], s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, {}, s, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, ( x: number ): number => x, s, 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 f = new Float64Array( 3 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, 10, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, true, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, false, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, null, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, undefined, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, {}, 1, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, '10', 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, true, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, false, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, null, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, undefined, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, [], 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, {}, 0, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, ( 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, '10', out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, true, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, false, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, null, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, undefined, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, [], out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, {}, out, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, 10, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, true, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, false, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, null, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, undefined, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, {}, 3, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, '10', 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, true, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, false, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, null, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, undefined, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, [], 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, {}, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, '10', 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, true, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, false, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, null, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, undefined, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, [], 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, {}, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, '10' ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, true ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, false ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, null ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, undefined ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, [] ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, {} ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 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 f = new Float64Array( 3 ); + const s = new Float64Array( 2 ); + const out = new Float64Array( 9 ); + + gleslie.ndarray(); // $ExpectError + gleslie.ndarray( 3 ); // $ExpectError + gleslie.ndarray( 3, f ); // $ExpectError + gleslie.ndarray( 3, f, 1 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1 ); // $ExpectError + gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/examples/index.js new file mode 100644 index 000000000000..2cce11ecd46b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/examples/index.js @@ -0,0 +1,44 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var gleslie = require( './../lib' ); + +var N = 4; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var opts = { + 'dtype': 'generic' +}; +var f = uniform( N, 0.0, 10.0, opts ); +console.log( 'f:', f ); + +var s = uniform( N - 1, 0.0, 1.0, opts ); +console.log( 's:', s ); + +var out = zeros( N*N, 'generic' ); + +gleslie( order, N, f, 1, s, 1, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/accessors.js new file mode 100644 index 000000000000..fe5aede7cca6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/accessors.js @@ -0,0 +1,100 @@ +/** +* @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 Leslie matrix using accessor arrays. +* +* @private +* @param {NonNegativeInteger} N - number of fecundity coefficients +* @param {Object} f - fecundity coefficients array object +* @param {integer} strideF - stride length for `f` +* @param {NonNegativeInteger} offsetF - starting index for `f` +* @param {Object} s - survival coefficients array object +* @param {integer} strideS - stride length for `s` +* @param {NonNegativeInteger} offsetS - starting index for `s` +* @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 f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie( 3, arraylike2object( toAccessorArray( f ) ), 1, 0, arraylike2object( toAccessorArray( s ) ), 1, 0, arraylike2object( toAccessorArray( out ) ), 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +*/ +function gleslie( N, f, strideF, offsetF, s, strideS, offsetS, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var fbuf; + var sbuf; + var obuf; + var getF; + var getS; + var oset; + var io; + var ij; + var i; + var j; + + fbuf = f.data; + sbuf = s.data; + obuf = out.data; + getF = f.accessors[ 0 ]; + getS = s.accessors[ 0 ]; + oset = out.accessors[ 1 ]; + + // Set the first row to the fecundity coefficients: + ij = offsetOut; + for ( j = 0; j < N; j++ ) { + oset( obuf, ij, getF( fbuf, offsetF + ( j * strideF ) ) ); + ij += strideOut2; + } + // Set the sub-diagonal to the survival coefficients and fill remaining elements with zeros: + io = offsetOut + strideOut1; + for ( i = 1; i < N; i++ ) { + ij = io; + for ( j = 0; j < i - 1; j++ ) { + oset( obuf, ij, 0.0 ); + ij += strideOut2; + } + oset( obuf, ij, getS( sbuf, offsetS + ( ( i - 1 ) * strideS ) ) ); + ij += strideOut2; + for ( j = i; j < N; j++ ) { + oset( obuf, ij, 0.0 ); + ij += strideOut2; + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gleslie; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/index.js new file mode 100644 index 000000000000..a0eb973d0ff9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 Leslie matrix. +* +* @module @stdlib/blas/ext/base/gleslie +* +* @example +* var gleslie = require( '@stdlib/blas/ext/base/gleslie' ); +* +* var f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +* +* @example +* var gleslie = require( '@stdlib/blas/ext/base/gleslie' ); +* +* var f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie.ndarray( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.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/gleslie/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/main.js new file mode 100644 index 000000000000..b52a02755e4f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 Leslie matrix. +* +* @param {(integer|string)} order - storage layout +* @param {NonNegativeInteger} N - number of fecundity coefficients +* @param {Collection} f - fecundity coefficients +* @param {integer} strideF - stride length for `f` +* @param {Collection} s - survival coefficients +* @param {integer} strideS - stride length for `s` +* @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 f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +*/ +function gleslie( order, N, f, strideF, s, strideS, out, ldo ) { + var iscm; + var sa1; + var sa2; + var of; + var os; + 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; + } + of = stride2offset( N, strideF ); + os = stride2offset( N - 1, strideS ); + iscm = isColumnMajor( l ); + if ( iscm ) { + sa1 = 1; + sa2 = ldo; + } else { // order === 'row-major' + sa1 = ldo; + sa2 = 1; + } + return ndarray( N, f, strideF, of, s, strideS, os, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = gleslie; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/ndarray.js new file mode 100644 index 000000000000..539b010169cc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/lib/ndarray.js @@ -0,0 +1,102 @@ +/** +* @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 Leslie matrix using alternative indexing semantics. +* +* @param {NonNegativeInteger} N - number of fecundity coefficients +* @param {Collection} f - fecundity coefficients +* @param {integer} strideF - stride length for `f` +* @param {NonNegativeInteger} offsetF - starting index for `f` +* @param {Collection} s - survival coefficients +* @param {integer} strideS - stride length for `s` +* @param {NonNegativeInteger} offsetS - starting index for `s` +* @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 f = [ 1.0, 2.0, 3.0 ]; +* var s = [ 0.4, 0.5 ]; +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gleslie( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); +* // out => [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ] +*/ +function gleslie( N, f, strideF, offsetF, s, strideS, offsetS, out, strideOut1, strideOut2, offsetOut ) { // eslint-disable-line max-len + var fo; + var so; + var oo; + var io; + var ij; + var i; + var j; + + if ( N <= 0 ) { + return out; + } + fo = arraylike2object( f ); + so = arraylike2object( s ); + oo = arraylike2object( out ); + if ( fo.accessorProtocol || so.accessorProtocol || oo.accessorProtocol ) { + accessors( N, fo, strideF, offsetF, so, strideS, offsetS, oo, strideOut1, strideOut2, offsetOut ); // eslint-disable-line max-len + return out; + } + // Set the first row to the fecundity coefficients: + ij = offsetOut; + for ( j = 0; j < N; j++ ) { + out[ ij ] = f[ offsetF + ( j * strideF ) ]; + ij += strideOut2; + } + // Set the sub-diagonal to the survival coefficients and fill remaining elements with zeros: + io = offsetOut + strideOut1; + for ( i = 1; i < N; i++ ) { + ij = io; + for ( j = 0; j < i - 1; j++ ) { + out[ ij ] = 0.0; + ij += strideOut2; + } + out[ ij ] = s[ offsetS + ( ( i - 1 ) * strideS ) ]; + ij += strideOut2; + for ( j = i; j < N; j++ ) { + out[ ij ] = 0.0; + ij += strideOut2; + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gleslie; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/package.json b/lib/node_modules/@stdlib/blas/ext/base/gleslie/package.json new file mode 100644 index 000000000000..54257ec7b61e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/gleslie", + "version": "0.0.0", + "description": "Generate a Leslie 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", + "leslie", + "matrix", + "strided", + "strided array", + "typed", + "array", + "ndarray", + "vector", + "gleslie", + "population", + "fecundity", + "survival" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.js new file mode 100644 index 000000000000..6232370fb4b9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/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 gleslie = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gleslie, '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 gleslie.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.main.js new file mode 100644 index 000000000000..a631b0919ad6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.main.js @@ -0,0 +1,670 @@ +/** +* @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 gleslie = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gleslie, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( gleslie.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() { + gleslie( value, 3, [ 1.0, 2.0, 3.0 ], 1, [ 0.4, 0.5 ], 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() { + gleslie( value, 3, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 0.4, 0.5 ] ), 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, + 2 + ]; + + 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() { + gleslie( 'row-major', 3, [ 1.0, 2.0, 3.0 ], 1, [ 0.4, 0.5 ], 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, + 2 + ]; + + 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() { + gleslie( 'row-major', 3, toAccessorArray( [ 1.0, 2.0, 3.0 ] ), 1, toAccessorArray( [ 0.4, 0.5 ] ), 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 f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 0, f, 1, s, 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 f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 0, toAccessorArray( f ), 1, toAccessorArray( s ), 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 returns the output matrix', function test( t ) { + var out; + var f; + var s; + var v; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + v = gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output matrix (accessors)', function test( t ) { + var out; + var f; + var s; + var v; + + f = toAccessorArray( [ 1.0, 2.0, 3.0 ] ); + s = toAccessorArray( [ 0.4, 0.5 ] ); + out = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + v = gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, 1, s, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, 1, s, 1, out, 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, 2, s, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), 2, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, 1, s, 2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, -2, s, 1, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), -2, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, 1, s, -2, out, 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a leading dimension for the output matrix (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, f, 1, s, 1, out, 4 ); + + expected = [ 1.0, 2.0, 3.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a leading dimension for the output matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'row-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 1, toAccessorArray( out ), 4 ); + + expected = [ 1.0, 2.0, 3.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a leading dimension for the output matrix (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, 1, s, 1, out, 4 ); + + expected = [ 1.0, 0.4, 0.0, 0.0, 2.0, 0.0, 0.5, 0.0, 3.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a leading dimension for the output matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 1, toAccessorArray( out ), 4 ); + + expected = [ 1.0, 0.4, 0.0, 0.0, 2.0, 0.0, 0.5, 0.0, 3.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, 2, s, 1, out, 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), 2, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, 1, s, 2, out, 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), 2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, -2, s, 1, out, 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), -2, toAccessorArray( s ), 1, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, f, 1, s, -2, out, 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 'column-major', 3, toAccessorArray( f ), 1, toAccessorArray( s ), -2, toAccessorArray( out ), 3 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 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 f0; + var f1; + var s0; + var s1; + + f0 = new Float64Array( [ 0.0, 1.0, 2.0, 3.0 ] ); + s0 = new Float64Array( [ 0.0, 0.4, 0.5 ] ); + + f1 = new Float64Array( f0.buffer, f0.BYTES_PER_ELEMENT*1 ); + s1 = new Float64Array( s0.buffer, s0.BYTES_PER_ELEMENT*1 ); + + out = new Float64Array( 9 ); + + gleslie( 'row-major', 3, f1, 1, s1, 1, out, 3 ); + + expected = new Float64Array([ + 1.0, + 2.0, + 3.0, + 0.4, + 0.0, + 0.0, + 0.0, + 0.5, + 0.0 + ]); + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.ndarray.js new file mode 100644 index 000000000000..f36d5a872f80 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gleslie/test/test.ndarray.js @@ -0,0 +1,683 @@ +/** +* @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 gleslie = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gleslie, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( gleslie.length, 11, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a Leslie matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.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 f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 0, f, 1, 0, s, 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 f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 0, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 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 returns the output matrix', function test( t ) { + var out; + var f; + var s; + var v; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + v = gleslie( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output matrix (accessors)', function test( t ) { + var out; + var f; + var s; + var v; + + f = toAccessorArray( [ 1.0, 2.0, 3.0 ] ); + s = toAccessorArray( [ 0.4, 0.5 ] ); + out = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + v = gleslie( 3, f, 1, 0, s, 1, 0, out, 3, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 2, 0, s, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 2, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 2, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 2, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 2, 0, s, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `f` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 2, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 2, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a stride for `s` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 2, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, -2, 4, s, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), -2, 4, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, -2, 2, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), -2, 2, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, -2, 4, s, 1, 0, out, 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `f` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 3.0, 0.0, 2.0, 0.0, 1.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), -2, 4, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, -2, 2, out, 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying a negative stride for `s` (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.5, 0.0, 0.4 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), -2, 2, toAccessorArray( out ), 1, 3, 0 ); + + expected = [ 1.0, 0.4, 0.0, 2.0, 0.0, 0.5, 3.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `f`', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 0.0, 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 1, s, 1, 0, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `f` (accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 0.0, 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 1, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `s`', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.0, 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 1, out, 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `s` (accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.0, 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 1, toAccessorArray( out ), 3, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `out`', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 0, out, 3, 1, 1 ); + + expected = [ 0.0, 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `out` (accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 3, 1, 1 ); + + expected = [ 0.0, 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 0, out, 4, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 4, 1, 0 ); + + expected = [ 1.0, 2.0, 3.0, 0.0, 0.4, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (column-major)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 1, 0, s, 1, 0, out, 1, 4, 0 ); + + expected = [ 1.0, 0.4, 0.0, 0.0, 2.0, 0.0, 0.5, 0.0, 3.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (column-major, accessors)', function test( t ) { + var expected; + var out; + var f; + var s; + + f = [ 1.0, 2.0, 3.0 ]; + s = [ 0.4, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 1, 0, toAccessorArray( s ), 1, 0, toAccessorArray( out ), 1, 4, 0 ); + + expected = [ 1.0, 0.4, 0.0, 0.0, 2.0, 0.0, 0.5, 0.0, 3.0, 0.0, 0.0, 0.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 f; + var s; + + f = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.0, 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, f, 2, 1, s, 2, 1, out, 3, 1, 1 ); + + expected = [ 0.0, 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 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 f; + var s; + + f = [ 0.0, 1.0, 0.0, 2.0, 0.0, 3.0 ]; + s = [ 0.0, 0.4, 0.0, 0.5 ]; + out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + + gleslie( 3, toAccessorArray( f ), 2, 1, toAccessorArray( s ), 2, 1, toAccessorArray( out ), 3, 1, 1 ); + + expected = [ 0.0, 1.0, 2.0, 3.0, 0.4, 0.0, 0.0, 0.0, 0.5, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +});