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..42bffaa03214 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/README.md @@ -0,0 +1,264 @@ + + +# ssbmv + +> 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. + +
+ +## Usage + +```javascript +var ssbmv = require( '@stdlib/blas/base/ssbmv' ); +``` + +#### ssbmv( ord, uplo, N, k, α, A, LDA, x, sx, β, y, sy ) + +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' ); + +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 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-/sub-diagonals. +- **α**: scalar constant. +- **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`. +- **β**: scalar constant. +- **y**: output [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. + +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' ); + +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 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' ); + +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, + +```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..eba8ed049269 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.js @@ -0,0 +1,106 @@ +/** +* @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 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' ); +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 = ones( len*len, options.dtype ); + 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..028c9acb3064 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/benchmark/benchmark.ndarray.js @@ -0,0 +1,106 @@ +/** +* @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 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' ); +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 = ones( len*len, options.dtype ); + 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..99a0123a619d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/repl.txt @@ -0,0 +1,171 @@ + +{{alias}}( ord, uplo, N, k, α, A, lda, x, sx, β, y, sy ) + 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 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. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + 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-/sub-diagonals. + + α: number + Scalar constant. + + A: Float32Array + 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. + + sx: integer + Index increment for `x`. + + β: number + Scalar constant. + + y: Float32Array + Output vector . + + sy: integer + Index increment for `y`. + + Returns + ------- + y: Float32Array + Output vector. + + 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: + > 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 ] ); + > 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` 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 + indices. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + 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-/sub-diagonals. + + α: number + Scalar constant. + + A: Float32Array + 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. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + β: number + Scalar. + + y: Float32Array + Output vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + Returns + ------- + y: Float32Array + Output vector. + + 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: + > 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 ] + + 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..704c49312410 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/docs/types/index.d.ts @@ -0,0 +1,132 @@ +/* +* @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 + +/// + +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `ssbmv`. +*/ +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-/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-/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`) + * @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 `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: 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-/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-/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`) + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - starting `x` index + * @param beta - scalar constant + * @param y - second input array + * @param strideY - `y` stride length + * @param offsetY - starting `y` index + * @returns `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: 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; +} + +/** +* 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-/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`) +* @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 `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..7ecca2fe5439 --- /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 string... +{ + 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 sixth 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 an 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 an 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 string... +{ + 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 an 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 an 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..16921bbe55b0 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/examples/index.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'; + +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..04dab33578cb --- /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 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 +* +* @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..81e41b97d92f --- /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' ).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 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 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-/sub-diagonals +* @param {number} alpha - scalar constant +* @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 +* @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 - starting `y` index +* @throws {TypeError} first argument must be a valid order +* @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} 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, max-len + 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( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( 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( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( k < 0 ) { + 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. Value: `%d`.', k+1, LDA ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + 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; + } + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY, offsetY ); + } else { + sscal( N, beta, y, strideY, offsetY ); + } + } + if ( alpha === 0.0 ) { + return y; + } + kx = offsetX; + ky = offsetY; + 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( 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 + jx += strideX; + jy += strideY; + if ( j >= k ) { + kx += strideX; + ky += strideY; + } + } + return y; + } + // ( order === 'row-major' && uplo === 'upper') || ( order === 'column-major' && uplo === 'lower' ) + 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( temp2 + f32( A[ (j*LDA)+(l+i) ] * x[ ix ] ) ); + } + y[ jy ] += f32( 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..d04a945ad37e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/lib/ssbmv.js @@ -0,0 +1,187 @@ +/** +* @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 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 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-/sub-diagonals +* @param {number} alpha - scalar constant +* @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 +* @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 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} 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, max-len + var kplus1; + var temp1; + var temp2; + var ix; + var iy; + var jx; + var jy; + var kx; + var ky; + var sy; + var i; + var j; + var l; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( 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( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( k < 0 ) { + 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. Value: `%d`.', k+1, LDA ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Ninth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + 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; + } + sy = strideY; + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + if ( strideY < 0 ) { + sy = -sy; + } + sscal( N, beta, y, sy ); + } + } + 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' ) + ) { + 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( 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 + jx += strideX; + jy += strideY; + if ( j >= k ) { + kx += strideX; + ky += strideY; + } + } + return y; + } + // ( order === 'row-major' && uplo === 'upper') || ( order === 'column-major' && uplo === 'lower' ) + 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( temp2 + f32( A[ (j*LDA)+(l+i) ] * x[ ix ] ) ); + } + y[ jy ] += f32( 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..687061e32937 --- /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 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", + "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/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/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyn.json new file mode 100644 index 000000000000..9236968974a7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyn.json @@ -0,0 +1,17 @@ +{ + "uplo": "lower", + "order": "row-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": [ 1.9, 2.7, 1.2 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json new file mode 100644 index 000000000000..b458603866aa --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xnyp.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "row-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": [ 3.2, 3.6, 6.8 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json new file mode 100644 index 000000000000..204491cef188 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xoyt.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "row-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": [ 1.2, 0.0, 6.8, 0.0, 9.6, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json new file mode 100644 index 000000000000..9edc7f1862c5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyn.json @@ -0,0 +1,17 @@ +{ + "uplo": "upper", + "order": "row-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": [ 3.6, 3.6, 3.6 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json new file mode 100644 index 000000000000..81dc7fb15935 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/fixtures/row_major_xpyp.json @@ -0,0 +1,17 @@ +{ + "uplo": "lower", + "order": "row-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.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..1f96bf24ed94 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ndarray.js @@ -0,0 +1,609 @@ +/** +* @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 max-len */ + +'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 ones = require( '@stdlib/array/ones' ); +var ssbmv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +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 // + +/** +* 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 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 out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y_out ); + + 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 ); + + 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( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y_out ); + + 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 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 out; + var a; + var x; + var y; + + a = new Float32Array( cxoyt.A ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); + + expected = new Float32Array( cxoyt.y_out ); + + 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 ); + + 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=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxpyn.A ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); + + expected = new Float32Array( rxpyn.y_out ); + + 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 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( rxnyp.A ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); + + expected = new Float32Array( rxnyp.y_out ); + + 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 ); + + 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( cxnyp.A ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); + + expected = new Float32Array( cxnyp.y_out ); + + 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( '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 out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y ); + + 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' ); + + 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' ); + + t.end(); +}); + +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; + + 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( 'when `α` is zero, the function scales the second input vector (row-major, lower)', 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', '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' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + 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(); +}); + +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( 'when `α` is zero, the function scales the second input vector (column-major, lower)', 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', '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' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + 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' ); + + t.end(); +}); + +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 new file mode 100644 index 000000000000..d07fafea229b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssbmv/test/test.ssbmv.js @@ -0,0 +1,609 @@ +/** +* @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 max-len */ + +'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 ones = require( '@stdlib/array/ones' ); +var ssbmv = require( './../lib/ssbmv.js' ); + + +// FIXTURES // + +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 // + +/** +* 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 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 out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y_out ); + + 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 ); + + 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( cxpyp.A ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y_out ); + + 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 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 out; + var a; + var x; + var y; + + a = new Float32Array( cxoyt.A ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); + + expected = new Float32Array( cxoyt.y_out ); + + 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 ); + + 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=-1)', function test( t ) { + var expected; + var out; + var a; + var x; + var y; + + a = new Float32Array( rxpyn.A ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); + + expected = new Float32Array( rxpyn.y_out ); + + 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 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( rxnyp.A ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); + + expected = new Float32Array( rxnyp.y_out ); + + 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 ); + + 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( cxnyp.A ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); + + expected = new Float32Array( cxnyp.y_out ); + + 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( '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 out; + var a; + var x; + var y; + + a = new Float32Array( rxpyp.A ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y ); + + 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' ); + + 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' ); + + t.end(); +}); + +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; + + 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( 'when `α` is zero, the function scales the second input vector (row-major, lower)', 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', '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' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + 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(); +}); + +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( 'when `α` is zero, the function scales the second input vector (column-major, lower)', 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', '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' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + 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' ); + + t.end(); +}); + +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(); +});