From 592175b673493152049ffea6b7c1efcc1f7f1187 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 18 Jun 2024 19:02:14 +0530 Subject: [PATCH 01/19] feat: add BLAS Level 2 routine for ssbmv --- .../@stdlib/blas/base/ssbmv/README.md | 265 ++++++++++ .../blas/base/ssbmv/benchmark/benchmark.js | 105 ++++ .../base/ssbmv/benchmark/benchmark.ndarray.js | 105 ++++ .../@stdlib/blas/base/ssbmv/docs/repl.txt | 167 ++++++ .../blas/base/ssbmv/docs/types/index.d.ts | 138 +++++ .../blas/base/ssbmv/docs/types/test.ts | 500 ++++++++++++++++++ .../@stdlib/blas/base/ssbmv/examples/index.js | 37 ++ .../@stdlib/blas/base/ssbmv/lib/index.js | 72 +++ .../@stdlib/blas/base/ssbmv/lib/main.js | 35 ++ .../@stdlib/blas/base/ssbmv/lib/ndarray.js | 176 ++++++ .../@stdlib/blas/base/ssbmv/lib/ssbmv.js | 182 +++++++ .../@stdlib/blas/base/ssbmv/package.json | 68 +++ .../base/ssbmv/test/fixtures/julia/REQUIRE | 2 + .../test/fixtures/julia/strides_xnyn.json | 15 + .../test/fixtures/julia/strides_xnyp.json | 15 + .../test/fixtures/julia/strides_xoyt.json | 15 + .../test/fixtures/julia/strides_xpyn.json | 15 + .../test/fixtures/julia/strides_xpyp.json | 15 + .../@stdlib/blas/base/ssbmv/test/test.js | 82 +++ .../blas/base/ssbmv/test/test.ndarray.js | 321 +++++++++++ .../blas/base/ssbmv/test/test.ssbmv.js | 321 +++++++++++ 21 files changed, 2651 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/README.md b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md new file mode 100644 index 000000000000..e2ddcd26ce14 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md @@ -0,0 +1,265 @@ + + +# ssbmv + +> Perform one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. + +
+ +## Usage + +```javascript +var ssbmv = require( '@stdlib/blas/base/ssbmv' ); +``` + +#### ssbmv( ord, uplo, N, k, α, A, LDA, x, sx, β, y, sy ) + +Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + +ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); +// y => [ ~0.2, ~1.7, ~0.9 ] +``` + +The function has the following parameters: + +- **ord**: storage layout. +- **uplo**: specifies the operation to be performed. +- **N**: specifies the order of the matrix `A`. +- **k**: number of super-diagonals. +- **α**: 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`. +- **β**: scalar constant. +- **y**: output [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. + +The stride parameters determine how operations are performed. For example, to +perform one of the matrix-vector operations starting from the second index of `x`, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssbmv( 'row-major', 'upper', 3, 1, 2.0, A, 3, x, -1, 1.0, y, 1 ); +// y => [ ~3.2, ~3.6, ~6.8 ] +``` + +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, 1.0 ] ); +var y0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 4.0, 5.0, 0.0, 0.0, 6.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 1st element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 1st element + +ssbmv( 'row-major', 'upper', 3, 1, 1.0, A, 3, x1, -1, 1.0, y1, -1 ); +// y0 => [ 1.0, 5.0, 7.0, 4.0 ] +``` + +#### ssbmv.ndarray( ord, uplo, N, k, α, A, LDA, x, sx, ox, β, y, sy, oy ) + +Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssbmv.ndarray( 'row-major', 'upper', 3, 1, 2.0, A, 3, x, -1, 2, 1.0, y, 1, 0 ); +// y => [ ~3.2, ~3.6, ~6.8 ] +``` + +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 A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +ssbmv.ndarray( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, -1, 2, 1.0, y, -1, 2 ); +// y => [ ~1.9, ~2.7, ~1.2 ] +``` + +
+ + + +
+ +## Notes + +- `ssbmv()` corresponds to the [BLAS][blas] level 2 function [`ssbmv`][ssbmv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ssbmv = require( '@stdlib/blas/base/ssbmv' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = discreteUniform( N*N, 0, 255, opts ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +ssbmv.ndarray( 'row-major', 'upper', N, 1, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 ); +console.log( y ); + +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/blas/base/ssbmv.h" +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js new file mode 100644 index 000000000000..fd321387cc38 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssbmv = require( './../lib/ssbmv.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 = ssbmv( 'row-major', 'upper', len, 1, 1.0, A, len, x, 1, 1.0, y, 1 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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 = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..9d60037e7c1b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssbmv = 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 = ssbmv( 'row-major', 'upper', len, 1, 1.0, A, len, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( 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 = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:size='+(len*len), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt new file mode 100644 index 000000000000..2a76ae4c731c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -0,0 +1,167 @@ + +{{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) + Perform one of the matrix-vector operations `y = α*A*x + β*y` + where α and β are scalars, x and y are n element vectors and A is + an n by n symmetric matrix, with k 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 `N` is equal to `0`, the function returns `y` unchanged. + + If `α` equals `0.0` and β equals `1.0`, the function returns `y` + unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. + + uplo: string + Specifies whether `A` is upper or lower triangular matrix. + + N: integer + Specifies the order of the matrix `A`. + + k: integer + Specifies the number of super-diagonals. + + α: number + Scalar constant. + + A: Float32Array + Matrix. + + lda: integer + Leading dimension. + + x: Float32Array + Input vector `x`. + + sx: integer + Index increment for `x`. + + β: number + Scalar constant. + + 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', 'upper', 2, 1, 1.0, A, 2, x, 1, 1.0, y, 1 ) + [ ~4.0, ~6.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', 'upper', 2, 1, 1.0, A, 2, x, -1, 1.0, y, -1 ) + [ ~6.0, ~4.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 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, 0.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); + > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x1, 1, 1.0, y1, 1 ) + > y0 + [ ~4.0, ~3.0 ] + + +{{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) + Perform one of the matrix-vector operations `y = α*A*x + β*y` + where α and β are scalars, x and y are n element vectors and A is + an n by n symmetric matrix, with k 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 + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. + + uplo: string + Specifies whether `A` is upper or lower triangular matrix. + + N: integer + Specifies the order of the matrix `A`. + + k: integer + Specifies the number of super-diagonals. + + α: 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`. + + β: 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 ord = 'row-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( ord, uplo, 2, 1, 1.0, A, 2, x, 1, 0, 1.0, y, 1, 0 ) + [ ~4.0, ~6.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 ord = 'row-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( ord, uplo, 2, 1, 1.0, A, 2, x, -1, 1, 1.0, y, -1, 1 ) + [ ~6.0, ~4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts new file mode 100644 index 000000000000..b384f5d23a9c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -0,0 +1,138 @@ +/* +* @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 + +/** +* Storage layouts. +*/ +type Order = 'row-major' | 'column-major'; + +/** +* Upper or lower triangular indicator. +*/ +type UPLO = 'upper' | 'lower'; + +/** +* Interface describing `ssbmv`. +*/ +interface Routine { + /** + * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param N - number of columns in the matrix `A` + * @param k - 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 A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + * + * ssbmv( 'row-major, 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); + * // y => [ ~0.2, ~1.7, ~0.9 ] + */ + ( order: Order, uplo: UPLO, N: number, k: 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` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals using alternative indexing semantics. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param N - number of columns in the matrix `A` + * @param k - 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 A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + * + * ssbmv.ndarray( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); + * // y => [ ~0.2, ~1.7, ~0.9 ] + */ + ndarray( order: Order, uplo: UPLO, N: number, k: 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` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied +* @param N - number of columns in the matrix `A` +* @param k - 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 A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssbmv( 'row-major', 'upper', 3, 1, 2.0, A, 3, x, -1, 1.0, y, 1 ); +* // y => [ ~3.2, ~3.6, ~6.8 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssbmv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 2, 1.0, y, 1, 0 ); +* // y => [ ~3.2, ~3.6, ~6.8 ] +*/ +declare var ssbmv: Routine; + + +// EXPORTS // + +export = ssbmv; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts new file mode 100644 index 000000000000..9b5942a5366f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts @@ -0,0 +1,500 @@ +/* +* @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 ssbmv = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 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 ); + + ssbmv( 10, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( true, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( false, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( null, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( undefined, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( [], 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( {}, 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( ( x: number ): number => x, 'upper', 10, 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 ); + + ssbmv( 'row-major', 10, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', true, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', false, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', null, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', undefined, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', [ '1' ], 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', {}, 10, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', ( x: number ): number => x, 10, 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 ); + + ssbmv( 'row-major', 'upper', '10', 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', true, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', false, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', null, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', undefined, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', [], 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', {}, 1, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', ( 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 fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, '10', 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, true, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, false, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, null, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, undefined, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, [], 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, {}, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 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 ); + + ssbmv( 'row-major', 'upper', 10, 1, '10', A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, true, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, false, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, null, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, undefined, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, [], A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, {}, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 fsixth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, 10, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, '10', 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, true, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, false, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, null, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, undefined, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, [ '1' ], 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, {}, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, '10', x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, true, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, false, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, null, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, [], x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, {}, x, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 eighth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, 10, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, '10', 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, true, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, false, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, null, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, undefined, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, {}, 1, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, '10', 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, true, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, false, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, null, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, undefined, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, [], 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, {}, 1.0, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, '10', y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, true, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, false, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, null, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, undefined, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, [], y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, {}, y, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 eleventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, 10, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, '10', 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, true, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, false, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, null, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, undefined, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, {}, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, '10' ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, true ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, false ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, null ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, undefined ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, [] ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y, {} ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 ); + + ssbmv(); // $ExpectError + ssbmv( 'row-major' ); // $ExpectError + ssbmv( 'row-major', 'upper' ); // $ExpectError + ssbmv( 'row-major', 'upper', 10 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0 ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 1.0, y ); // $ExpectError + ssbmv( 'row-major', 'upper', 10, 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 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 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 ); + + ssbmv.ndarray( 10, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( true, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( false, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( null, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( undefined, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( [], 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( {}, 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( ( x: number ): number => x, 'upper', 10, 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 ); + + ssbmv.ndarray( 'row-major', 10, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', true, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', false, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', null, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', undefined, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', [ '1' ], 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', {}, 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', ( x: number ): number => x, 10, 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 ); + + ssbmv.ndarray( 'row-major', 'upper', '10', 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', true, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', false, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', null, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', undefined, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', [], 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', {}, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', ( 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 fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, '10', 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, true, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, false, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, null, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, undefined, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, [], 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, {}, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, ( 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 fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, '10', A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, true, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, false, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, null, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, undefined, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, [], A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, {}, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 sixth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, 10, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, '10', 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, true, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, false, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, null, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, undefined, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, [ '1' ], 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, {}, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, '10', x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, [], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 eighth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, 10, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, '10', 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, '10', 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, true, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, false, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, null, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, [], 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, {}, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, '10', 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, true, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, false, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, null, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, [], 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, {}, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, '10', y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, true, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, false, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, null, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, [], y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, {}, y, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 twelfth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, 10, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, '10', 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, '10', 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 fourteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, '10' ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, true ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, false ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, null ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 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 ); + + ssbmv.ndarray(); // $ExpectError + ssbmv.ndarray( 'row-major' ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper' ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1 ); // $ExpectError + ssbmv.ndarray( 'row-major', 'upper', 10, 1, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js new file mode 100644 index 000000000000..6a7cb444e185 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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 ssbmv = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = discreteUniform( N*N, 0, 255, opts ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +ssbmv.ndarray( 'row-major', 'upper', N, 1, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js new file mode 100644 index 000000000000..6e9237ee53e1 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js @@ -0,0 +1,72 @@ +/** +* @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` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* +* @module @stdlib/blas/base/ssbmv +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssbmv = require( '@stdlib/blas/base/ssbmv' ); +* +* var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ ~0.2, ~1.7, ~0.9 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssbmv = require( '@stdlib/blas/base/ssbmv' ); +* +* var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssbmv.ndarray( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); +* // y => [ ~0.2, ~1.7, ~0.9 ] +*/ + +// 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 ssbmv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ssbmv = main; +} else { + ssbmv = tmp; +} + + +// EXPORTS // + +module.exports = ssbmv; + +// exports: { "ndarray": "ssbmv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/main.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/main.js new file mode 100644 index 000000000000..187287892c9d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/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 ssbmv = require( './ssbmv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ssbmv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ssbmv; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js new file mode 100644 index 000000000000..ec03615baad0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -0,0 +1,176 @@ +/** +* @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 sfill = require( '@stdlib/blas/ext/base/sfill' ); +var sscal = require( '@stdlib/blas/base/sscal' ); +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); +var abs = require( '@stdlib/math/special/abs' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied +* @param {NonNegativeInteger} N - specifies the order of matrix `A` +* @param {NonNegativeInteger} k - number of super-diagonals +* @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 - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - `x` starting index +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - `y` starting index +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be greater than ( k + 1 ) +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} thirteenth argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); +* // y => [ ~0.2, ~1.7, ~0.9 ] +*/ +function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params + var kplus1; + var temp1; + var temp2; + var ix; + var iy; + var jx; + var jy; + var kx; + var ky; + var i; + var j; + var l; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + } + if ( N < 0 ) { + throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + } + if ( k < 0 ) { + throw new RangeError( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ); + } + if ( LDA < ( k + 1 ) ) { + throw new RangeError( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ); + } + if ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Set up the start points in `x` and `y` if the stride is negative... + kx = offsetX; + ky = offsetY; + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + sscal( N, beta, y, abs( strideY ) ); + } + } + if ( alpha === 0.0 ) { + return y; + } + if ( + ( order === 'column-major' && uplo === 'upper' ) || + ( order === 'row-major' && uplo === 'lower' ) + ) { + kplus1 = k; + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + ix = kx; + iy = ky; + l = kplus1 - j; + for ( i = max( 0, ( j - k ) ); i < j; i++ ) { + y[ iy ] += f32( temp1 * A[ ( l + i ) + ( j * LDA ) ] ); + temp2 += f32( A[ ( l + i ) + ( j * LDA ) ] * x[ ix ] ); + ix += strideX; + iy += strideY; + } + y[ jy ] += f32( ( temp1 * A[ kplus1 + ( LDA * j ) ] ) + ( alpha * temp2 ) ); // eslint-disable-line max-len + jx += strideX; + jy += strideY; + if ( j >= k ) { + kx += strideX; + ky += strideY; + } + } + return y; + } + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + y[ jy ] += f32( temp1 * A[ LDA * j ] ); + l = ( -j ); + ix = jx; + iy = jy; + for ( i = j + 1; i < min( N, ( j + k + 1 ) ); i++ ) { + ix += strideX; + iy += strideY; + y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); + temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); + } + y[ jy ] += alpha * temp2; + jx += strideX; + jy += strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = ssbmv; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js new file mode 100644 index 000000000000..501613e0ac82 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -0,0 +1,182 @@ +/** +* @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 sfill = require( '@stdlib/blas/ext/base/sfill' ); +var sscal = require( '@stdlib/blas/base/sscal' ); +var max = require( '@stdlib/math/base/special/max' ); +var min = require( '@stdlib/math/base/special/min' ); +var abs = require( '@stdlib/math/special/abs' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied +* @param {NonNegativeInteger} N - specifies the order of matrix `A` +* @param {NonNegativeInteger} k - number of super-diagonals +* @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 - first input array +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input array +* @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} fourth argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be greater than ( k + 1 ) +* @throws {RangeError} ninth argument must be non-zero +* @throws {RangeError} twelfth argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ ~0.2, ~1.7, ~0.9 ] +*/ +function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params + var kplus1; + var temp1; + var temp2; + var ix; + var iy; + var jx; + var jy; + var kx; + var ky; + var i; + var j; + var l; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + } + if ( N < 0 ) { + throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + } + if ( k < 0 ) { + throw new RangeError( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ); + } + if ( LDA < ( k + 1 ) ) { + throw new RangeError( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ); + } + if ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Set up the start points in `x` and `y` if the stride is negative... + if ( strideX > 0 ) { + kx = 0; + } else { + kx = ( 1 - N ) * strideX; + } + if ( strideY > 0 ) { + ky = 0; + } else { + ky = ( 1 - N ) * strideY; + } + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + sscal( N, beta, y, abs( strideY ) ); + } + } + if ( alpha === 0.0 ) { + return y; + } + if ( + ( order === 'column-major' && uplo === 'upper' ) || + ( order === 'row-major' && uplo === 'lower' ) + ) { + kplus1 = k; + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + ix = kx; + iy = ky; + l = kplus1 - j; + for ( i = max( 0, ( j - k ) ); i < j; i++ ) { + y[ iy ] += f32( temp1 * A[ ( l + i ) + ( j * LDA ) ] ); + temp2 += f32( A[ ( l + i ) + ( j * LDA ) ] * x[ ix ] ); + ix += strideX; + iy += strideY; + } + y[ jy ] += f32( ( temp1 * A[ kplus1 + ( LDA * j ) ] ) + ( alpha * temp2 ) ); // eslint-disable-line max-len + jx += strideX; + jy += strideY; + if ( j >= k ) { + kx += strideX; + ky += strideY; + } + } + return y; + } + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + y[ jy ] += f32( temp1 * A[ LDA * j ] ); + l = ( -j ); + ix = jx; + iy = jy; + for ( i = j + 1; i < min( N, ( j + k + 1 ) ); i++ ) { + ix += strideX; + iy += strideY; + y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); + temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); + } + y[ jy ] += alpha * temp2; + jx += strideX; + jy += strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = ssbmv; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/package.json b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json new file mode 100644 index 000000000000..77914f76d045 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/ssbmv", + "version": "0.0.0", + "description": "Perform one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k 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", + "ssbmv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..308c3be89c85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json new file mode 100644 index 000000000000..5bd38d32eccb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json @@ -0,0 +1,15 @@ +{ + "uplo": "lower", + "order": "row-major", + "N": 3, + "k": 1, + "alpha": 1.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "strideY": -1, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 1.9, 2.7, 1.2 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json new file mode 100644 index 000000000000..3d6ab11f4fc3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "strideY": 1, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 3.2, 3.6, 6.8 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json new file mode 100644 index 000000000000..23ef37d43f3f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "strideY": 2, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 1.2, 2.0, 7.8 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json new file mode 100644 index 000000000000..7d338b0afb8d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "strideY": -1, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 3.6, 3.6, 3.6 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json new file mode 100644 index 000000000000..20f2535b82a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json @@ -0,0 +1,15 @@ +{ + "uplo": "lower", + "order": "row-major", + "N": 3, + "k": 1, + "alpha": 1.0, + "beta": 0.0, + "lda": 3, + "strideX": 1, + "strideY": 1, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 0.0, 0.0, 0.0 ], + "y_out": [ 0.2, 1.7, 0.9 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.js new file mode 100644 index 000000000000..997024f0d260 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/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 ssbmv = 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 ssbmv, '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 ssbmv.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 ssbmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssbmv, 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 ssbmv; + var main; + + main = require( './../lib/ssbmv.js' ); + + ssbmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssbmv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js new file mode 100644 index 000000000000..31ffb5c8c02d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js @@ -0,0 +1,321 @@ +/** +* @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 EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ssbmv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var stridexoyt = require( './fixtures/julia/strides_xoyt.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 ssbmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 14', function test( t ) { + t.strictEqual( ssbmv.length, 14, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals, with k super-diagonals (sx=1, sy=1)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + lda = stridexpyp.lda; + k = stridexpyp.k; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + expected = new Float32Array( stridexpyp.y_out ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 0 ); // eslint-disable-line max-len + 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 matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals (sx=1, sy=2)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexoyt.order; + uplo = stridexoyt.uplo; + + n = stridexoyt.N; + lda = stridexoyt.lda; + k = stridexpyp.k; + + strideX = stridexoyt.strideX; + strideY = stridexoyt.strideY; + + alpha = stridexoyt.alpha; + beta = stridexoyt.beta; + + a = new Float32Array( stridexoyt.A ); + x = new Float32Array( stridexoyt.x ); + y = new Float32Array( stridexoyt.y ); + + expected = new Float32Array( stridexoyt.y_out ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 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 an `x` offset', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexnyp.order; + uplo = stridexnyp.uplo; + + n = stridexnyp.N; + k = stridexnyp.k; + lda = stridexnyp.lda; + + strideX = stridexnyp.strideX; + strideY = stridexnyp.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 2, beta, y, strideY, 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 a `y` offset', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyn.order; + uplo = stridexpyn.uplo; + + n = stridexpyn.N; + k = stridexpyn.k; + lda = stridexpyn.lda; + + strideX = stridexpyn.strideX; + strideY = stridexpyn.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 2 ); // 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 strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + k = stridexpyp.k; + lda = stridexpyp.lda; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 0 ); // eslint-disable-line max-len + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexnyn.order; + uplo = stridexnyn.uplo; + + n = stridexnyn.N; + k = stridexnyn.k; + lda = stridexnyn.lda; + + strideX = stridexnyn.strideX; + strideY = stridexnyn.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 2, beta, y, strideY, 2 ); // 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/ssbmv/test/test.ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js new file mode 100644 index 000000000000..ef643d3c6151 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js @@ -0,0 +1,321 @@ +/** +* @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 EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ssbmv = require( './../lib/ssbmv.js' ); + + +// FIXTURES // + +var stridexoyt = require( './fixtures/julia/strides_xoyt.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 ssbmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( ssbmv.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals, with k super-diagonals (sx=1, sy=1)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + lda = stridexpyp.lda; + k = stridexpyp.k; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + expected = new Float32Array( stridexpyp.y_out ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + 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 matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals (sx=1, sy=2)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexoyt.order; + uplo = stridexoyt.uplo; + + n = stridexoyt.N; + lda = stridexoyt.lda; + k = stridexpyp.k; + + strideX = stridexoyt.strideX; + strideY = stridexoyt.strideY; + + alpha = stridexoyt.alpha; + beta = stridexoyt.beta; + + a = new Float32Array( stridexoyt.A ); + x = new Float32Array( stridexoyt.x ); + y = new Float32Array( stridexoyt.y ); + + expected = new Float32Array( stridexoyt.y_out ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function a negative `x` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexnyp.order; + uplo = stridexnyp.uplo; + + n = stridexnyp.N; + lda = stridexnyp.lda; + k = stridexnyp.k; + + strideX = stridexnyp.strideX; + strideY = stridexnyp.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyn.order; + uplo = stridexpyn.uplo; + + n = stridexpyn.N; + lda = stridexpyn.lda; + k = stridexpyn.k; + + strideX = stridexpyn.strideX; + strideY = stridexpyn.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // 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 strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + lda = stridexpyp.lda; + k = stridexpyp.k; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var lda; + var out; + var a; + var k; + var n; + var x; + var y; + + order = stridexnyn.order; + uplo = stridexnyn.uplo; + + n = stridexnyn.N; + lda = stridexnyn.lda; + k = stridexnyn.k; + + strideX = stridexnyn.strideX; + strideY = stridexnyn.strideY; + + 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 = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); From dd9d170963d8743340c8089f846c8f7815494687 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Sat, 22 Jun 2024 14:41:51 +0530 Subject: [PATCH 02/19] refactor: update implementation --- .../@stdlib/blas/base/ssbmv/lib/index.js | 2 +- .../@stdlib/blas/base/ssbmv/lib/ndarray.js | 27 +++++++++---------- .../@stdlib/blas/base/ssbmv/lib/ssbmv.js | 22 ++++++++------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js index 6e9237ee53e1..9252c21e519e 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* BLAS level 2 routine to perform the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @module @stdlib/blas/base/ssbmv * diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js index ec03615baad0..21ddd33f1bb7 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -20,11 +20,10 @@ // MODULES // -var sfill = require( '@stdlib/blas/ext/base/sfill' ); -var sscal = require( '@stdlib/blas/base/sscal' ); +var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; +var sscal = require( '@stdlib/blas/base/sscal' ).ndarray; var max = require( '@stdlib/math/base/special/max' ); var min = require( '@stdlib/math/base/special/min' ); -var abs = require( '@stdlib/math/special/abs' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); @@ -33,22 +32,22 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); // MAIN // /** -* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied -* @param {NonNegativeInteger} N - specifies the order of matrix `A` +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {NonNegativeInteger} k - number of super-diagonals * @param {number} alpha - scalar constant -* @param {Float32Array} A - matrix of coefficients +* @param {Float32Array} A - matrix * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - `x` starting index +* @param {NonNegativeInteger} offsetX - starting `x` index * @param {number} beta - scalar constant * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - `y` starting index +* @param {NonNegativeInteger} offsetY - starting `y` index * @throws {TypeError} first argument must be a valid order * @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} third argument must be a nonnegative integer @@ -68,7 +67,7 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); * // y => [ ~0.2, ~1.7, ~0.9 ] */ -function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params +function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len var kplus1; var temp1; var temp2; @@ -106,14 +105,13 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { return y; } - // Set up the start points in `x` and `y` if the stride is negative... kx = offsetX; ky = offsetY; if ( beta !== 1.0 ) { if ( beta === 0.0 ) { - sfill( N, 0.0, y, strideY ); + sfill( N, 0.0, y, strideY, offsetY ); } else { - sscal( N, beta, y, abs( strideY ) ); + sscal( N, beta, y, strideY, offsetY ); } } if ( alpha === 0.0 ) { @@ -138,7 +136,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, ix += strideX; iy += strideY; } - y[ jy ] += f32( ( temp1 * A[ kplus1 + ( LDA * j ) ] ) + ( alpha * temp2 ) ); // eslint-disable-line max-len + y[ jy ] += f32( f32( temp1 * A[ kplus1 + ( LDA * j ) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len jx += strideX; jy += strideY; if ( j >= k ) { @@ -148,6 +146,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, } return y; } + // ( order === 'row-major' && uplo === 'upper') || ( order === 'column-major' && uplo === 'lower' ) jx = kx; jy = ky; for ( j = 0; j < N; j++ ) { @@ -163,7 +162,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); } - y[ jy ] += alpha * temp2; + y[ jy ] += f32( alpha * temp2 ); jx += strideX; jy += strideY; } diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js index 501613e0ac82..32f6689474a9 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -24,7 +24,6 @@ var sfill = require( '@stdlib/blas/ext/base/sfill' ); var sscal = require( '@stdlib/blas/base/sscal' ); var max = require( '@stdlib/math/base/special/max' ); var min = require( '@stdlib/math/base/special/min' ); -var abs = require( '@stdlib/math/special/abs' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); @@ -33,14 +32,14 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); // MAIN // /** -* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied -* @param {NonNegativeInteger} N - specifies the order of matrix `A` +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {NonNegativeInteger} k - number of super-diagonals * @param {number} alpha - scalar constant -* @param {Float32Array} A - matrix of coefficients +* @param {Float32Array} A - matrix * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length @@ -66,7 +65,7 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); * // y => [ ~0.2, ~1.7, ~0.9 ] */ -function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params +function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params, max-len var kplus1; var temp1; var temp2; @@ -76,6 +75,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) var jy; var kx; var ky; + var sy; var i; var j; var l; @@ -104,7 +104,6 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { return y; } - // Set up the start points in `x` and `y` if the stride is negative... if ( strideX > 0 ) { kx = 0; } else { @@ -115,11 +114,15 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) } else { ky = ( 1 - N ) * strideY; } + sy = strideY; if ( beta !== 1.0 ) { if ( beta === 0.0 ) { sfill( N, 0.0, y, strideY ); } else { - sscal( N, beta, y, abs( strideY ) ); + if ( strideY < 0 ) { + sy = -sy; + } + sscal( N, beta, y, sy ); } } if ( alpha === 0.0 ) { @@ -144,7 +147,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) ix += strideX; iy += strideY; } - y[ jy ] += f32( ( temp1 * A[ kplus1 + ( LDA * j ) ] ) + ( alpha * temp2 ) ); // eslint-disable-line max-len + y[ jy ] += f32( f32( temp1 * A[ kplus1 + ( LDA * j ) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len jx += strideX; jy += strideY; if ( j >= k ) { @@ -154,6 +157,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) } return y; } + // ( order === 'row-major' && uplo === 'upper') || ( order === 'column-major' && uplo === 'lower' ) jx = kx; jy = ky; for ( j = 0; j < N; j++ ) { @@ -169,7 +173,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); } - y[ jy ] += alpha * temp2; + y[ jy ] += f32( alpha * temp2 ); jx += strideX; jy += strideY; } From 630794150f66e8f3f09e28fc8f96a30f7923cd17 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 11:49:55 +0530 Subject: [PATCH 03/19] test: update test directory path and cases --- .../@stdlib/blas/base/ssbmv/lib/ndarray.js | 2 +- .../test/fixtures/column_major_xnyn.json | 17 + .../test/fixtures/column_major_xnyp.json | 17 + .../test/fixtures/column_major_xoyt.json | 17 + .../test/fixtures/column_major_xpyn.json | 17 + .../test/fixtures/column_major_xpyp.json | 17 + .../base/ssbmv/test/fixtures/julia/REQUIRE | 2 - .../strides_xnyn.json => row_major_xnyn.json} | 2 + .../strides_xnyp.json => row_major_xnyp.json} | 2 + .../strides_xoyt.json => row_major_xoyt.json} | 6 +- .../strides_xpyn.json => row_major_xpyn.json} | 2 + .../strides_xpyp.json => row_major_xpyp.json} | 2 + .../blas/base/ssbmv/test/test.ndarray.js | 584 +++++++++++++----- .../blas/base/ssbmv/test/test.ssbmv.js | 584 +++++++++++++----- 14 files changed, 968 insertions(+), 303 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyp.json delete mode 100644 lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE rename lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/{julia/strides_xnyn.json => row_major_xnyn.json} (89%) rename lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/{julia/strides_xnyp.json => row_major_xnyp.json} (89%) rename lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/{julia/strides_xoyt.json => row_major_xoyt.json} (65%) rename lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/{julia/strides_xpyn.json => row_major_xpyn.json} (89%) rename lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/{julia/strides_xpyp.json => row_major_xpyp.json} (89%) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js index 21ddd33f1bb7..6c614ef0b72d 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -100,7 +100,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ); } if ( strideY === 0 ) { - throw new RangeError( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ); + throw new RangeError( 'invalid argument. Thirteenth argument must be non-zero. Value: `%d`.', strideY ); } if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { return y; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyn.json new file mode 100644 index 000000000000..8acf1988e1f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyn.json @@ -0,0 +1,17 @@ +{ + "uplo": "lower", + "order": "column-major", + "N": 3, + "k": 1, + "alpha": 1.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": -1, + "offsetY": 2, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 2.3, 1.8, 1.3 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyp.json new file mode 100644 index 000000000000..23604647c3a9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xnyp.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": 1, + "offsetY": 0, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 1.4, 8.2, 6.2 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xoyt.json new file mode 100644 index 000000000000..b00324c48e65 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xoyt.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 2, + "offsetY": 0, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "y_out": [ 2.2, 0.0, 9.4, 0.0, 7.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyn.json new file mode 100644 index 000000000000..f0be6e8f0597 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyn.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "k": 1, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": -1, + "offsetY": 2, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 2.8, 5.4, 3.4 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyp.json new file mode 100644 index 000000000000..d0a7b367501f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/column_major_xpyp.json @@ -0,0 +1,17 @@ +{ + "uplo": "lower", + "order": "column-major", + "N": 3, + "k": 1, + "alpha": 1.0, + "beta": 0.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 0.0, 0.0, 0.0 ], + "y_out": [ 0.3, 0.8, 1.3 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE deleted file mode 100644 index 308c3be89c85..000000000000 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -JSON 0.21 diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyn.json similarity index 89% rename from lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json rename to lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyn.json index 5bd38d32eccb..9236968974a7 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyn.json @@ -7,7 +7,9 @@ "beta": 1.0, "lda": 3, "strideX": -1, + "offsetX": 2, "strideY": -1, + "offsetY": 2, "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json similarity index 89% rename from lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json rename to lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json index 3d6ab11f4fc3..b458603866aa 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json @@ -7,7 +7,9 @@ "beta": 1.0, "lda": 3, "strideX": -1, + "offsetX": 2, "strideY": 1, + "offsetY": 0, "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], "x": [ 1.0, 2.0, 3.0 ], "y": [ 1.0, 2.0, 3.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json similarity index 65% rename from lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json rename to lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json index 23ef37d43f3f..204491cef188 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json @@ -7,9 +7,11 @@ "beta": 1.0, "lda": 3, "strideX": 1, + "offsetX": 0, "strideY": 2, + "offsetY": 0, "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], "x": [ 1.0, 2.0, 3.0 ], - "y": [ 1.0, 2.0, 3.0 ], - "y_out": [ 1.2, 2.0, 7.8 ] + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "y_out": [ 1.2, 0.0, 6.8, 0.0, 9.6, 0.0 ] } diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json similarity index 89% rename from lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json rename to lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json index 7d338b0afb8d..9edc7f1862c5 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json @@ -7,7 +7,9 @@ "beta": 1.0, "lda": 3, "strideX": 1, + "offsetX": 0, "strideY": -1, + "offsetY": 2, "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 2.0, 3.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json similarity index 89% rename from lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json rename to lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json index 20f2535b82a8..81dc7fb15935 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/julia/strides_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json @@ -7,7 +7,9 @@ "beta": 0.0, "lda": 3, "strideX": 1, + "offsetX": 0, "strideY": 1, + "offsetY": 0, "A": [ 0.5, -0.2, 0.1, 0.4, 0.6, -0.3, 0.7, 0.2, -0.8 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 0.0, 0.0, 0.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js index 31ffb5c8c02d..d4dd0aa8c94c 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js @@ -24,16 +24,23 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); var ssbmv = require( './../lib/ndarray.js' ); // FIXTURES // -var stridexoyt = require( './fixtures/julia/strides_xoyt.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' ); +var rxoyt = require( './fixtures/row_major_xoyt.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + +var cxoyt = require( './fixtures/column_major_xoyt.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); // FUNCTIONS // @@ -78,244 +85,523 @@ tape( 'the function has an arity of 14', function test( t ) { t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals, with k super-diagonals (sx=1, sy=1)', function test( t ) { +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( value, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, value, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, value, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, value, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { + var values; + var i; + + values = [ + 1, + 0, + -1, + -2 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), value, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), value, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid thirteenth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), value, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyp.N; - lda = stridexpyp.lda; - k = stridexpyp.k; + expected = new Float32Array( rxpyp.y_out ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, y, rxpyp.strideY, rxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - a = new Float32Array( stridexpyp.A ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + a = new Float32Array( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); - expected = new Float32Array( stridexpyp.y_out ); + expected = new Float32Array( cxpyp.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 0 ); // eslint-disable-line max-len + out = ssbmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.k, cxpyp.alpha, a, cxpyp.lda, x, cxpyp.strideX, cxpyp.offsetX, cxpyp.beta, y, cxpyp.strideY, cxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=2)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxoyt.A ); + x = new Float32Array( rxoyt.x ); + y = new Float32Array( rxoyt.y ); + + expected = new Float32Array( rxoyt.y_out ); + + out = ssbmv( rxoyt.order, rxoyt.uplo, rxoyt.N, rxoyt.k, rxoyt.alpha, a, rxoyt.lda, x, rxoyt.strideX, rxoyt.offsetX, rxoyt.beta, y, rxoyt.strideY, rxoyt.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals (sx=1, sy=2)', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=2)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexoyt.order; - uplo = stridexoyt.uplo; + a = new Float32Array( cxoyt.A ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); + + expected = new Float32Array( cxoyt.y_out ); - n = stridexoyt.N; - lda = stridexoyt.lda; - k = stridexpyp.k; + out = ssbmv( cxoyt.order, cxoyt.uplo, cxoyt.N, cxoyt.k, cxoyt.alpha, a, cxoyt.lda, x, cxoyt.strideX, cxoyt.offsetX, cxoyt.beta, y, cxoyt.strideY, cxoyt.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - strideX = stridexoyt.strideX; - strideY = stridexoyt.strideY; + t.end(); +}); - alpha = stridexoyt.alpha; - beta = stridexoyt.beta; +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - a = new Float32Array( stridexoyt.A ); - x = new Float32Array( stridexoyt.x ); - y = new Float32Array( stridexoyt.y ); + a = new Float32Array( rxpyn.A ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); - expected = new Float32Array( stridexoyt.y_out ); + expected = new Float32Array( rxpyn.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 0 ); // eslint-disable-line max-len + out = ssbmv( rxpyn.order, rxpyn.uplo, rxpyn.N, rxpyn.k, rxpyn.alpha, a, rxpyn.lda, x, rxpyn.strideX, rxpyn.offsetX, rxpyn.beta, y, rxpyn.strideY, rxpyn.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxpyn.A ); + x = new Float32Array( cxpyn.x ); + y = new Float32Array( cxpyn.y ); + + expected = new Float32Array( cxpyn.y_out ); + + out = ssbmv( cxpyn.order, cxpyn.uplo, cxpyn.N, cxpyn.k, cxpyn.alpha, a, cxpyn.lda, x, cxpyn.strideX, cxpyn.offsetX, cxpyn.beta, y, cxpyn.strideY, cxpyn.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function supports an `x` offset', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=-1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexnyp.order; - uplo = stridexnyp.uplo; + a = new Float32Array( rxnyp.A ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); - n = stridexnyp.N; - k = stridexnyp.k; - lda = stridexnyp.lda; + expected = new Float32Array( rxnyp.y_out ); - strideX = stridexnyp.strideX; - strideY = stridexnyp.strideY; + out = ssbmv( rxnyp.order, rxnyp.uplo, rxnyp.N, rxnyp.k, rxnyp.alpha, a, rxnyp.lda, x, rxnyp.strideX, rxnyp.offsetX, rxnyp.beta, y, rxnyp.strideY, rxnyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexnyp.alpha; - beta = stridexnyp.beta; + t.end(); +}); - a = new Float32Array( stridexnyp.A ); - x = new Float32Array( stridexnyp.x ); - y = new Float32Array( stridexnyp.y ); +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=-1, sy=1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxnyp.A ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); - expected = new Float32Array( stridexnyp.y_out ); + expected = new Float32Array( cxnyp.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 2, beta, y, strideY, 0 ); // eslint-disable-line max-len + out = ssbmv( cxnyp.order, cxnyp.uplo, cxnyp.N, cxnyp.k, cxnyp.alpha, a, cxnyp.lda, x, cxnyp.strideX, cxnyp.offsetX, cxnyp.beta, y, cxnyp.strideY, cxnyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the second input vector', function test( t ) { + var out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, y, rxpyp.strideY, rxpyp.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); -tape( 'the function supports a `y` offset', function test( t ) { +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (row-major)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexpyn.order; - uplo = stridexpyn.uplo; + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyn.N; - k = stridexpyn.k; - lda = stridexpyn.lda; + expected = new Float32Array( rxpyp.y ); - strideX = stridexpyn.strideX; - strideY = stridexpyn.strideY; + out = ssbmv( rxpyp.order, rxpyp.uplo, 0, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, y, rxpyp.strideY, rxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyn.alpha; - beta = stridexpyn.beta; + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, 0.0, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.offsetX, 1.0, y, rxpyp.strideY, rxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - a = new Float32Array( stridexpyn.A ); - x = new Float32Array( stridexpyn.x ); - y = new Float32Array( stridexpyn.y ); + t.end(); +}); - expected = new Float32Array( stridexpyn.y_out ); +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 2 ); // eslint-disable-line max-len - isApprox( t, y, expected, 2.0 ); + a = new Float32Array( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y ); + + out = ssbmv( cxpyp.order, cxpyp.uplo, 0, cxpyp.k, cxpyp.alpha, a, cxpyp.lda, x, cxpyp.strideX, cxpyp.offsetX, cxpyp.beta, y, cxpyp.strideY, cxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + out = ssbmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.k, 0.0, a, cxpyp.lda, x, cxpyp.strideX, cxpyp.offsetX, 1.0, y, cxpyp.strideY, cxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'when `α` is zero, the function scales the second input vector (row-major, upper)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = ssbmv( 'row-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0, 5.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = ssbmv( 'row-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0, 0.0, y, -1, 2 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function returns a reference to the second input array', function test( t ) { - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; +tape( 'when `α` is zero, the function scales the second input vector (row-major, lower)', function test( t ) { + var expected; var out; var a; - var k; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexpyp.N; - k = stridexpyp.k; - lda = stridexpyp.lda; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = ssbmv( 'row-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0, 5.0, y, -1, 2 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - a = new Float32Array( stridexpyp.A ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + out = ssbmv( 'row-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0, 0.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 0, beta, y, strideY, 0 ); // eslint-disable-line max-len +tape( 'when `α` is zero, the function scales the second input vector (column-major, upper)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = ssbmv( 'column-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0, 5.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = ssbmv( 'column-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0, 0.0, y, -1, 2 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { +tape( 'when `α` is zero, the function scales the second input vector (column-major, lower)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexnyn.order; - uplo = stridexnyn.uplo; + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexnyn.N; - k = stridexnyn.k; - lda = stridexnyn.lda; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexnyn.strideX; - strideY = stridexnyn.strideY; + out = ssbmv( 'column-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0, 5.0, y, -1, 2 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexnyn.alpha; - beta = stridexnyn.beta; + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - a = new Float32Array( stridexnyn.A ); - x = new Float32Array( stridexnyn.x ); - y = new Float32Array( stridexnyn.y ); + out = ssbmv( 'column-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0, 0.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - expected = new Float32Array( stridexnyn.y_out ); + t.end(); +}); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, 2, beta, y, strideY, 2 ); // eslint-disable-line max-len +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxnyn.A ); + x = new Float32Array( rxnyn.x ); + y = new Float32Array( rxnyn.y ); + + expected = new Float32Array( rxnyn.y_out ); + + out = ssbmv( rxnyn.order, rxnyn.uplo, rxnyn.N, rxnyn.k, rxnyn.alpha, a, rxnyn.lda, x, rxnyn.strideX, rxnyn.offsetX, rxnyn.beta, y, rxnyn.strideY, rxnyn.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxnyn.A ); + x = new Float32Array( cxnyn.x ); + y = new Float32Array( cxnyn.y ); + + expected = new Float32Array( cxnyn.y_out ); + + out = ssbmv( cxnyn.order, cxnyn.uplo, cxnyn.N, cxnyn.k, cxnyn.alpha, a, cxnyn.lda, x, cxnyn.strideX, cxnyn.offsetX, cxnyn.beta, y, cxnyn.strideY, cxnyn.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js index ef643d3c6151..94709881be3c 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js @@ -24,16 +24,23 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); var ssbmv = require( './../lib/ssbmv.js' ); // FIXTURES // -var stridexoyt = require( './fixtures/julia/strides_xoyt.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' ); +var rxoyt = require( './fixtures/row_major_xoyt.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + +var cxoyt = require( './fixtures/column_major_xoyt.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); // FUNCTIONS // @@ -78,244 +85,523 @@ tape( 'the function has an arity of 12', function test( t ) { t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals, with k super-diagonals (sx=1, sy=1)', function test( t ) { +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( value, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, value, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, value, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fourth argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, value, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { + var values; + var i; + + values = [ + 1, + 0, + -1, + -2 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), value, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid ninth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), value, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid twelfth argument', function test( t ) { + var values; + var i; + + values = [ + 0 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, new Float32Array( rxpyp.a ), rxpyp.lda, new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), value ); + }; + } +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyp.N; - lda = stridexpyp.lda; - k = stridexpyp.k; + expected = new Float32Array( rxpyp.y_out ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - a = new Float32Array( stridexpyp.A ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + a = new Float32Array( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); - expected = new Float32Array( stridexpyp.y_out ); + expected = new Float32Array( cxpyp.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + out = ssbmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.k, cxpyp.alpha, a, cxpyp.lda, x, cxpyp.strideX, cxpyp.beta, y, cxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=2)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxoyt.A ); + x = new Float32Array( rxoyt.x ); + y = new Float32Array( rxoyt.y ); + + expected = new Float32Array( rxoyt.y_out ); + + out = ssbmv( rxoyt.order, rxoyt.uplo, rxoyt.N, rxoyt.k, rxoyt.alpha, a, rxoyt.lda, x, rxoyt.strideX, rxoyt.beta, y, rxoyt.strideY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals (sx=1, sy=2)', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=2)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexoyt.order; - uplo = stridexoyt.uplo; + a = new Float32Array( cxoyt.A ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); + + expected = new Float32Array( cxoyt.y_out ); - n = stridexoyt.N; - lda = stridexoyt.lda; - k = stridexpyp.k; + out = ssbmv( cxoyt.order, cxoyt.uplo, cxoyt.N, cxoyt.k, cxoyt.alpha, a, cxoyt.lda, x, cxoyt.strideX, cxoyt.beta, y, cxoyt.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - strideX = stridexoyt.strideX; - strideY = stridexoyt.strideY; + t.end(); +}); - alpha = stridexoyt.alpha; - beta = stridexoyt.beta; +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - a = new Float32Array( stridexoyt.A ); - x = new Float32Array( stridexoyt.x ); - y = new Float32Array( stridexoyt.y ); + a = new Float32Array( rxpyn.A ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); - expected = new Float32Array( stridexoyt.y_out ); + expected = new Float32Array( rxpyn.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + out = ssbmv( rxpyn.order, rxpyn.uplo, rxpyn.N, rxpyn.k, rxpyn.alpha, a, rxpyn.lda, x, rxpyn.strideX, rxpyn.beta, y, rxpyn.strideY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxpyn.A ); + x = new Float32Array( cxpyn.x ); + y = new Float32Array( cxpyn.y ); + + expected = new Float32Array( cxpyn.y_out ); + + out = ssbmv( cxpyn.order, cxpyn.uplo, cxpyn.N, cxpyn.k, cxpyn.alpha, a, cxpyn.lda, x, cxpyn.strideX, cxpyn.beta, y, cxpyn.strideY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function a negative `x` stride', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (row-major, sx=-1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexnyp.order; - uplo = stridexnyp.uplo; + a = new Float32Array( rxnyp.A ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); - n = stridexnyp.N; - lda = stridexnyp.lda; - k = stridexnyp.k; + expected = new Float32Array( rxnyp.y_out ); - strideX = stridexnyp.strideX; - strideY = stridexnyp.strideY; + out = ssbmv( rxnyp.order, rxnyp.uplo, rxnyp.N, rxnyp.k, rxnyp.alpha, a, rxnyp.lda, x, rxnyp.strideX, rxnyp.beta, y, rxnyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexnyp.alpha; - beta = stridexnyp.beta; + t.end(); +}); - a = new Float32Array( stridexnyp.A ); - x = new Float32Array( stridexnyp.x ); - y = new Float32Array( stridexnyp.y ); +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals (column-major, sx=-1, sy=1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxnyp.A ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); - expected = new Float32Array( stridexnyp.y_out ); + expected = new Float32Array( cxnyp.y_out ); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len + out = ssbmv( cxnyp.order, cxnyp.uplo, cxnyp.N, cxnyp.k, cxnyp.alpha, a, cxnyp.lda, x, cxnyp.strideX, cxnyp.beta, y, cxnyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the second input vector', function test( t ) { + var out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); -tape( 'the function supports a negative `y` stride', function test( t ) { +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (row-major)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexpyn.order; - uplo = stridexpyn.uplo; + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyn.N; - lda = stridexpyn.lda; - k = stridexpyn.k; + expected = new Float32Array( rxpyp.y ); - strideX = stridexpyn.strideX; - strideY = stridexpyn.strideY; + out = ssbmv( rxpyp.order, rxpyp.uplo, 0, rxpyp.k, rxpyp.alpha, a, rxpyp.lda, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyn.alpha; - beta = stridexpyn.beta; + out = ssbmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.k, 0.0, a, rxpyp.lda, x, rxpyp.strideX, 1.0, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - a = new Float32Array( stridexpyn.A ); - x = new Float32Array( stridexpyn.x ); - y = new Float32Array( stridexpyn.y ); + t.end(); +}); - expected = new Float32Array( stridexpyn.y_out ); +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len - isApprox( t, y, expected, 2.0 ); + a = new Float32Array( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y ); + + out = ssbmv( cxpyp.order, cxpyp.uplo, 0, cxpyp.k, cxpyp.alpha, a, cxpyp.lda, x, cxpyp.strideX, cxpyp.beta, y, cxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + out = ssbmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.k, 0.0, a, cxpyp.lda, x, cxpyp.strideX, 1.0, y, cxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'when `α` is zero, the function scales the second input vector (row-major, upper)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = ssbmv( 'row-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 5.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = ssbmv( 'row-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0.0, y, -1 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function returns a reference to the second input array', function test( t ) { - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; +tape( 'when `α` is zero, the function scales the second input vector (row-major, lower)', function test( t ) { + var expected; var out; var a; - var k; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexpyp.N; - lda = stridexpyp.lda; - k = stridexpyp.k; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = ssbmv( 'row-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 5.0, y, -1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - a = new Float32Array( stridexpyp.A ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + out = ssbmv( 'row-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len +tape( 'when `α` is zero, the function scales the second input vector (column-major, upper)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = ssbmv( 'column-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 5.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = ssbmv( 'column-major', 'upper', 3, 1, 0.0, a, 3, x, 1, 0.0, y, -1 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { +tape( 'when `α` is zero, the function scales the second input vector (column-major, lower)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; - var lda; var out; var a; - var k; - var n; var x; var y; - order = stridexnyn.order; - uplo = stridexnyn.uplo; + a = ones( 9, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexnyn.N; - lda = stridexnyn.lda; - k = stridexnyn.k; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexnyn.strideX; - strideY = stridexnyn.strideY; + out = ssbmv( 'column-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 5.0, y, -1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexnyn.alpha; - beta = stridexnyn.beta; + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - a = new Float32Array( stridexnyn.A ); - x = new Float32Array( stridexnyn.x ); - y = new Float32Array( stridexnyn.y ); + out = ssbmv( 'column-major', 'lower', 3, 1, 0.0, a, 3, x, 1, 0.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - expected = new Float32Array( stridexnyn.y_out ); + t.end(); +}); - out = ssbmv( order, uplo, n, k, alpha, a, lda, x, strideX, beta, y, strideY ); // eslint-disable-line max-len +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxnyn.A ); + x = new Float32Array( rxnyn.x ); + y = new Float32Array( rxnyn.y ); + + expected = new Float32Array( rxnyn.y_out ); + + out = ssbmv( rxnyn.order, rxnyn.uplo, rxnyn.N, rxnyn.k, rxnyn.alpha, a, rxnyn.lda, x, rxnyn.strideX, rxnyn.beta, y, rxnyn.strideY ); + t.strictEqual( out, y, 'returns expected value' ); isApprox( t, y, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( cxnyn.A ); + x = new Float32Array( cxnyn.x ); + y = new Float32Array( cxnyn.y ); + + expected = new Float32Array( cxnyn.y_out ); + + out = ssbmv( cxnyn.order, cxnyn.uplo, cxnyn.N, cxnyn.k, cxnyn.alpha, a, cxnyn.lda, x, cxnyn.strideX, cxnyn.beta, y, cxnyn.strideY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); From 4bb90a8541ad9d1d2bce025cb473707fd7938eee Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 11:53:05 +0530 Subject: [PATCH 04/19] docs: update comments --- lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js | 2 ++ lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js index d4dd0aa8c94c..1f96bf24ed94 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js index 94709881be3c..d07fafea229b 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // From 62ae20f74af45f4b2b69c0a6d4158b0f6bb5dc2e Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 12:10:31 +0530 Subject: [PATCH 05/19] docs: update descriptions --- .../@stdlib/blas/base/ssbmv/docs/repl.txt | 36 +++++++++++-------- .../blas/base/ssbmv/docs/types/index.d.ts | 36 ++++++++----------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index 2a76ae4c731c..a3b4967d6964 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -1,8 +1,8 @@ {{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) Perform one of the matrix-vector operations `y = α*A*x + β*y` - where α and β are scalars, x and y are n element vectors and A is - an n by n symmetric matrix, with k super-diagonals. + where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A is + an `N` by `N` symmetric matrix, with `k` super-diagonals. The stride parameters determine how operations are performed. @@ -17,13 +17,15 @@ Parameters ---------- ord: string - Row-major (C-style) or column-major (Fortran-style) order. + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. uplo: string - Specifies whether `A` is upper or lower triangular matrix. + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. N: integer - Specifies the order of the matrix `A`. + Number of elements along each dimension of `A`. k: integer Specifies the number of super-diagonals. @@ -35,7 +37,8 @@ Matrix. lda: integer - Leading dimension. + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). x: Float32Array Input vector `x`. @@ -47,7 +50,7 @@ Scalar constant. y: Float32Array - Input/output vector `y`. + Output vector `y`. sy: integer Index increment for `y`. @@ -86,8 +89,8 @@ {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) Perform one of the matrix-vector operations `y = α*A*x + β*y` - where α and β are scalars, x and y are n element vectors and A is - an n by n symmetric matrix, with k super-diagonals using alternative + where `α` and `β` are scalars, x and y are `N` element vectors, and `A` is + an `N` by `N` symmetric matrix, with `k` super-diagonals using alternative indexing semantics. While typed array views mandate a view offset based on the underlying @@ -97,25 +100,28 @@ Parameters ---------- ord: string - Row-major (C-style) or column-major (Fortran-style) order. + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. uplo: string - Specifies whether `A` is upper or lower triangular matrix. + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. N: integer - Specifies the order of the matrix `A`. + Number of elements along each dimension of `A`. k: integer Specifies the number of super-diagonals. α: number - Scalar. + Scalar constant. A: Float32Array Matrix. lda: integer - Leading dimension. + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). x: Float32Array Input vector `x`. @@ -130,7 +136,7 @@ Scalar. y: Float32Array - Input/output vector `y`. + Output vector `y`. sy: integer Index increment for `y`. diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts index b384f5d23a9c..94f4ea762740 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -18,15 +18,9 @@ // TypeScript Version: 4.1 -/** -* Storage layouts. -*/ -type Order = 'row-major' | 'column-major'; +/// -/** -* Upper or lower triangular indicator. -*/ -type UPLO = 'upper' | 'lower'; +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; /** * Interface describing `ssbmv`. @@ -37,15 +31,15 @@ interface Routine { * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied - * @param N - number of columns in the matrix `A` + * @param N - number of elements along each dimension in the matrix `A` * @param k - 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 x - first input array * @param strideX - `x` stride length * @param beta - scalar constant - * @param y - an `N` element vector + * @param y - second input array * @param strideY - `y` stride length * @returns output array `y` * @@ -59,25 +53,25 @@ interface Routine { * ssbmv( 'row-major, 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); * // y => [ ~0.2, ~1.7, ~0.9 ] */ - ( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + ( order: Layout, uplo: MatrixTriangle, N: number, k: 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` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals using alternative indexing semantics. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied - * @param N - number of columns in the matrix `A` + * @param N - number of elements along each dimension in the matrix `A` * @param k - 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 x - first input array * @param strideX - `x` stride length - * @param offsetX - `x` index offset + * @param offsetX - starting `x` index * @param beta - scalar constant - * @param y - an `N` element vector + * @param y - second input array * @param strideY - `y` stride length - * @param offsetY - `y` index offset + * @param offsetY - starting `y` index * @returns output array `y` * * @example @@ -90,7 +84,7 @@ interface Routine { * ssbmv.ndarray( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); * // y => [ ~0.2, ~1.7, ~0.9 ] */ - ndarray( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; + ndarray( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; } /** @@ -98,15 +92,15 @@ interface Routine { * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied -* @param N - number of columns in the matrix `A` +* @param N - number of elements along each dimension in the matrix `A` * @param k - 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 x - first input array * @param strideX - `x` stride length * @param beta - scalar constant -* @param y - an `N` element vector +* @param y - second input array * @param strideY - `y` stride length * @returns output array `y` * From f1089d8f975d68edf98e8abbb97043f3c64fe962 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 12:14:06 +0530 Subject: [PATCH 06/19] docs: update descriptions --- lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt | 4 ++-- .../@stdlib/blas/base/ssbmv/docs/types/index.d.ts | 6 +++--- lib/node_modules/@stdlib/blas/base/ssbmv/package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index a3b4967d6964..836c5d15e8f0 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -1,6 +1,6 @@ {{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) - Perform one of the matrix-vector operations `y = α*A*x + β*y` + Perform the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A is an `N` by `N` symmetric matrix, with `k` super-diagonals. @@ -88,7 +88,7 @@ {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) - Perform one of the matrix-vector operations `y = α*A*x + β*y` + Perform the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, x and y are `N` element vectors, and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals using alternative indexing semantics. diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts index 94f4ea762740..c97cac1e1ebb 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. + * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -56,7 +56,7 @@ interface Routine { ( order: Layout, uplo: MatrixTriangle, N: number, k: 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` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals using alternative indexing semantics. + * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals using alternative indexing semantics. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -88,7 +88,7 @@ interface Routine { } /** -* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/package.json b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json index 77914f76d045..dd62748a88d0 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/package.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ssbmv", "version": "0.0.0", - "description": "Perform one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric band matrix, with k super-diagonals.", + "description": "Perform the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From dd9fa1efee720262cf64464058fafbd659f757b0 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 12:23:37 +0530 Subject: [PATCH 07/19] docs: update README --- .../@stdlib/blas/base/ssbmv/README.md | 19 +++++++++---------- .../@stdlib/blas/base/ssbmv/docs/repl.txt | 8 ++++---- .../blas/base/ssbmv/docs/types/index.d.ts | 12 ++++++------ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/README.md b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md index e2ddcd26ce14..6bb2753b478b 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md @@ -20,7 +20,7 @@ limitations under the License. # ssbmv -> Perform one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. +> Perform the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals.
@@ -32,7 +32,7 @@ var ssbmv = require( '@stdlib/blas/base/ssbmv' ); #### ssbmv( ord, uplo, N, k, α, A, LDA, x, sx, β, y, sy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals. +Performs the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -48,20 +48,19 @@ ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); The function has the following parameters: - **ord**: storage layout. -- **uplo**: specifies the operation to be performed. -- **N**: specifies the order of the matrix `A`. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric band matrix `A` should be referenced. +- **N**: number of elements along each dimension of `A`. - **k**: number of super-diagonals. - **α**: scalar constant. -- **A**: matrix of coefficients [`Float32Array`][mdn-float32array]. -- **lda**: stride of the first dimension of `A` (leading dimension of `A`). +- **A**: input matrix stored in linear memory as [`Float32Array`][mdn-float32array]. +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: input [`Float32Array`][mdn-float32array]. - **sx**: index increment for `x`. - **β**: scalar constant. - **y**: output [`Float32Array`][mdn-float32array]. - **sy**: index increment for `y`. -The stride parameters determine how operations are performed. For example, to -perform one of the matrix-vector operations starting from the second index of `x`, +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x` in reverse order, ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -96,7 +95,7 @@ ssbmv( 'row-major', 'upper', 3, 1, 1.0, A, 3, x1, -1, 1.0, y1, -1 ); #### ssbmv.ndarray( ord, uplo, N, k, α, A, LDA, x, sx, ox, β, y, sy, oy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, with k super-diagonals using alternative indexing semantics. +Performs the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals using alternative indexing semantics. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -114,7 +113,7 @@ 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`,..., +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, ```javascript var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index 836c5d15e8f0..a23837773f34 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -1,8 +1,8 @@ {{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) Perform the matrix-vector operations `y = α*A*x + β*y` - where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A is - an `N` by `N` symmetric matrix, with `k` super-diagonals. + where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A + is an `N` by `N` symmetric band matrix, with `k` super-diagonals. The stride parameters determine how operations are performed. @@ -90,8 +90,8 @@ {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) Perform the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, x and y are `N` element vectors, and `A` is - an `N` by `N` symmetric matrix, with `k` super-diagonals using alternative - indexing semantics. + an `N` by `N` symmetric band matrix, with `k` 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 diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts index c97cac1e1ebb..1f4ce2dbc9e6 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -27,10 +27,10 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals. + * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. * * @param order - storage layout - * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant @@ -56,10 +56,10 @@ interface Routine { ( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** - * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals using alternative indexing semantics. + * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals using alternative indexing semantics. * * @param order - storage layout - * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant @@ -88,10 +88,10 @@ interface Routine { } /** -* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric matrix, with `k` super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. * * @param order - storage layout -* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied +* @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant From 2e92bc60877865953040f5b79bcf93f7febb8221 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 12:44:45 +0530 Subject: [PATCH 08/19] chore: resolve lint error --- lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index a23837773f34..9adc5249c240 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -76,16 +76,6 @@ > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x, -1, 1.0, y, -1 ) [ ~6.0, ~4.0 ] - // Using typed array views: - > var x0 = new {{alias:@stdlib/array/float32}}( [ 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, 0.0, 3.0 ] ); - > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); - > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); - > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x1, 1, 1.0, y1, 1 ) - > y0 - [ ~4.0, ~3.0 ] - {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) Perform the matrix-vector operations `y = α*A*x + β*y` From 6c640f7f1dcf4f1c828bffc49e6788ee8a05b86a Mon Sep 17 00:00:00 2001 From: aman-095 Date: Mon, 24 Jun 2024 12:52:51 +0530 Subject: [PATCH 09/19] docs: add example for offset --- lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index 9adc5249c240..bde2c0736875 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -76,6 +76,16 @@ > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x, -1, 1.0, y, -1 ) [ ~6.0, ~4.0 ] + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 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, 0.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); + > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x1, 1, 1.0, y1, 1 ); + > y0 + [ ~4.0, ~3.0 ] + {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) Perform the matrix-vector operations `y = α*A*x + β*y` From 916c29574373168acbbe695dd065644eb060c9ae Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 19:46:03 -0700 Subject: [PATCH 10/19] fix: update error handling and make style changes to clarify operations --- .../@stdlib/blas/base/ssbmv/lib/index.js | 2 +- .../@stdlib/blas/base/ssbmv/lib/ndarray.js | 43 ++++++------- .../@stdlib/blas/base/ssbmv/lib/ssbmv.js | 61 ++++++++++--------- 3 files changed, 54 insertions(+), 52 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js index 9252c21e519e..157c7a466261 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @module @stdlib/blas/base/ssbmv * diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js index 6c614ef0b72d..da68ee899878 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -27,12 +27,13 @@ var min = require( '@stdlib/math/base/special/min' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); // MAIN // /** -* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -49,10 +50,10 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting `y` index * @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} seventh argument must be greater than ( k + 1 ) +* @throws {RangeError} seventh argument must be greater than `k+1` * @throws {RangeError} ninth argument must be non-zero * @throws {RangeError} thirteenth argument must be non-zero * @returns {Float32Array} `y` @@ -82,31 +83,29 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, var l; if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( !isMatrixTriangle( uplo ) ) { - throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); } if ( N < 0 ) { - throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( k < 0 ) { - throw new RangeError( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ); + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ) ); } - if ( LDA < ( k + 1 ) ) { - throw new RangeError( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ); + if ( LDA < k+1 ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ) ); } if ( strideX === 0 ) { - throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ); + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( strideY === 0 ) { - throw new RangeError( 'invalid argument. Thirteenth argument must be non-zero. Value: `%d`.', strideY ); + throw new RangeError( format( 'invalid argument. Thirteenth argument must be non-zero. Value: `%d`.', strideY ) ); } if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { return y; } - kx = offsetX; - ky = offsetY; if ( beta !== 1.0 ) { if ( beta === 0.0 ) { sfill( N, 0.0, y, strideY, offsetY ); @@ -117,6 +116,8 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, if ( alpha === 0.0 ) { return y; } + kx = offsetX; + ky = offsetY; if ( ( order === 'column-major' && uplo === 'upper' ) || ( order === 'row-major' && uplo === 'lower' ) @@ -130,13 +131,13 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, ix = kx; iy = ky; l = kplus1 - j; - for ( i = max( 0, ( j - k ) ); i < j; i++ ) { - y[ iy ] += f32( temp1 * A[ ( l + i ) + ( j * LDA ) ] ); - temp2 += f32( A[ ( l + i ) + ( j * LDA ) ] * x[ ix ] ); + for ( i = max( 0, j-k ); i < j; i++ ) { + y[ iy ] += f32( temp1 * A[ (l+i)+(j*LDA) ] ); + temp2 = f32( temp2 + f32( A[ (l+i)+(j*LDA) ] * x[ ix ] ) ); ix += strideX; iy += strideY; } - y[ jy ] += f32( f32( temp1 * A[ kplus1 + ( LDA * j ) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len + y[ jy ] += f32( f32( temp1 * A[ kplus1+(LDA*j) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len jx += strideX; jy += strideY; if ( j >= k ) { @@ -153,14 +154,14 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, temp1 = f32( alpha * x[ jx ] ); temp2 = 0.0; y[ jy ] += f32( temp1 * A[ LDA * j ] ); - l = ( -j ); + l = -j; ix = jx; iy = jy; - for ( i = j + 1; i < min( N, ( j + k + 1 ) ); i++ ) { + for ( i = j+1; i < min( N, j+k+1 ); i++ ) { ix += strideX; iy += strideY; - y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); - temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); + y[ iy ] += f32( temp1 * A[ (j*LDA)+(l+i) ] ); + temp2 = f32( temp2 + f32( A[ (j*LDA)+(l+i) ] * x[ ix ] ) ); } y[ jy ] += f32( alpha * temp2 ); jx += strideX; diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js index 32f6689474a9..5ff41ba0294f 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -27,12 +27,13 @@ var min = require( '@stdlib/math/base/special/min' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); // MAIN // /** -* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -47,10 +48,10 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} fourth argument must be a nonnegative integer -* @throws {RangeError} seventh argument must be greater than ( k + 1 ) +* @throws {RangeError} seventh argument must be greater than `k + 1` * @throws {RangeError} ninth argument must be non-zero * @throws {RangeError} twelfth argument must be non-zero * @returns {Float32Array} `y` @@ -81,39 +82,29 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) var l; if ( !isLayout( order ) ) { - throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( !isMatrixTriangle( uplo ) ) { - throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); } if ( N < 0 ) { - throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); } if ( k < 0 ) { - throw new RangeError( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ); + throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ) ); } - if ( LDA < ( k + 1 ) ) { - throw new RangeError( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ); + if ( LDA < k+1 ) { + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ) ); } if ( strideX === 0 ) { - throw new RangeError( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ); + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( strideY === 0 ) { - throw new RangeError( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ); + throw new RangeError( format( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ) ); } if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { return y; } - if ( strideX > 0 ) { - kx = 0; - } else { - kx = ( 1 - N ) * strideX; - } - if ( strideY > 0 ) { - ky = 0; - } else { - ky = ( 1 - N ) * strideY; - } sy = strideY; if ( beta !== 1.0 ) { if ( beta === 0.0 ) { @@ -128,6 +119,16 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) if ( alpha === 0.0 ) { return y; } + if ( strideX > 0 ) { + kx = 0; + } else { + kx = ( 1 - N ) * strideX; + } + if ( strideY > 0 ) { + ky = 0; + } else { + ky = ( 1 - N ) * strideY; + } if ( ( order === 'column-major' && uplo === 'upper' ) || ( order === 'row-major' && uplo === 'lower' ) @@ -141,13 +142,13 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) ix = kx; iy = ky; l = kplus1 - j; - for ( i = max( 0, ( j - k ) ); i < j; i++ ) { - y[ iy ] += f32( temp1 * A[ ( l + i ) + ( j * LDA ) ] ); - temp2 += f32( A[ ( l + i ) + ( j * LDA ) ] * x[ ix ] ); + for ( i = max( 0, j-k ); i < j; i++ ) { + y[ iy ] += f32( temp1 * A[ (l+i)+(j*LDA) ] ); + temp2 = f32( temp2 + f32( A[ (l+i)+(j*LDA) ] * x[ ix ] ) ); ix += strideX; iy += strideY; } - y[ jy ] += f32( f32( temp1 * A[ kplus1 + ( LDA * j ) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len + y[ jy ] += f32( f32( temp1 * A[ kplus1+(LDA*j) ] ) + f32( alpha * temp2 ) ); // eslint-disable-line max-len jx += strideX; jy += strideY; if ( j >= k ) { @@ -163,15 +164,15 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) for ( j = 0; j < N; j++ ) { temp1 = f32( alpha * x[ jx ] ); temp2 = 0.0; - y[ jy ] += f32( temp1 * A[ LDA * j ] ); - l = ( -j ); + y[ jy ] += f32( temp1 * A[ LDA*j ] ); + l = -j; ix = jx; iy = jy; - for ( i = j + 1; i < min( N, ( j + k + 1 ) ); i++ ) { + for ( i = j+1; i < min( N, j+k+1 ); i++ ) { ix += strideX; iy += strideY; - y[ iy ] += f32( temp1 * A[ ( j * LDA ) + ( l + i ) ] ); - temp2 += f32( A[ ( j * LDA ) + ( l + i ) ] * x[ ix ] ); + y[ iy ] += f32( temp1 * A[ (j*LDA)+(l+i) ] ); + temp2 = f32( temp2 + f32( A[ (j*LDA)+(l+i) ] * x[ ix ] ) ); } y[ jy ] += f32( alpha * temp2 ); jx += strideX; From 5011e86cc3064252097de470cc6a3a6d56d47200 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 19:50:02 -0700 Subject: [PATCH 11/19] bench: update to ensure symmetric matrix --- .../@stdlib/blas/base/ssbmv/benchmark/benchmark.js | 3 ++- .../@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js index fd321387cc38..eba8ed049269 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var ones = require( '@stdlib/array/ones' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); @@ -48,7 +49,7 @@ var options = { 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 ); + var A = ones( len*len, options.dtype ); return benchmark; /** diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js index 9d60037e7c1b..028c9acb3064 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js @@ -22,6 +22,7 @@ var bench = require( '@stdlib/bench' ); var uniform = require( '@stdlib/random/array/uniform' ); +var ones = require( '@stdlib/array/ones' ); var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pow = require( '@stdlib/math/base/special/pow' ); var floor = require( '@stdlib/math/base/special/floor' ); @@ -48,7 +49,7 @@ var options = { 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 ); + var A = ones( len*len, options.dtype ); return benchmark; /** From d897b4cc8e0e0001c468dfcb164b8bba2f881571 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 19:54:11 -0700 Subject: [PATCH 12/19] docs: update descriptions --- .../blas/base/ssbmv/docs/types/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts index 1f4ce2dbc9e6..5598dd52352e 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -27,21 +27,21 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant - * @param A - matrix of coefficients + * @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - first input array * @param strideX - `x` stride length * @param beta - scalar constant * @param y - second input array * @param strideY - `y` stride length - * @returns output array `y` + * @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -56,14 +56,14 @@ interface Routine { ( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** - * Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals using alternative indexing semantics. + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant - * @param A - matrix of coefficients + * @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - first input array * @param strideX - `x` stride length @@ -72,7 +72,7 @@ interface Routine { * @param y - second input array * @param strideY - `y` stride length * @param offsetY - starting `y` index - * @returns output array `y` + * @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -88,21 +88,21 @@ interface Routine { } /** -* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` * @param k - number of super-diagonals * @param alpha - scalar constant -* @param A - matrix of coefficients +* @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param x - first input array * @param strideX - `x` stride length * @param beta - scalar constant * @param y - second input array * @param strideY - `y` stride length -* @returns output array `y` +* @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); From 26acfd968646b4ec49b458fa6cad1ac829439137 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 22:15:01 -0700 Subject: [PATCH 13/19] test: fix grammar --- .../@stdlib/blas/base/ssbmv/docs/types/test.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts index 9b5942a5366f..7ecca2fe5439 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/test.ts @@ -46,7 +46,7 @@ import ssbmv = require( './index' ); ssbmv( ( x: number ): number => x, 'upper', 10, 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... +// The compiler throws an error if the function is provided a second argument which is not a string... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -110,7 +110,7 @@ import ssbmv = require( './index' ); ssbmv( 'row-major', 'upper', 10, 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 fsixth argument which is not a Float32Array... +// The compiler throws an error if the function is provided a sixth argument which is not a Float32Array... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -142,7 +142,7 @@ import ssbmv = require( './index' ); ssbmv( 'row-major', 'upper', 10, 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 eighth argument which is not a Float32Array... +// The compiler throws an error if the function is provided an eighth argument which is not a Float32Array... { const y = new Float32Array( 10 ); const A = new Float32Array( 20 ); @@ -190,7 +190,7 @@ import ssbmv = require( './index' ); ssbmv( 'row-major', 'upper', 10, 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 eleventh argument which is not a Float32Array... +// The compiler throws an error if the function is provided an eleventh argument which is not a Float32Array... { const x = new Float32Array( 10 ); const A = new Float32Array( 20 ); @@ -268,7 +268,7 @@ import ssbmv = require( './index' ); ssbmv.ndarray( ( x: number ): number => x, 'upper', 10, 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... +// The compiler throws an error if the function is provided a second argument which is not a string... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -364,7 +364,7 @@ import ssbmv = require( './index' ); ssbmv.ndarray( 'row-major', 'upper', 10, 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 eighth argument which is not a Float32Array... +// The compiler throws an error if the function is provided an eighth argument which is not a Float32Array... { const y = new Float32Array( 10 ); const A = new Float32Array( 20 ); @@ -412,7 +412,7 @@ import ssbmv = require( './index' ); ssbmv.ndarray( 'row-major', 'upper', 10, 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 eleventh argument which is not a number... +// The compiler throws an error if the function is provided an eleventh argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); From b45b96ffc41600230c17f84d49a35bcb27868706 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:23:27 -0700 Subject: [PATCH 14/19] docs: update descriptions --- .../@stdlib/blas/base/ssbmv/docs/repl.txt | 64 +++++++++---------- .../blas/base/ssbmv/docs/types/index.d.ts | 12 ++-- .../@stdlib/blas/base/ssbmv/lib/ndarray.js | 6 +- .../@stdlib/blas/base/ssbmv/lib/ssbmv.js | 6 +- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt index bde2c0736875..99a0123a619d 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -1,18 +1,18 @@ {{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) - Perform the matrix-vector operations `y = α*A*x + β*y` - where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A - is an `N` by `N` symmetric band matrix, with `k` super-diagonals. + Perform the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are + scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` + symmetric band matrix with `k` super-/sub-diagonals. - The stride parameters determine how operations are performed. + The stride parameters determine how elements in the strided arrays are + accessed at runtime. Indexing is relative to the first index. To introduce an offset, use typed array views. If `N` is equal to `0`, the function returns `y` unchanged. - If `α` equals `0.0` and β equals `1.0`, the function returns `y` - unchanged. + If `α` equals `0.0` and β equals `1.0`, the function returns `y` unchanged. Parameters ---------- @@ -21,27 +21,27 @@ either 'row-major' or 'column-major'. uplo: string - Specifies whether to reference the upper or lower triangular part of - `A`. Must be either 'upper' or 'lower'. + Specifies whether the upper or lower triangular part of `A` is provided. + Must be either 'upper' or 'lower'. N: integer Number of elements along each dimension of `A`. k: integer - Specifies the number of super-diagonals. + Specifies the number of super-/sub-diagonals. α: number Scalar constant. A: Float32Array - Matrix. + Symmetric band matrix stored in band storage. lda: integer Stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). x: Float32Array - Input vector `x`. + Input vector. sx: integer Index increment for `x`. @@ -50,7 +50,7 @@ Scalar constant. y: Float32Array - Output vector `y`. + Output vector . sy: integer Index increment for `y`. @@ -58,7 +58,7 @@ Returns ------- y: Float32Array - Output array. + Output vector. Examples -------- @@ -70,16 +70,16 @@ [ ~4.0, ~6.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 ] ); + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x, -1, 1.0, y, -1 ) [ ~6.0, ~4.0 ] // Using typed array views: > var x0 = new {{alias:@stdlib/array/float32}}( [ 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, 0.0, 3.0 ] ); + > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 3.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); > {{alias}}( 'row-major', 'upper', 2, 1, 1.0, A, 2, x1, 1, 1.0, y1, 1 ); @@ -88,10 +88,10 @@ {{alias}}.ndarray( ord, uplo, N, k, α, A, lda, x, sx, ox, β, y, sy, oy ) - Perform the matrix-vector operations `y = α*A*x + β*y` - where `α` and `β` are scalars, x and y are `N` element vectors, and `A` is - an `N` by `N` symmetric band matrix, with `k` super-diagonals using - alternative indexing semantics. + Perform the matrix-vector operations `y = α*A*x + β*y` using alternative + indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` + element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` + super-/sub-diagonals. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting @@ -104,27 +104,27 @@ either 'row-major' or 'column-major'. uplo: string - Specifies whether to reference the upper or lower triangular part of - `A`. Must be either 'upper' or 'lower'. + Specifies whether the upper or lower triangular part of `A` is supplied. + Must be either 'upper' or 'lower'. N: integer Number of elements along each dimension of `A`. k: integer - Specifies the number of super-diagonals. + Specifies the number of super-/sub-diagonals. α: number Scalar constant. A: Float32Array - Matrix. + Symmetric band matrix stored in band storage. lda: integer Stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). x: Float32Array - Input vector `x`. + Input vector. sx: integer Index increment for `x`. @@ -136,7 +136,7 @@ Scalar. y: Float32Array - Output vector `y`. + Output vector. sy: integer Index increment for `y`. @@ -147,7 +147,7 @@ Returns ------- y: Float32Array - Output array. + Output vector. Examples -------- @@ -161,11 +161,9 @@ [ ~4.0, ~6.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 ord = 'row-major'; - > var uplo = 'upper'; + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > {{alias}}.ndarray( ord, uplo, 2, 1, 1.0, A, 2, x, -1, 1, 1.0, y, -1, 1 ) [ ~6.0, ~4.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts index 5598dd52352e..704c49312410 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -27,12 +27,12 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` - * @param k - number of super-diagonals + * @param k - number of super-/sub-diagonals * @param alpha - scalar constant * @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) @@ -56,12 +56,12 @@ interface Routine { ( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** - * Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` - * @param k - number of super-diagonals + * @param k - number of super-/sub-diagonals * @param alpha - scalar constant * @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) @@ -88,12 +88,12 @@ interface Routine { } /** -* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* Performs the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric band matrix `A` is being supplied * @param N - number of elements along each dimension in the matrix `A` -* @param k - number of super-diagonals +* @param k - number of super-/sub-diagonals * @param alpha - scalar constant * @param A - symmetric band matrix stored in band storage * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js index da68ee899878..aa4ddc566885 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -33,14 +33,14 @@ var format = require( '@stdlib/string/format' ); // MAIN // /** -* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {NonNegativeInteger} k - number of super-diagonals +* @param {NonNegativeInteger} k - number of super-/sub-diagonals * @param {number} alpha - scalar constant -* @param {Float32Array} A - matrix +* @param {Float32Array} A - symmetric band matrix stored in band storage * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js index 5ff41ba0294f..103b0f4164b0 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -33,14 +33,14 @@ var format = require( '@stdlib/string/format' ); // MAIN // /** -* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` -* @param {NonNegativeInteger} k - number of super-diagonals +* @param {NonNegativeInteger} k - number of super-/sub-diagonals * @param {number} alpha - scalar constant -* @param {Float32Array} A - matrix +* @param {Float32Array} A - symmetric band matrix stored in band storage * @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length From be8ff22eb057fb00eec01744f7e874e504fedf36 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:23:56 -0700 Subject: [PATCH 15/19] docs: re-enable lint rules --- lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js index 6a7cb444e185..16921bbe55b0 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.js @@ -16,8 +16,6 @@ * limitations under the License. */ -/* eslint-disable */ // FIXME - 'use strict'; var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); From 06dfbb2b56c9fae5f983b8f198d0bbed2c4666e2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:24:27 -0700 Subject: [PATCH 16/19] docs: update description --- lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js index 157c7a466261..04dab33578cb 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-diagonals. +* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. * * @module @stdlib/blas/base/ssbmv * From e22b003dfc133b31689fd68f59b18d3d0c5b750e Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:25:17 -0700 Subject: [PATCH 17/19] docs: update description --- lib/node_modules/@stdlib/blas/base/ssbmv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/package.json b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json index dd62748a88d0..687061e32937 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/package.json +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ssbmv", "version": "0.0.0", - "description": "Perform the matrix-vector operations `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals.", + "description": "Perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 90e63cd02987c4e888a9cf3a45f76b07ac3fc32f Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:28:37 -0700 Subject: [PATCH 18/19] docs: update descriptions --- lib/node_modules/@stdlib/blas/base/ssbmv/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/README.md b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md index 6bb2753b478b..42bffaa03214 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md @@ -20,7 +20,7 @@ limitations under the License. # ssbmv -> Perform the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. +> Perform the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals.
@@ -32,7 +32,7 @@ var ssbmv = require( '@stdlib/blas/base/ssbmv' ); #### ssbmv( ord, uplo, N, k, α, A, LDA, x, sx, β, y, sy ) -Performs the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals. +Performs the matrix-vector operation `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -48,11 +48,11 @@ ssbmv( 'row-major', 'lower', 3, 1, 1.0, A, 3, x, 1, 0.0, y, 1 ); The function has the following parameters: - **ord**: storage layout. -- **uplo**: specifies whether the upper or lower triangular part of the symmetric band matrix `A` should be referenced. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric band matrix `A` is supplied. - **N**: number of elements along each dimension of `A`. -- **k**: number of super-diagonals. +- **k**: number of super-/sub-diagonals. - **α**: scalar constant. -- **A**: input matrix stored in linear memory as [`Float32Array`][mdn-float32array]. +- **A**: symmetric band matrix stored in band storage in linear memory as a [`Float32Array`][mdn-float32array]. - **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). - **x**: input [`Float32Array`][mdn-float32array]. - **sx**: index increment for `x`. @@ -95,7 +95,7 @@ ssbmv( 'row-major', 'upper', 3, 1, 1.0, A, 3, x1, -1, 1.0, y1, -1 ); #### ssbmv.ndarray( ord, uplo, N, k, α, A, LDA, x, sx, ox, β, y, sy, oy ) -Performs the matrix-vector operations `y = α*A*x + β*y` where `α` and `β` are scalars, `x` and `y` are `N` element vectors and `A` is an `N` by `N` symmetric band matrix, with `k` super-diagonals using alternative indexing semantics. +Performs the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric band matrix with `k` super-/sub-diagonals. ```javascript var Float32Array = require( '@stdlib/array/float32' ); From 5ce5259427de3e2de18c5287554de0f8b645508c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 24 Jun 2024 23:34:30 -0700 Subject: [PATCH 19/19] fix: update error messages --- lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js | 2 +- lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js index aa4ddc566885..81e41b97d92f 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ndarray.js @@ -95,7 +95,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, offsetX, beta, y, throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ) ); } if ( LDA < k+1 ) { - throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ) ); + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to %d. Value: `%d`.', k+1, LDA ) ); } if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js index 103b0f4164b0..d04a945ad37e 100644 --- a/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -94,7 +94,7 @@ function ssbmv( order, uplo, N, k, alpha, A, LDA, x, strideX, beta, y, strideY ) throw new RangeError( format( 'invalid argument. Fourth argument must be a nonnegative integer. Value: `%d`.', k ) ); } if ( LDA < k+1 ) { - throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to ( %d + 1 ). Value: `%d`.', k, LDA ) ); + throw new RangeError( format( 'invalid argument. Seventh argument must be greater than or equal to %d. Value: `%d`.', k+1, LDA ) ); } if ( strideX === 0 ) { throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) );