From dfe3a6da7cc146e8adf2883dfd08cc73554cdf23 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 3 Jun 2024 18:12:34 +0530 Subject: [PATCH] feat: add BLAS Level 2 routine for sgbmv --- .../@stdlib/blas/base/sgbmv/README.md | 318 ++++++++++ .../blas/base/sgbmv/benchmark/benchmark.js | 104 ++++ .../base/sgbmv/benchmark/benchmark.ndarray.js | 104 ++++ .../@stdlib/blas/base/sgbmv/docs/repl.txt | 175 ++++++ .../blas/base/sgbmv/docs/types/index.d.ts | 178 ++++++ .../blas/base/sgbmv/docs/types/test.ts | 568 ++++++++++++++++++ .../@stdlib/blas/base/sgbmv/examples/index.js | 47 ++ .../@stdlib/blas/base/sgbmv/lib/index.js | 94 +++ .../@stdlib/blas/base/sgbmv/lib/main.js | 35 ++ .../@stdlib/blas/base/sgbmv/lib/ndarray.js | 228 +++++++ .../@stdlib/blas/base/sgbmv/lib/sgbmv.js | 235 ++++++++ .../@stdlib/blas/base/sgbmv/package.json | 68 +++ .../base/sgbmv/test/fixtures/julia/REQUIRE | 2 + .../test/fixtures/julia/strides_xnyn.json | 20 + .../test/fixtures/julia/strides_xnyp.json | 22 + .../test/fixtures/julia/strides_xoyo.json | 22 + .../test/fixtures/julia/strides_xpyn.json | 20 + .../test/fixtures/julia/strides_xpyp.json | 20 + .../@stdlib/blas/base/sgbmv/test/test.js | 82 +++ .../blas/base/sgbmv/test/test.ndarray.js | 325 ++++++++++ .../blas/base/sgbmv/test/test.sgbmv.js | 325 ++++++++++ 21 files changed, 2992 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/lib/sgbmv.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xoyo.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sgbmv/test/test.sgbmv.js diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/README.md b/lib/node_modules/@stdlib/blas/base/sgbmv/README.md new file mode 100644 index 000000000000..2423c87bd153 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/README.md @@ -0,0 +1,318 @@ + + +# sgbmv + +> Perform one of the matrix-vector operations `y = al*A*x + b*y` or `y = al*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals. + +
+ +## Usage + +```javascript +var sgbmv = require( '@stdlib/blas/base/sgbmv' ); +``` + +#### sgbmv( ord, trans, M, N, kl, ku, a, A, LDA, x, sx, b, y, sy ) + +Performs one of the matrix-vector operations `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var trans = 'N'; + +var M = 4; +var N = 3; +var kl = 1; +var ku = 1; +var lda = 4; + +var l = 2.0; +var b = 3.0; + +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + +sgbmv( 'row-major', trans, M, N, kl, ku, l, A, lda, x, 1, b, y, 1 ); +// y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +``` + +The function has the following parameters: + +- **ord**: storage layout. +- **trans**: specifies the operation to be performed. +- **M**: number of rows in the matrix `A`. +- **N**: number of columns in the matrix `A`. +- **kl**: number of sub-diagonals within the band of `A`. +- **ku**: number of super-diagonals within the band of `A`. +- **a**: scalar constant. +- **A**: matrix of coefficients [`Float32Array`][mdn-float32array]. +- **lda**: stride of the first dimension of `A` (leading dimension of `A`). +- **x**: input [`Float32Array`][mdn-float32array]. +- **sx**: index increment for `x`. +- **b**: scalar constant. +- **y**: output [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. + +The stride parameters determine how operations are performed. For example, to perform vector-matrix operation `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var trans = 'N'; + +var M = 4; +var N = 3; +var kl = 1; +var ku = 1; +var lda = 4; + +var a = 2.0; +var b = 3.0; + +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0, 11.0 ] ); + +sgbmv( 'row-major', trans, M, N, kl, ku, a, A, lda, x, 1, b, y, 1 ); +// y => [ 32.0, 77.0, 110.0, 99.0, 10.0, 11.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 1.0, 1.0 ] ); +var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 4th element + +sgbmv( 'row-major', 'N', 2, 2, 1, 1, 1.0, A, 2, x1, -1, 1.0, y1, -1 ); +// y0 => [ 1.0, 1.0 ] +``` + +#### sgbmv.ndarray( ord, trans, M, N, kl, ku, a, A, LDA, x, sx, ox, b, y, sy, oy ) + +Performs one of the matrix-vector operations `y = a*A*x + b*y` or `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var trans = 'N'; + +var M = 4; +var N = 3; +var kl = 1; +var ku = 1; +var lda = 4; + +var a = 2.0; +var b = 3.0; + +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + +sgbmv.ndarray( 'row-major', trans, M, N, kl, ku, a, A, lda, x, 1, 0, b, y, 1, 0 ); +// y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to perform operation with given `x` and `y` offset values`,..., + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var trans = 'N'; + +var M = 4; +var N = 3; +var kl = 1; +var ku = 1; +var lda = 4; + +var a = 2.0; +var b = 3.0; + +var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); + +sgbmv.ndarray( 'column-major', 'N', M, N, kl, ku, a, A, 3, x, -1, 2, b, y, -1, 3 ); // eslint-disable-line max-len +// y => [ 38.0, 61.0, 70.0, 45.0, 10.0 ] +``` + +
+ + + +
+ +## Notes + +- `sgbmv()` corresponds to the [BLAS][blas] level 2 function [`sgbmv`][sgbmv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sgbmv = require( '@stdlib/blas/base/sgbmv' ); + +var opts = { + 'dtype': 'float32' +}; + +var trans = 'N'; + +var M = 3; +var N = 3; +var lda = 3; + +var a = 1; +var b = 1; + +var A = discreteUniform( M*N, 0, 255, opts ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( M, 0, 255, opts ); + +sgbmv.ndarray( 'row-major', trans, M, N, 1, 1, a, A, lda, x, 1, 0, b, y, 1, 0 ); +console.log( y ); + +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/sgbmv.h" +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.js new file mode 100644 index 000000000000..93cd9af34000 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 pkg = require( './../package.json' ).name; +var sgbmv = require( './../lib/sgbmv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + var y = uniform( len, -10.0, 10.0, options ); + var A = uniform( len*len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sgbmv( 'row-major', 'N', len, len, 1, 1, 1.0, A, len, x, 1, 1.0, y, 1 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.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 = 4; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..5f9075cd3ec8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 pkg = require( './../package.json' ).name; +var sgbmv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = uniform( len, -10.0, 10.0, options ); + var y = uniform( len, -10.0, 10.0, options ); + var A = uniform( len*len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sgbmv( 'row-major', 'N', len, len, 1, 1, 1.0, A, len, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.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 = 4; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':ndarray:len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/repl.txt new file mode 100644 index 000000000000..66043ca04e01 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/repl.txt @@ -0,0 +1,175 @@ + +{{alias}}( od, trans, M, N, kl, ku, a, A, lda, x, sx, b, y, sy ) + Perform one of the matrix-vector operations `y = a*A*x + b*y` or + `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals. + + The stride parameters determine how operations are performed. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `M` or `N` is equal to `0`, the function returns `y` unchanged. + + If `a` equals `0` and b equals `1`, the function returns `y` + unchanged. + + Parameters + ---------- + od: string + Row-major (C-style) or column-major (Fortran-style) oder. + + trans: string + Specifies whether `A` is transposed. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + kl: integer + Number of sub-diagonals. + + ku: integer + Number of super-diagonals. + + a: number + Scalar. + + A: Float32Array + Matrix. + + lda: integer + Leading dimension. + + x: Float32Array + Input vector `x`. + + sx: integer + Index increment for `x`. + + b: number + Scalar. + + y: Float32Array + Input/output vector `y`. + + sy: integer + Index increment for `y`. + + Returns + ------- + y: Float32Array + Output array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'N', 2, 2, 1, 1, 1.0, A, 2, x, 1, 1.0, y, 1 ) + [ 1.0, 1.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'N', 2, 2, 1, 1, 1.0, A, 2, x, -1, 1.0, y, -1 ) + [ 1.0, 1.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); + > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 'row-major', 'N', 2, 2, 1, 1, 1.0, A, 2, x1, -1, 1.0, y1, -1 ) + > y0 + [ 1.0, 1.0 ] + + +{{alias}}.ndarray( od, trans, M, N, kl, ku, a, A, lda, x, sx, ox, b, y, sy, oy ) + Perform one of the matrix-vector operations `y = a*A*x + b*y` or + `y = a*A**T*x + b*y` with kl as sub-diagonals and ku as super-diagonals + 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 + ---------- + od: string + Row-major (C-style) or column-major (Fortran-style) oder. + + trans: string + Specifies whether `A` is transposed. + + M: integer + Number of rows in `A`. + + N: integer + Number of columns in `A`. + + kl: integer + Number of sub-diagonals. + + ku: integer + Number of super-diagonals. + + a: number + Scalar. + + A: Float32Array + Matrix. + + lda: integer + Leading dimension. + + x: Float32Array + Input vector `x`. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + b: number + Scalar. + + y: Float32Array + Input/output vector `y`. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + Returns + ------- + y: Float32Array + Output array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var od = 'row-major'; + > {{alias}}.ndarray( od, 'N', 2, 2, 1, 1, 1, A, 2, x, 1, 0, 1, y, 1, 0 ) + [ 1.0, 1.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var od = 'row-major'; + > {{alias}}.ndarray( od, 'N', 2, 2, 1, 1, 1, A, 2, x, -1, 1, 1, y, -1, 1 ) + [ 1.0, 1.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/index.d.ts new file mode 100644 index 000000000000..68f8ad0d86dc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/index.d.ts @@ -0,0 +1,178 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface describing `sgbmv`. +*/ +interface Routine { + /** + * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals. + * + * @param order - storage layout + * @param trans - specifies the operation to be performed + * @param M - number of rows in the matrix `A` + * @param N - number of columns in the matrix `A` + * @param kl - number of sub-diagonals + * @param ku - number of super-diagonals + * @param alpha - scalar constant + * @param A - matrix of coefficients + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param x - an `M` element vector + * @param strideX - `x` stride length + * @param beta - scalar constant + * @param y - an `N` element vector + * @param strideY - `y` stride length + * @returns output array `y` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var trans = 'N'; + * + * var M = 4; + * var N = 3; + * var kl = 1; + * var ku = 1; + * var lda = 4; + * + * var alpha = 2.0; + * var beta = 3.0; + * + * var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0 ] ); + * + * sgbmv( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, beta, y, 1 ); + * // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] + */ + ( order: string, trans: string, M: number, N: number, kl: number, ku: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + + /** + * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals using alternative indexing semantics. + * + * @param order - storage layout + * @param trans - specifies the operation to be performed + * @param M - number of rows in the matrix `A` + * @param N - number of columns in the matrix `A` + * @param kl - number of sub-diagonals + * @param ku - number of super-diagonals + * @param alpha - scalar constant + * @param A - matrix of coefficients + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param x - an `M` element vector + * @param strideX - `x` stride length + * @param offsetX - `x` index offset + * @param beta - scalar constant + * @param y - an `N` element vector + * @param strideY - `y` stride length + * @param offsetY - `y` index offset + * @returns output array `y` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var trans = 'N'; + * + * var M = 4; + * var N = 3; + * var kl = 1; + * var ku = 1; + * var lda = 4; + * + * var alpha = 2.0; + * var beta = 3.0; + * + * var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0 ] ); + * + * sgbmv( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, beta, y, 1 ); + * // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] + */ + ndarray( order: string, trans: string, M: number, N: number, kl: number, ku: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; +} + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals. +* +* @param order - storage layout +* @param trans - specifies the operation to be performed +* @param M - number of rows in the matrix `A` +* @param N - number of columns in the matrix `A` +* @param kl - number of sub-diagonals +* @param ku - number of super-diagonals +* @param alpha - scalar constant +* @param A - matrix of coefficients +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param x - an `M` element vector +* @param strideX - `x` stride length +* @param beta - scalar constant +* @param y - an `N` element vector +* @param strideY - `y` stride length +* @returns output array `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +* +* sgbmv( 'column-major', 'N', M, N, kl, ku, alpha, A, 3, x, -1, beta, y, -1 ); +* // y => [ 42.0, 71.0, 80.0, 53.0, 10.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +* +* sgbmv.ndarray( 'column-major', 'N', M, N, kl, ku, alpha, A, 3, x, -1, 2, beta, y, -1, 3 ); +* // y => [ 42.0, 71.0, 80.0, 53.0, 10.0 ] +*/ +declare var sgbmv: Routine; + + +// EXPORTS // + +export = sgbmv; diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/test.ts new file mode 100644 index 000000000000..9ccc06e6e58a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/docs/types/test.ts @@ -0,0 +1,568 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import sgbmv = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 10, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( true, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( false, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( null, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( undefined, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( [], 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( {}, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( ( x: number ): number => x, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a character... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 10, 10, 1, 1, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', true, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', false, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', null, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', undefined, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', [ '1' ], 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', {}, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', ( x: number ): number => x, 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', '10', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', true, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', false, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', null, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', undefined, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', [], 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', {}, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', ( x: number ): number => x, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, '10', 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, true, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, false, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, null, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, undefined, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, [], 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, {}, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, ( x: number ): number => x, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, '10', 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, true, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, false, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, null, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, undefined, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, [], 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, {}, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, ( x: number ): number => x, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, '10', 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, true, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, false, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, null, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, undefined, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, [], 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, {}, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, ( x: number ): number => x, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, '10', A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, true, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, false, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, null, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, undefined, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, [], A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, {}, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, ( x: number ): number => x, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, 10, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, '10', 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, true, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, false, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, null, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, undefined, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, [ '1' ], 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, {}, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, ( x: number ): number => x, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, '10', x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, true, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, false, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, null, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, [], x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, {}, x, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, ( x: number ): number => x, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, 10, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, '10', 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, true, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, false, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, null, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, undefined, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, {}, 1, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, ( x: number ): number => x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, '10', 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, true, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, false, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, null, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, undefined, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, [], 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, {}, 1.0, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, '10', y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, true, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, false, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, null, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, undefined, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, [], y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, {}, y, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, ( x: number ): number => x, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteen argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, 10, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, '10', 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, true, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, false, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, null, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, undefined, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, {}, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteen argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, '10' ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, true ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, false ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, null ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, undefined ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, [] ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, {} ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv(); // $ExpectError + sgbmv( 'row-major' ); // $ExpectError + sgbmv( 'row-major', 'N' ); // $ExpectError + sgbmv( 'row-major', 'N', 10 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0 ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y ); // $ExpectError + sgbmv( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 1.0, y, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 10, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( true, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( false, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( null, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( undefined, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( [], 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( {}, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( ( x: number ): number => x, 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a character... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 10, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', true, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', false, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', null, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', undefined, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', [ '1' ], 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', {}, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', ( x: number ): number => x, 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', '10', 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', true, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', false, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', null, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', undefined, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', [], 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', {}, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', ( x: number ): number => x, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, '10', 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, true, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, false, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, null, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, undefined, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, [], 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, {}, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, ( x: number ): number => x, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, '10', 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, true, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, false, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, null, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, undefined, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, [], 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, {}, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, ( x: number ): number => x, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, '10', 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, true, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, false, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, null, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, undefined, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, [], 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, {}, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, ( x: number ): number => x, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, '10', A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, true, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, false, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, null, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, undefined, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, [], A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, {}, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, ( x: number ): number => x, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, 10, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, '10', 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, true, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, false, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, null, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, undefined, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, [ '1' ], 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, {}, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, ( x: number ): number => x, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, '10', x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, [], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, 10, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, '10', 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, ( x: number ): number => x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, '10', 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, true, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, false, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, null, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, [], 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, {}, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, ( x: number ): number => x, 0, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, '10', 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, true, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, false, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, null, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, [], 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, {}, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, '10', y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, true, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, false, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, null, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, [], y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, {}, y, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, ( x: number ): number => x, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourteenth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, 10, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, '10', 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, '10', 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, '10' ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, true ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, false ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, null ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + sgbmv.ndarray(); // $ExpectError + sgbmv.ndarray( 'row-major' ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N' ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1 ); // $ExpectError + sgbmv.ndarray( 'row-major', 'N', 10, 10, 1, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/sgbmv/examples/index.js new file mode 100644 index 000000000000..8c52099a3c88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/examples/index.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 */ // FIXME + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sgbmv = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var trans = 'N'; + +var M = 3; +var N = 3; +var kl = 1; +var ku = 1; +var lda = 3; + +var alpha = 1; +var beta = 1; + +var A = discreteUniform( M*N, 0, 255, opts ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( M, 0, 255, opts ); + +sgbmv.ndarray( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, 0, beta, y, 1, 0 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/index.js new file mode 100644 index 000000000000..23a898830629 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/index.js @@ -0,0 +1,94 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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'; + +/** +* BLAS level 2 routine to perform one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals. +* +* @module @stdlib/blas/base/sgbmv +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sgbmv = require( '@stdlib/blas/base/sgbmv' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +* +* sgbmv( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, beta, y, 1 ); +* // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sgbmv = require( '@stdlib/blas/base/sgbmv' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +* +* sgbmv.ndarray( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, 0, beta, y, 1, 0 ); +* // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var sgbmv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + sgbmv = main; +} else { + sgbmv = tmp; +} + + +// EXPORTS // + +module.exports = sgbmv; + +// exports: { "ndarray": "sgbmv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/lib/main.js b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/main.js new file mode 100644 index 000000000000..761859fa2a58 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/main.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var sgbmv = require( './sgbmv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( sgbmv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = sgbmv; diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/ndarray.js new file mode 100644 index 000000000000..e60613ce97fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/ndarray.js @@ -0,0 +1,228 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 */ // FIXME + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y`. +* +* @param {string} order - storage layout +* @param {string} trans - specifies the operation to be performed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} A - matrix of coefficients +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} x - an `M` element vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {number} beta - scalar constant +* @param {Float64Array} y - an `N` element vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting `y` index +* @returns {Float64Array} `y` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); // eslint-disable-line max-len +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0, 10.0 ] ); +* +* sgbmv.ndarray( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, 0, beta, y, 1, 0 ); +* // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +*/ +function sgbmv( order, trans, M, N, kl, ku, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { + var info; + var kup1; + var lenx; + var leny; + var temp; + var ix; + var iy; + var jx; + var jy; + var kx; + var ky; + var i; + var j; + var k; + + info = 0; + if ( ( trans.toUpperCase() !== 'N' ) && ( trans.toUpperCase() !== 'T' ) && ( trans.toUpperCase() !== 'C' ) ) { + info = 1; + } else if ( M < 0 ) { + info = 2; + } else if ( N < 0 ) { + info = 3; + } else if ( kl < 0 ) { + info = 4; + } else if ( ku < 0 ) { + info = 5; + } else if ( LDA < ( kl + ku + 1 ) ) { + info = 8; + } else if ( strideX === 0 ) { + info = 10; + } else if ( strideY === 0 ) { + info = 13; + } + if ( info !== 0 ) { + return y; + // throw new Error( "Invalid input parameters ( info = " + info + " ) " ); + } + if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + if ( trans.toUpperCase() === 'N' ) { + lenx = N; + leny = M; + } else { + lenx = M; + leny = N; + } + kx = offsetX; + ky = offsetY; + if ( beta !== 1.0 ) { + if ( strideY === 1 ) { + if ( beta === 0.0 ) { + for ( i = 0; i < leny; i++ ) { + y[ i ] = 0.0; + } + } else { + for ( i = 0; i < leny; i++ ) { + y[ i ] *= beta; + } + } + } else { + iy = ky; + if ( beta === 0.0 ) { + for ( i = 0; i < leny; i++ ) { + y[ iy ] = 0.0; + iy += strideY; + } + } else { + for ( i = 0; i < leny; i++ ) { + y[ iy ] *= beta; + iy += strideY; + } + } + } + } + if ( alpha === 0.0 ) { + return y; + } + kup1 = ku + 1; + if ( trans.toUpperCase() === 'N' ) { + jx = kx; + if ( strideY === 1 ) { + for ( j = 0; j < N; j++ ) { + temp = alpha * x[ jx ]; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + y[ i ] += temp * A[ j + ( i + k ) * LDA ]; + } else { + y[ i ] += temp * A[ ( i + k ) + j * LDA ]; + } + } + jx += strideX; + } + } else { + for ( j = 0; j < N; j++ ) { + temp = alpha * x[ jx ]; + iy = ky; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + y[ iy ] += temp * A[ j + ( i + k ) * LDA ]; + } else { + y[ iy ] += temp * A[ ( i + k ) + j * LDA ]; + } + iy += strideY; + } + jx += strideX; + if ( j >= ku ) { + ky += strideY; + } + } + } + } else { + jy = ky; + if ( strideX === 1 ) { + for ( j = 0; j < N; j++ ) { + temp = 0.0; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + temp += A[ j + ( i + k ) * LDA ] * x[ i ]; + } else { + temp += A[ ( i + k ) + j * LDA ] * x[ i ]; + } + } + y[ jy ] += alpha * temp; + jy += strideY; + } + } else { + for ( j = 0; j < N; j++ ) { + temp = 0.0; + ix = kx; + k = kup1 - j - 1; + for (i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++) { + if (order === 'row-major') { + temp += A[ j + ( i + k ) * LDA ] * x[ ix ]; + } else { + temp += A[ ( i + k ) + j * LDA ] * x[ ix ]; + } + ix += strideX; + } + y[ jy ] += alpha * temp; + jy += strideY; + if ( j >= ku ) { + kx += strideX; + } + } + } + } + return y; +} + + +// EXPORTS // + +module.exports = sgbmv; diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/lib/sgbmv.js b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/sgbmv.js new file mode 100644 index 000000000000..aeb899e0471c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/lib/sgbmv.js @@ -0,0 +1,235 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 */ // FIXME + +'use strict'; + +// MODULES // + +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals. +* +* @param {string} order - storage layout +* @param {string} trans - specifies the operation to be performed +* @param {NonNegativeInteger} M - number of rows in the matrix `A` +* @param {NonNegativeInteger} N - number of columns in the matrix `A` +* @param {NonNegativeInteger} kl - number of sub-diagonals within the band of `A` +* @param {NonNegativeInteger} ku - number of super-diagonals within the band of `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} A - matrix of coefficients +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} x - an `M` element vector +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float32Array} y - an `N` element vector +* @param {integer} strideY - `y` stride length +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float64' ); +* +* var trans = 'N'; +* +* var M = 4; +* var N = 3; +* var kl = 1; +* var ku = 1; +* var lda = 4; +* +* var alpha = 2.0; +* var beta = 3.0; +* +* var A = new Float32Array( [ 0.0, 1.0, 2.0, 3.0, 5.0, 6.0, 7.0, 8.0, 10.0, 11.0, 12.0, 13.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 6.0, 7.0, 8.0, 9.0 ] ); +* +* sgbmv( 'row-major', trans, M, N, kl, ku, alpha, A, lda, x, 1, beta, y, 1 ); +* // y => [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +*/ +function sgbmv( order, trans, M, N, kl, ku, alpha, A, LDA, x, strideX, beta, y, strideY ) { + var info; + var kup1; + var lenx; + var leny; + var temp; + var ix; + var iy; + var jx; + var jy; + var kx; + var ky; + var i; + var j; + var k; + + info = 0; + if ( ( trans.toUpperCase() !== 'N' ) && ( trans.toUpperCase() !== 'T' ) && ( trans.toUpperCase() !== 'C' ) ) { + info = 1; + } else if ( M < 0 ) { + info = 2; + } else if ( N < 0 ) { + info = 3; + } else if ( kl < 0 ) { + info = 4; + } else if ( ku < 0 ) { + info = 5; + } else if ( LDA < ( kl + ku + 1 ) ) { + info = 8; + } else if ( strideX === 0 ) { + info = 10; + } else if ( strideY === 0 ) { + info = 13; + } + if ( info !== 0 ) { + return y; + // throw new Error( "Invalid input parameters ( info = " + info + " ) " ); + } + if ( M === 0 || N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + if ( trans.toUpperCase() === 'N' ) { + lenx = N; + leny = M; + } else { + lenx = M; + leny = N; + } + if ( strideX > 0 ) { + kx = 0; + } else { + kx = ( 1 - lenx ) * strideX; + } + if ( strideY > 0 ) { + ky = 0; + } else { + ky = ( 1 - leny ) * strideY; + } + if ( beta !== 1.0 ) { + if ( strideY === 1 ) { + if ( beta === 0.0 ) { + for ( i = 0; i < leny; i++ ) { + y[ i ] = 0.0; + } + } else { + for ( i = 0; i < leny; i++ ) { + y[ i ] *= beta; + } + } + } else { + iy = ky; + if ( beta === 0.0 ) { + for ( i = 0; i < leny; i++ ) { + y[ iy ] = 0.0; + iy += strideY; + } + } else { + for ( i = 0; i < leny; i++ ) { + y[ iy ] *= beta; + iy += strideY; + } + } + } + } + if ( alpha === 0.0 ) { + return y; + } + kup1 = ku + 1; + if ( trans.toUpperCase() === 'N' ) { + jx = kx; + if ( strideY === 1 ) { + for ( j = 0; j < N; j++ ) { + temp = alpha * x[ jx ]; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + y[ i ] += temp * A[ j + ( i + k ) * LDA ]; + } else { + y[ i ] += temp * A[ ( i + k ) + j * LDA ]; + } + } + jx += strideX; + } + } else { + for ( j = 0; j < N; j++ ) { + temp = alpha * x[ jx ]; + iy = ky; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + y[ iy ] += temp * A[ j + ( i + k ) * LDA ]; + } else { + y[ iy ] += temp * A[ ( i + k ) + j * LDA ]; + } + iy += strideY; + } + jx += strideX; + if ( j >= ku ) { + ky += strideY; + } + } + } + } else { + jy = ky; + if ( strideX === 1 ) { + for ( j = 0; j < N; j++ ) { + temp = 0.0; + k = kup1 - j - 1; + for ( i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++ ) { + if ( order === 'row-major' ) { + temp += A[ j + ( i + k ) * LDA ] * x[ i ]; + } else { + temp += A[ ( i + k ) + j * LDA ] * x[ i ]; + } + } + y[ jy ] += alpha * temp; + jy += strideY; + } + } else { + for ( j = 0; j < N; j++ ) { + temp = 0.0; + ix = kx; + k = kup1 - j - 1; + for (i = max( 0, j - ku ); i < min( M, j + kl + 1 ); i++) { + if (order === 'row-major') { + temp += A[ j + ( i + k ) * LDA ] * x[ ix ]; + } else { + temp += A[ ( i + k ) + j * LDA ] * x[ ix ]; + } + ix += strideX; + } + y[ jy ] += alpha * temp; + jy += strideY; + if ( j >= ku ) { + kx += strideX; + } + } + } + } + return y; +} + + +// EXPORTS // + +module.exports = sgbmv; diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/package.json b/lib/node_modules/@stdlib/blas/base/sgbmv/package.json new file mode 100644 index 000000000000..514dd59786e8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/sgbmv", + "version": "0.0.0", + "description": "Perform one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals.", + "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", + "level 2", + "sgbmv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] + } diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..308c3be89c85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyn.json new file mode 100644 index 000000000000..479f74d99964 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyn.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "trans": "N", + "M": 4, + "N": 3, + "kl": 1, + "ku": 1, + "alpha": 2.0, + "lda": 4, + "A": [ + 0.0, 1.0, 2.0, 3.0, + 5.0, 6.0, 7.0, 8.0, + 10.0, 11.0, 12.0, 13.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "strideX": -1, + "beta": 3.0, + "y": [ 6.0, 7.0, 8.0, 9.0, 10.0 ], + "strideY": -1, + "y_out": [ 42.0, 71.0, 80.0, 53.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyp.json new file mode 100644 index 000000000000..925d0c72fdd6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xnyp.json @@ -0,0 +1,22 @@ +{ + "order": "column-major", + "trans": "N", + "M": 5, + "N": 5, + "kl": 1, + "ku": 1, + "alpha": 2.0, + "lda": 5, + "A": [ + 0.0, 1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, 9.0, + 10.0, 11.0, 12.0, 13.0, 14.0, + 15.0, 16.0, 17.0, 18.0, 19.0, + 20.0, 21.0, 22.0, 23.0, 24.0 ], + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": -1, + "beta": 3.0, + "y": [ 6.0, 7.0, 8.0, 9.0, 10.0 ], + "strideY": 2, + "y_out": [ 68.0, 7.0, 152.0, 9.0, 212.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xoyo.json b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xoyo.json new file mode 100644 index 000000000000..54369c6960bb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xoyo.json @@ -0,0 +1,22 @@ +{ + "order": "row-major", + "trans": "N", + "M": 5, + "N": 5, + "kl": 1, + "ku": 1, + "alpha": 2.0, + "lda": 3, + "A": [ + 0.0, 1.0, 2.0, + 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, + 9.0, 10.0, 11.0, + 12.0, 13.0, 14.0 ], + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": 1, + "beta": 3.0, + "y": [ 6.0, 7.0, 8.0, 9.0, 10.0 ], + "strideY": 1, + "y_out": [ 28.0, 61.0, 106.0, 163.0, 172.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyn.json new file mode 100644 index 000000000000..2023640a0b87 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyn.json @@ -0,0 +1,20 @@ +{ + "order": "column-major", + "trans": "N", + "M": 4, + "N": 3, + "kl": 1, + "ku": 1, + "alpha": 2.0, + "lda": 4, + "A": [ + 0.0, 1.0, 2.0, 3.0, + 5.0, 6.0, 7.0, 8.0, + 10.0, 11.0, 12.0, 13.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "beta": 3.0, + "y": [ 6.0, 7.0, 8.0, 9.0 ], + "strideY": -1, + "y_out": [ 90.0, 115.0, 112.0, 49.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyp.json new file mode 100644 index 000000000000..4a7e09e3b653 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/fixtures/julia/strides_xpyp.json @@ -0,0 +1,20 @@ +{ + "order": "row-major", + "trans": "N", + "M": 4, + "N": 3, + "kl": 1, + "ku": 1, + "alpha": 2.0, + "lda": 4, + "A": [ + 0.0, 1.0, 2.0, 3.0, + 5.0, 6.0, 7.0, 8.0, + 10.0, 11.0, 12.0, 13.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "beta": 3.0, + "y": [ 6.0, 7.0, 8.0, 9.0, 10.0 ], + "strideY": 1, + "y_out": [ 32.0, 77.0, 110.0, 99.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.js b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.js new file mode 100644 index 000000000000..7d177ae04156 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.js @@ -0,0 +1,82 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var sgbmv = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sgbmv, '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 sgbmv.ndarray, 'function', 'method is a function' ); + t.end(); +}); + +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var sgbmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sgbmv, mock, 'returns expected value' ); + t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } +}); + +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { + var sgbmv; + var main; + + main = require( './../lib/sgbmv.js' ); + + sgbmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sgbmv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.ndarray.js new file mode 100644 index 000000000000..dbd68494d51d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.ndarray.js @@ -0,0 +1,325 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float32Array = require( '@stdlib/array/float32' ); +var scopy = require( '@stdlib/blas/base/scopy' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sgbmv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var stridexoyo = require( './fixtures/julia/strides_xoyo.json' ); +var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); +var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); +var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); +var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sgbmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 16', function test( t ) { + t.strictEqual( sgbmv.length, 16, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals (sx=1, sy=1)', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexoyo.order; + trans = stridexoyo.trans; + + m = stridexoyo.M; + n = stridexoyo.N; + kl = stridexoyo.kl; + ku = stridexoyo.ku; + lda = stridexoyo.lda; + + alpha = stridexoyo.alpha; + beta = stridexoyo.beta; + + a = new Float32Array( stridexoyo.A ); + x = new Float32Array( stridexoyo.x ); + y = new Float32Array( stridexoyo.y ); + + expected = new Float32Array( stridexoyo.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, 0, beta, y, 1, 0 ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports `y` offset', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyn.order; + trans = stridexpyn.trans; + + m = stridexpyn.M; + n = stridexpyn.N; + kl = stridexpyn.kl; + ku = stridexpyn.ku; + lda = stridexpyn.lda; + + alpha = stridexpyn.alpha; + beta = stridexpyn.beta; + + a = new Float32Array( stridexpyn.A ); + x = new Float32Array( stridexpyn.x ); + y = new Float32Array( stridexpyn.y ); + + expected = new Float32Array( stridexpyn.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, 0, beta, y, -1, 3 ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports `x` offset', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexnyp.order; + trans = stridexnyp.trans; + + m = stridexnyp.M; + n = stridexnyp.N; + kl = stridexnyp.kl; + ku = stridexnyp.ku; + lda = stridexnyp.lda; + + alpha = stridexnyp.alpha; + beta = stridexnyp.beta; + + a = new Float32Array( stridexnyp.A ); + x = new Float32Array( stridexnyp.x ); + y = new Float32Array( stridexnyp.y ); + + expected = new Float32Array( stridexnyp.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, -1, 4, beta, y, 2, 0 ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input array', function test( t ) { + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyp.order; + trans = stridexpyp.trans; + + m = stridexpyp.M; + n = stridexpyp.N; + kl = stridexpyp.kl; + ku = stridexpyp.ku; + lda = stridexpyp.lda; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, 0, beta, y, 1, 0 ); // eslint-disable-line max-len + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter less than to `0`, the function leaves both input arrays unchanged', function test( t ) { + var alpha; + var order; + var trans; + var beta; + var lda; + var kl; + var ku; + var xe; + var ye; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyp.order; + trans = stridexpyp.trans; + + m = stridexpyp.M; + n = stridexpyp.N; + kl = stridexpyp.kl; + ku = stridexpyp.ku; + lda = stridexpyp.lda; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + xe = new Float32Array( x.length ); + scopy( x.length, x, 1, xe, 1 ); + + ye = new Float32Array( y.length ); + scopy( y.length, y, 1, ye, 1 ); + + sgbmv( order, trans, -1, n, kl, ku, alpha, a, lda, x, 1, 0, beta, y, 1, 0 ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + sgbmv( order, trans, m, -1, kl, ku, alpha, a, lda, x, 1, 0, beta, y, 1, 0 ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexnyn.order; + trans = stridexnyn.trans; + + m = stridexnyn.M; + n = stridexnyn.N; + kl = stridexnyn.kl; + ku = stridexnyn.ku; + lda = stridexnyn.lda; + + alpha = stridexnyn.alpha; + beta = stridexnyn.beta; + + a = new Float32Array( stridexnyn.A ); + x = new Float32Array( stridexnyn.x ); + y = new Float32Array( stridexnyn.y ); + + expected = new Float32Array( stridexnyn.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, -1, 2, beta, y, -1, 3 ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.sgbmv.js b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.sgbmv.js new file mode 100644 index 000000000000..72581fc21abc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sgbmv/test/test.sgbmv.js @@ -0,0 +1,325 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 Float32Array = require( '@stdlib/array/float32' ); +var scopy = require( '@stdlib/blas/base/scopy' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sgbmv = require( './../lib/sgbmv.js' ); + + +// FIXTURES // + +var stridexoyo = require( './fixtures/julia/strides_xoyo.json' ); +var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); +var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); +var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); +var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sgbmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 14', function test( t ) { + t.strictEqual( sgbmv.length, 14, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals (sx=1, sy=1)', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexoyo.order; + trans = stridexoyo.trans; + + m = stridexoyo.M; + n = stridexoyo.N; + kl = stridexoyo.kl; + ku = stridexoyo.ku; + lda = stridexoyo.lda; + + alpha = stridexoyo.alpha; + beta = stridexoyo.beta; + + a = new Float32Array( stridexoyo.A ); + x = new Float32Array( stridexoyo.x ); + y = new Float32Array( stridexoyo.y ); + + expected = new Float32Array( stridexoyo.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, beta, y, 1 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals (sx=1, sy=-1)', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyn.order; + trans = stridexpyn.trans; + + m = stridexpyn.M; + n = stridexpyn.N; + kl = stridexpyn.kl; + ku = stridexpyn.ku; + lda = stridexpyn.lda; + + alpha = stridexpyn.alpha; + beta = stridexpyn.beta; + + a = new Float32Array( stridexpyn.A ); + x = new Float32Array( stridexpyn.x ); + y = new Float32Array( stridexpyn.y ); + + expected = new Float32Array( stridexpyn.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, beta, y, -1 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations `y = alpha*A*x + beta*y` or `y = alpha*A**T*x + beta*y` with kl as sub-diagonals and ku as super-diagonals (sx=-1, sy=2)', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexnyp.order; + trans = stridexnyp.trans; + + m = stridexnyp.M; + n = stridexnyp.N; + kl = stridexnyp.kl; + ku = stridexnyp.ku; + lda = stridexnyp.lda; + + alpha = stridexnyp.alpha; + beta = stridexnyp.beta; + + a = new Float32Array( stridexnyp.A ); + x = new Float32Array( stridexnyp.x ); + y = new Float32Array( stridexnyp.y ); + + expected = new Float32Array( stridexnyp.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, -1, beta, y, 2 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input array', function test( t ) { + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyp.order; + trans = stridexpyp.trans; + + m = stridexpyp.M; + n = stridexpyp.N; + kl = stridexpyp.kl; + ku = stridexpyp.ku; + lda = stridexpyp.lda; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, 1, beta, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided an `M` or `N` parameter less than to `0`, the function leaves both input arrays unchanged', function test( t ) { + var alpha; + var order; + var trans; + var beta; + var lda; + var kl; + var ku; + var xe; + var ye; + var a; + var m; + var n; + var x; + var y; + + order = stridexpyp.order; + trans = stridexpyp.trans; + + m = stridexpyp.M; + n = stridexpyp.N; + kl = stridexpyp.kl; + ku = stridexpyp.ku; + lda = stridexpyp.lda; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + xe = new Float32Array( x.length ); + scopy( x.length, x, 1, xe, 1 ); + + ye = new Float32Array( y.length ); + scopy( y.length, y, 1, ye, 1 ); + + sgbmv( order, trans, -1, n, kl, ku, alpha, a, lda, x, 1, beta, y, 1 ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + sgbmv( order, trans, m, -1, kl, ku, alpha, a, lda, x, 1, beta, y, 1 ); + t.deepEqual( x, xe, 'returns expected value' ); + t.deepEqual( y, ye, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var alpha; + var order; + var trans; + var beta; + var lda; + var out; + var kl; + var ku; + var a; + var m; + var n; + var x; + var y; + + order = stridexnyn.order; + trans = stridexnyn.trans; + + m = stridexnyn.M; + n = stridexnyn.N; + kl = stridexnyn.kl; + ku = stridexnyn.ku; + lda = stridexnyn.lda; + + alpha = stridexnyn.alpha; + beta = stridexnyn.beta; + + a = new Float32Array( stridexnyn.A ); + x = new Float32Array( stridexnyn.x ); + y = new Float32Array( stridexnyn.y ); + + expected = new Float32Array( stridexnyn.y_out ); + + out = sgbmv( order, trans, m, n, kl, ku, alpha, a, lda, x, -1, beta, y, -1 ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +});