From d90f10d721d352eb9565a3cbbdb0ce0ec5fd233e Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 17 Oct 2026 17:50:17 +0500 Subject: [PATCH 1/2] feat: add blas/ext/base/gpascal --- .../@stdlib/blas/ext/base/gpascal/README.md | 189 +++ .../ext/base/gpascal/benchmark/benchmark.js | 103 ++ .../gpascal/benchmark/benchmark.ndarray.js | 103 ++ .../blas/ext/base/gpascal/docs/repl.txt | 95 ++ .../ext/base/gpascal/docs/types/index.d.ts | 112 ++ .../blas/ext/base/gpascal/docs/types/test.ts | 214 +++ .../blas/ext/base/gpascal/examples/index.js | 34 + .../blas/ext/base/gpascal/lib/accessors.js | 104 ++ .../blas/ext/base/gpascal/lib/index.js | 73 + .../@stdlib/blas/ext/base/gpascal/lib/main.js | 97 ++ .../blas/ext/base/gpascal/lib/ndarray.js | 122 ++ .../blas/ext/base/gpascal/package.json | 72 + .../blas/ext/base/gpascal/test/test.js | 38 + .../blas/ext/base/gpascal/test/test.main.js | 1179 ++++++++++++++++ .../ext/base/gpascal/test/test.ndarray.js | 1255 +++++++++++++++++ 15 files changed, 3790 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/README.md create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/accessors.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/package.json create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js create mode 100644 lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/README.md b/lib/node_modules/@stdlib/blas/ext/base/gpascal/README.md new file mode 100644 index 000000000000..cc104b1106d4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/README.md @@ -0,0 +1,189 @@ + + +# gpascal + +> Generate a Pascal matrix. + +
+ +
+ + + +
+ +## Usage + +```javascript +var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); +``` + +#### gpascal( order, uplo, N, out, ldo ) + +Generates a Pascal matrix. + +```javascript +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gpascal( 'row-major', 'symmetric', 3, out, 3 ); +// out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +``` + +To generate a lower triangular Pascal matrix: + +```javascript +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gpascal( 'row-major', 'lower', 3, out, 3 ); +// out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] +``` + +To generate an upper triangular Pascal matrix: + +```javascript +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gpascal( 'row-major', 'upper', 3, out, 3 ); +// out => [ 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies which form of the Pascal matrix to generate. Must be one of `'symmetric'`, `'lower'`, or `'upper'`. +- **N**: order of the Pascal matrix. +- **out**: output array. +- **ldo**: stride between successive contiguous vectors of the matrix `out` (a.k.a., leading dimension of the matrix `out`). + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial array: +var out0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create an offset view: +var out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + +gpascal( 'row-major', 'symmetric', 2, out1, 2 ); +// out0 => [ 0.0, 1.0, 1.0, 1.0, 2.0 ] +``` + +#### gpascal.ndarray( uplo, N, out, strideOut1, strideOut2, offsetOut ) + +Generates a Pascal matrix using alternative indexing semantics. + +```javascript +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gpascal.ndarray( 'symmetric', 3, out, 3, 1, 0 ); +// out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +``` + +The function has the following additional parameters: + +- **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, the offset parameter supports indexing semantics based on a starting index. For example, to start writing matrix elements from the second element of the output array: + +```javascript +var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + +gpascal.ndarray( 'symmetric', 3, out, 3, 1, 1 ); +// out => [ 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +``` + +
+ + + +
+ +## Notes + +- If `N` is less than or equal to `0`, both functions return `out` unchanged. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). + +
+ + + +
+ +## Examples + + + +```javascript +var ndarray2array = require( '@stdlib/ndarray/base/to-array' ); +var shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); + +var N = 5; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var out = zeros( N*N, 'generic' ); + +gpascal( order, 'symmetric', N, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.js new file mode 100644 index 000000000000..46577ac6c367 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.js @@ -0,0 +1,103 @@ +/** +* @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 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 gpascal = 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 ); + 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++ ) { + v = gpascal( 'row-major', 'symmetric', len, 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 = 2; // 2^min + max = 10; // 2^max + + for ( i = min; i <= max; i += 2 ) { + len = pow( 2, i ); + f = createBenchmark( len ); + bench( format( '%s:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..75da6cb84000 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/benchmark/benchmark.ndarray.js @@ -0,0 +1,103 @@ +/** +* @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 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 gpascal = 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 ); + 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++ ) { + v = gpascal( 'symmetric', len, 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 = 2; // 2^min + max = 10; // 2^max + + for ( i = min; i <= max; i += 2 ) { + len = pow( 2, i ); + f = createBenchmark( len ); + bench( format( '%s:ndarray:len=%d', pkg, len ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/repl.txt new file mode 100644 index 000000000000..d2111031c77b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/repl.txt @@ -0,0 +1,95 @@ + +{{alias}}( order, uplo, N, out, ldo ) + Generates a Pascal matrix. + + If `N` is less than or equal to `0`, the function returns `out` unchanged. + + Parameters + ---------- + order: string + Storage layout. + + uplo: string + Specifies which form of the Pascal matrix to generate. Must be one of + `'symmetric'`, `'lower'`, or `'upper'`. + + N: integer + Order of the Pascal matrix. + + out: ArrayLikeObject + Output array. + + ldo: integer + Stride length between successive contiguous vectors of the matrix + `out` (a.k.a., leading dimension of `out`). + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + // Symmetric Pascal matrix: + > var out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}( 'row-major', 'symmetric', 3, out, 3 ) + [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] + + // Lower triangular Pascal matrix: + > out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}( 'row-major', 'lower', 3, out, 3 ) + [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] + + // Upper triangular Pascal matrix: + > out = new {{alias:@stdlib/array/float64}}( 9 ); + > {{alias}}( 'row-major', 'upper', 3, out, 3 ) + [ 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] + + +{{alias}}.ndarray( uplo, N, out, so1, so2, oo ) + Generates a Pascal matrix using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a starting + index. + + Parameters + ---------- + uplo: string + Specifies which form of the Pascal matrix to generate. Must be one of + `'symmetric'`, `'lower'`, or `'upper'`. + + N: integer + Order of the Pascal matrix. + + 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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 'symmetric', 3, out, 3, 1, 0 ) + [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] + + // Using an index offset: + > out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + > {{alias}}.ndarray( 'symmetric', 3, out, 3, 1, 1 ) + [ 0.0, 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/index.d.ts new file mode 100644 index 000000000000..ef2dff42b67a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/index.d.ts @@ -0,0 +1,112 @@ +/* +* @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'; + +/** +* Output array. +*/ +type OutputArray = Collection | AccessorArrayLike; + +/** +* Interface describing `gpascal`. +*/ +interface Routine { + /** + * Generates a Pascal matrix. + * + * @param order - storage layout + * @param uplo - specifies which form of the Pascal matrix to generate + * @param N - order of the Pascal matrix + * @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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gpascal( 'row-major', 'symmetric', 3, out, 3 ); + * // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] + * + * @example + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gpascal( 'row-major', 'lower', 3, out, 3 ); + * // out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] + */ + = OutputArray>( order: Layout, uplo: string, N: number, out: V, ldo: number ): V; + + /** + * Generates a Pascal matrix using alternative indexing semantics. + * + * @param uplo - specifies which form of the Pascal matrix to generate + * @param N - order of the Pascal matrix + * @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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gpascal.ndarray( 'symmetric', 3, out, 3, 1, 0 ); + * // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] + * + * @example + * var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; + * + * gpascal.ndarray( 'lower', 3, out, 3, 1, 0 ); + * // out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] + */ + ndarray = OutputArray>( uplo: string, N: number, out: V, strideOut1: number, strideOut2: number, offsetOut: number ): V; +} + +/** +* Generates a Pascal matrix. +* +* @param order - storage layout +* @param uplo - specifies which form of the Pascal matrix to generate +* @param N - order of the Pascal matrix +* @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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'symmetric', 3, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal.ndarray( 'symmetric', 3, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +*/ +declare var gpascal: Routine; + + +// EXPORTS // + +export = gpascal; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/test.ts new file mode 100644 index 000000000000..f1b05e82f02a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/docs/types/test.ts @@ -0,0 +1,214 @@ +/* +* @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 gpascal = require( './index' ); + + +// TESTS // + +// The function returns a collection... +{ + const out = new Float64Array( 16 ); + + gpascal( 'row-major', 'symmetric', 4, out, 4 ); // $ExpectType Float64Array + gpascal( 'row-major', 'symmetric', 4, new AccessorArray( out ), 4 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the function is provided a first argument which is not a valid order... +{ + const out = new Float64Array( 16 ); + + gpascal( 10, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( true, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( false, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( null, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( undefined, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( [], 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( {}, 'symmetric', 4, out, 4 ); // $ExpectError + gpascal( ( x: number ): number => x, 'symmetric', 4, out, 4 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const out = new Float64Array( 16 ); + + gpascal( 'row-major', 10, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', true, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', false, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', null, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', undefined, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', [], 4, out, 4 ); // $ExpectError + gpascal( 'row-major', {}, 4, out, 4 ); // $ExpectError + gpascal( 'row-major', ( x: number ): number => x, 4, out, 4 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal( 'row-major', 'symmetric', '10', out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', true, out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', false, out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', null, out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', undefined, out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', [], out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', {}, out, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', ( x: number ): number => x, out, 4 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a collection... +{ + gpascal( 'row-major', 'symmetric', 4, 10, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, true, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, false, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, null, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, undefined, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, {}, 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, ( x: number ): number => x, 4 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal( 'row-major', 'symmetric', 4, out, '10' ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, true ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, false ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, null ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, undefined ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, [] ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, {} ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const out = new Float64Array( 16 ); + + gpascal(); // $ExpectError + gpascal( 'row-major' ); // $ExpectError + gpascal( 'row-major', 'symmetric' ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4 ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out ); // $ExpectError + gpascal( 'row-major', 'symmetric', 4, out, 4, 10 ); // $ExpectError +} + +// Attached to the main export is an `ndarray` method which returns a collection... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 'symmetric', 4, out, 4, 1, 0 ); // $ExpectType Float64Array + gpascal.ndarray( 'symmetric', 4, new AccessorArray( out ), 4, 1, 0 ); // $ExpectType AccessorArray +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a string... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 10, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( true, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( false, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( null, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( undefined, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( [], 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( {}, 4, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( ( x: number ): number => x, 4, out, 4, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 'symmetric', '10', out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', true, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', false, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', null, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', undefined, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', [], out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', {}, out, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', ( x: number ): number => x, out, 4, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a collection... +{ + gpascal.ndarray( 'symmetric', 4, 10, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, true, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, false, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, null, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, undefined, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, {}, 4, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, ( x: number ): number => x, 4, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 'symmetric', 4, out, '10', 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, true, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, false, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, null, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, undefined, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, [], 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, {}, 1, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 'symmetric', 4, out, 4, '10', 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, true, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, false, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, null, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, undefined, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, [], 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, {}, 0 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray( 'symmetric', 4, out, 4, 1, '10' ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, true ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, false ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, null ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, undefined ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, [] ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, {} ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const out = new Float64Array( 16 ); + + gpascal.ndarray(); // $ExpectError + gpascal.ndarray( 'symmetric' ); // $ExpectError + gpascal.ndarray( 'symmetric', 4 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1 ); // $ExpectError + gpascal.ndarray( 'symmetric', 4, out, 4, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/examples/index.js new file mode 100644 index 000000000000..ff6d92db0e99 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 shape2strides = require( '@stdlib/ndarray/base/shape2strides' ); +var zeros = require( '@stdlib/array/zeros' ); +var gpascal = require( './../lib' ); + +var N = 5; +var order = 'row-major'; +var shape = [ N, N ]; +var strides = shape2strides( shape, order ); + +var out = zeros( N*N, 'generic' ); + +gpascal( order, 'symmetric', N, out, N ); +console.log( ndarray2array( out, shape, strides, 0, order ) ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/accessors.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/accessors.js new file mode 100644 index 000000000000..0b695c2bd5a1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/accessors.js @@ -0,0 +1,104 @@ +/** +* @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'; + +// MAIN // + +/** +* Generates a Pascal matrix using accessor arrays. +* +* @private +* @param {string} uplo - specifies whether to fill the lower or upper triangular part of `out` +* @param {NonNegativeInteger} N - order of the Pascal matrix +* @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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'symmetric', 3, arraylike2object( toAccessorArray( out ) ), 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +*/ +function gpascal( uplo, N, out, strideOut1, strideOut2, offsetOut ) { + var obuf; + var oset; + var io; + var v; + var i; + var j; + + obuf = out.data; + oset = out.accessors[ 1 ]; + + if ( uplo === 'symmetric' ) { + io = offsetOut; + for ( i = 0; i < N; i++ ) { + v = 1.0; + oset( obuf, io, v ); + for ( j = 1; j < N; j++ ) { + v *= ( i + j ) / j; + oset( obuf, io + (j*strideOut2), v ); + } + io += strideOut1; + } + return out; + } + if ( uplo === 'lower' ) { + io = offsetOut; + for ( i = 0; i < N; i++ ) { + v = 1.0; + oset( obuf, io, v ); + for ( j = 1; j <= i; j++ ) { + v *= ( i - j + 1 ) / j; + oset( obuf, io + (j*strideOut2), v ); + } + for ( j = i + 1; j < N; j++ ) { + oset( obuf, io + (j*strideOut2), 0.0 ); + } + io += strideOut1; + } + return out; + } + // uplo === 'upper' + io = offsetOut; + for ( i = 0; i < N; i++ ) { + for ( j = 0; j < i; j++ ) { + oset( obuf, io + (j*strideOut2), 0.0 ); + } + v = 1.0; + oset( obuf, io + (i*strideOut2), v ); + for ( j = i + 1; j < N; j++ ) { + v *= j / ( j - i ); + oset( obuf, io + (j*strideOut2), v ); + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gpascal; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/index.js new file mode 100644 index 000000000000..691a736d58b2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/index.js @@ -0,0 +1,73 @@ +/** +* @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 Pascal matrix. +* +* @module @stdlib/blas/ext/base/gpascal +* +* @example +* var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); +* +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'symmetric', 3, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +* +* @example +* var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); +* +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'lower', 3, out, 3 ); +* // out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] +* +* @example +* var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); +* +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'upper', 3, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] +* +* @example +* var gpascal = require( '@stdlib/blas/ext/base/gpascal' ); +* +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal.ndarray( 'symmetric', 3, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.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/gpascal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/main.js new file mode 100644 index 000000000000..8d80e1370a2f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/main.js @@ -0,0 +1,97 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isColumnMajor = require( '@stdlib/ndarray/base/assert/is-column-major-string' ); +var resolveLayout = require( '@stdlib/blas/base/layout-resolve-str' ); +var max = require( '@stdlib/math/base/special/fast/max' ); +var format = require( '@stdlib/string/format' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Generates a Pascal matrix. +* +* @param {(integer|string)} order - storage layout +* @param {string} uplo - specifies whether to fill the lower or upper triangular part of `out` +* @param {NonNegativeInteger} N - order of the Pascal matrix +* @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 {TypeError} second argument must be a valid value +* @throws {RangeError} fifth argument must be a valid stride +* @returns {Collection} output matrix +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'symmetric', 3, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'lower', 3, out, 3 ); +* // out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'row-major', 'upper', 3, out, 3 ); +* // out => [ 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] +*/ +function gpascal( order, uplo, N, out, ldo ) { + var sa1; + var sa2; + 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 ( uplo !== 'lower' && uplo !== 'upper' && uplo !== 'symmetric' ) { + throw new TypeError( format( 'invalid argument. Second argument must be one of the following: \'lower\', \'upper\', or \'symmetric\'. Value: `%s`.', uplo ) ); + } + if ( isColumnMajor( l ) ) { + if ( ldo < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, ldo ) ); + } + sa1 = 1; + sa2 = ldo; + } else { // order === 'row-major' + if ( ldo < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, ldo ) ); + } + sa1 = ldo; + sa2 = 1; + } + if ( N <= 0 ) { + return out; + } + return ndarray( uplo, N, out, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = gpascal; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/ndarray.js new file mode 100644 index 000000000000..a309a6969fba --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/lib/ndarray.js @@ -0,0 +1,122 @@ +/** +* @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 arraylike2object = require( '@stdlib/array/base/arraylike2object' ); +var accessors = require( './accessors.js' ); + + +// MAIN // + +/** +* Generates a Pascal matrix using alternative indexing semantics. +* +* @param {string} uplo - specifies whether to fill the lower or upper triangular part of `out` +* @param {NonNegativeInteger} N - order of the Pascal matrix +* @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 out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'symmetric', 3, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 1.0, 2.0, 3.0, 1.0, 3.0, 6.0 ] +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'lower', 3, out, 3, 1, 0 ); +* // out => [ 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 2.0, 1.0 ] +* +* @example +* var out = [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ]; +* +* gpascal( 'upper', 3, out, 3, 1, 0 ); +* // out => [ 1.0, 1.0, 1.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] +*/ +function gpascal( uplo, N, out, strideOut1, strideOut2, offsetOut ) { + var oo; + var io; + var v; + var i; + var j; + + if ( N <= 0 ) { + return out; + } + oo = arraylike2object( out ); + if ( oo.accessorProtocol ) { + accessors( uplo, N, oo, strideOut1, strideOut2, offsetOut ); + return out; + } + if ( uplo === 'symmetric' ) { + io = offsetOut; + for ( i = 0; i < N; i++ ) { + v = 1.0; + out[ io ] = v; + for ( j = 1; j < N; j++ ) { + v *= ( i + j ) / j; + out[ io + (j*strideOut2) ] = v; + } + io += strideOut1; + } + return out; + } + if ( uplo === 'lower' ) { + io = offsetOut; + for ( i = 0; i < N; i++ ) { + v = 1.0; + out[ io ] = v; + for ( j = 1; j <= i; j++ ) { + v *= ( i - j + 1 ) / j; + out[ io + (j*strideOut2) ] = v; + } + for ( j = i + 1; j < N; j++ ) { + out[ io + (j*strideOut2) ] = 0.0; + } + io += strideOut1; + } + return out; + } + // uplo === 'upper' + io = offsetOut; + for ( i = 0; i < N; i++ ) { + for ( j = 0; j < i; j++ ) { + out[ io + (j*strideOut2) ] = 0.0; + } + v = 1.0; + out[ io + (i*strideOut2) ] = v; + for ( j = i + 1; j < N; j++ ) { + v *= j / ( j - i ); + out[ io + (j*strideOut2) ] = v; + } + io += strideOut1; + } + return out; +} + + +// EXPORTS // + +module.exports = gpascal; diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/package.json b/lib/node_modules/@stdlib/blas/ext/base/gpascal/package.json new file mode 100644 index 000000000000..c513d8e8c8ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/blas/ext/base/gpascal", + "version": "0.0.0", + "description": "Generate a Pascal 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", + "pascal", + "matrix", + "strided", + "strided array", + "typed", + "array", + "ndarray", + "vector", + "gpascal", + "binomial", + "triangular", + "symmetric" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.js new file mode 100644 index 000000000000..68a3cffeaf09 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/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 gpascal = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gpascal, '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 gpascal.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js new file mode 100644 index 000000000000..65857f013557 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js @@ -0,0 +1,1179 @@ +/** +* @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 gpascal = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gpascal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 5', function test( t ) { + t.strictEqual( gpascal.length, 5, '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() { + gpascal( value, 'symmetric', 2, [ 0.0, 0.0, 0.0, 0.0 ], 2 ); + }; + } +}); + +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() { + gpascal( value, 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid second 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() { + gpascal( 'row-major', value, 2, [ 0.0, 0.0, 0.0, 0.0 ], 2 ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second 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() { + gpascal( 'row-major', value, 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument (row-major)', function test( t ) { + var values; + var i; + + values = [ + -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() { + gpascal( 'row-major', 'symmetric', 2, [ 0.0, 0.0, 0.0, 0.0 ], value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument (row-major, accessors)', function test( t ) { + var values; + var i; + + values = [ + -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() { + gpascal( 'row-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); // eslint-disable-line max-len + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument (column-major)', function test( t ) { + var values; + var i; + + values = [ + -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() { + gpascal( 'column-major', 'symmetric', 2, [ 0.0, 0.0, 0.0, 0.0 ], value ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument (column-major, accessors)', function test( t ) { + var values; + var i; + + values = [ + -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() { + gpascal( 'column-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); // eslint-disable-line max-len + }; + } +}); + +tape( 'if `N` is less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + gpascal( 'row-major', 'symmetric', 0, out, 1 ); + + expected = [ 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `N` is less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + gpascal( 'row-major', 'symmetric', 0, toAccessorArray( out ), 1 ); + + expected = [ 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 v; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + v = gpascal( 'row-major', 'symmetric', 2, out, 2 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns the output matrix (accessors)', function test( t ) { + var out; + var v; + + out = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); + + v = gpascal( 'row-major', 'symmetric', 2, out, 2 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'symmetric', 4, out, 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'symmetric', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'symmetric', 4, out, 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'symmetric', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'lower', 4, out, 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'lower', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'lower', 4, out, 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'lower', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'upper', 4, out, 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'upper', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'upper', 4, out, 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'upper', 4, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a leading dimension for the output matrix (row-major, symmetric)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'symmetric', 2, out, 3 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 1.0, + 2.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, symmetric, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'symmetric', 2, toAccessorArray( out ), 3 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 1.0, + 2.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, symmetric)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'symmetric', 2, out, 3 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 1.0, + 2.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, symmetric, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'column-major', 'symmetric', 2, toAccessorArray( out ), 3 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 1.0, + 2.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, lower)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'lower', 2, out, 5 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.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 (row-major, lower, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'row-major', 'lower', 2, toAccessorArray( out ), 5 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.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, upper)', function test( t ) { + var expected; + var out; + + 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 + ]; + + gpascal( 'column-major', 'upper', 3, out, 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.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, upper, accessors)', function test( t ) { + var expected; + var out; + + 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 + ]; + + gpascal( 'column-major', 'upper', 3, toAccessorArray( out ), 4 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets (symmetric)', function test( t ) { + var expected; + var out0; + var out1; + + out0 = new Float64Array( 5 ); + out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + + gpascal( 'row-major', 'symmetric', 2, out1, 2 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 1.0, + 2.0 + ]); + + t.deepEqual( out1, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets (lower)', function test( t ) { + var expected; + var out0; + var out1; + + out0 = new Float64Array( 5 ); + out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + + gpascal( 'row-major', 'lower', 2, out1, 2 ); + + expected = new Float64Array([ + 1.0, + 0.0, + 1.0, + 1.0 + ]); + + t.deepEqual( out1, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports view offsets (upper)', function test( t ) { + var expected; + var out0; + var out1; + + out0 = new Float64Array( 5 ); + out1 = new Float64Array( out0.buffer, out0.BYTES_PER_ELEMENT*1 ); + + gpascal( 'row-major', 'upper', 2, out1, 2 ); + + expected = new Float64Array([ + 1.0, + 1.0, + 0.0, + 1.0 + ]); + + t.deepEqual( out1, expected, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.ndarray.js new file mode 100644 index 000000000000..29a205bc1022 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.ndarray.js @@ -0,0 +1,1255 @@ +/** +* @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 gpascal = require( './../lib/ndarray.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof gpascal, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 6', function test( t ) { + t.strictEqual( gpascal.length, 6, 'has expected arity' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 4, out, 4, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 4, toAccessorArray( out ), 4, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 4, out, 1, 4, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a symmetric Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 4, toAccessorArray( out ), 1, 4, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0, + 2.0, + 3.0, + 4.0, + 1.0, + 3.0, + 6.0, + 10.0, + 1.0, + 4.0, + 10.0, + 20.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 4, out, 4, 1, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 4, toAccessorArray( out ), 4, 1, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 4, out, 1, 4, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates a lower triangular Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 4, toAccessorArray( out ), 1, 4, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (row-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 4, out, 4, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (row-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 4, toAccessorArray( out ), 4, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 3.0, + 0.0, + 0.0, + 1.0, + 3.0, + 0.0, + 0.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (column-major)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 4, out, 1, 4, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function generates an upper triangular Pascal matrix (column-major, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 4, toAccessorArray( out ), 1, 4, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 1.0, + 3.0, + 3.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `N` is less than or equal to `0`, the function returns the output array unchanged', function test( t ) { + var expected; + var out; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + gpascal( 'symmetric', 0, out, 0, 1, 0 ); + + expected = [ 0.0, 0.0, 0.0, 0.0 ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'if `N` is less than or equal to `0`, the function returns the output array unchanged (accessors)', function test( t ) { + var expected; + var out; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + gpascal( 'symmetric', 0, toAccessorArray( out ), 0, 1, 0 ); + + expected = [ 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 v; + + out = [ 0.0, 0.0, 0.0, 0.0 ]; + + v = gpascal( 'symmetric', 2, out, 2, 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 v; + + out = toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ); + + v = gpascal( 'symmetric', 2, out, 2, 1, 0 ); + + t.strictEqual( v, out, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major, symmetric)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, out, 5, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major, symmetric, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, toAccessorArray( out ), 5, 1, 0 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.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, symmetric)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, out, 1, 5, 0 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.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, symmetric, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, toAccessorArray( out ), 1, 5, 0 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 0.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major, lower)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 3, out, 5, 1, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (row-major, lower, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 3, toAccessorArray( out ), 5, 1, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (column-major, upper)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 3, out, 1, 5, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying output strides (column-major, upper, accessors)', function test( t ) { + var expected; + var out; + + 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, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 3, toAccessorArray( out ), 1, 5, 0 ); + + expected = [ + 1.0, + 0.0, + 0.0, + 0.0, + 0.0, + 1.0, + 1.0, + 0.0, + 0.0, + 0.0, + 1.0, + 2.0, + 1.0, + 0.0, + 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; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, out, 2, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 1.0, + 1.0, + 2.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; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, toAccessorArray( out ), 2, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 1.0, + 1.0, + 2.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative output strides (row-major, symmetric)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, out, -2, -1, 3 ); + + expected = [ + 2.0, + 1.0, + 1.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative output strides (row-major, symmetric, accessors)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, toAccessorArray( out ), -2, -1, 3 ); + + expected = [ + 2.0, + 1.0, + 1.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `out` (lower)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 2, out, 2, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 0.0, + 1.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying an offset for `out` (upper)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 2, out, 2, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 1.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative output strides (row-major, lower)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'lower', 2, out, -2, -1, 3 ); + + expected = [ + 1.0, + 1.0, + 0.0, + 1.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports specifying negative output strides (row-major, upper)', function test( t ) { + var expected; + var out; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'upper', 2, out, -2, -1, 3 ); + + expected = [ + 1.0, + 0.0, + 1.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; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, out, 3, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.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; + + out = [ + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0 + ]; + + gpascal( 'symmetric', 2, toAccessorArray( out ), 3, 1, 1 ); + + expected = [ + 0.0, + 1.0, + 1.0, + 0.0, + 1.0, + 2.0, + 0.0 + ]; + + t.deepEqual( out, expected, 'returns expected value' ); + t.end(); +}); From 3a8b3dd3761cf2c2099f132945e54121e45f00f5 Mon Sep 17 00:00:00 2001 From: headlessNode Date: Sat, 17 Oct 2026 17:57:22 +0500 Subject: [PATCH 2/2] fix: lint err --- .../@stdlib/blas/ext/base/gpascal/test/test.main.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js index 65857f013557..c24581532b06 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/gpascal/test/test.main.js @@ -80,7 +80,7 @@ tape( 'the function throws an error if provided an invalid first argument (acces function badValue( value ) { return function badValue() { - gpascal( value, 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); // eslint-disable-line max-len + gpascal( value, 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); }; } }); @@ -126,7 +126,7 @@ tape( 'the function throws an error if provided an invalid second argument (acce function badValue( value ) { return function badValue() { - gpascal( 'row-major', value, 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); // eslint-disable-line max-len + gpascal( 'row-major', value, 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), 2 ); }; } }); @@ -172,7 +172,7 @@ tape( 'the function throws an error if provided an invalid fifth argument (row-m function badValue( value ) { return function badValue() { - gpascal( 'row-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); // eslint-disable-line max-len + gpascal( 'row-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); }; } }); @@ -218,7 +218,7 @@ tape( 'the function throws an error if provided an invalid fifth argument (colum function badValue( value ) { return function badValue() { - gpascal( 'column-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); // eslint-disable-line max-len + gpascal( 'column-major', 'symmetric', 2, toAccessorArray( [ 0.0, 0.0, 0.0, 0.0 ] ), value ); }; } });