diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/README.md b/lib/node_modules/@stdlib/blas/base/ssymv/README.md new file mode 100644 index 00000000000..0acda8012b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/README.md @@ -0,0 +1,263 @@ + + +# ssymv + +> 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 matrix. + +
+ +## Usage + +```javascript +var ssymv = require( '@stdlib/blas/base/ssymv' ); +``` + +#### ssymv( order, uplo, N, α, 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 matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + +ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); +// y => [ 1.0, 2.0, 3.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **N**: number of elements along each dimension of `A`. +- **α**: scalar constant. +- **A**: input matrix stored 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( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssymv( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 1.0, y, 1 ); +// y => [ 7.0, 10.0, 9.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +ssymv( 'row-major', 'upper', 3, 1.0, A, 3, x1, -1, 1.0, y1, -1 ); +// y0 => [ 1.0, 4.0, 3.0, 2.0 ] +``` + +#### ssymv.ndarray( order, uplo, N, α, 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 matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, -1, 2, 1.0, y, 1, 0 ); +// y => [ 7.0, 10.0, 9.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, -1, 2, 1.0, y, -1, 2 ); +// y => [ 4.0, 3.0, 2.0 ] +``` + +
+ + + +
+ +## Notes + +- `ssymv()` corresponds to the [BLAS][blas] level 2 function [`ssymv`][ssymv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var ssymv = require( '@stdlib/blas/base/ssymv' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = ones( N*N, opts.dtype ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +ssymv.ndarray( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 ); +console.log( y ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ssymv/benchmark/benchmark.js new file mode 100644 index 00000000000..72cea5db73b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssymv = require( './../lib/ssymv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = ones( N*N, 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 = ssymv( 'row-major', 'upper', N, 1.0, A, N, 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 min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssymv/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..e1c4c3bf633 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssymv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = uniform( N, -10.0, 10.0, options ); + var y = uniform( N, -10.0, 10.0, options ); + var A = ones( N*N, 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 = ssymv( 'row-major', 'upper', N, 1.0, A, N, 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 min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssymv/docs/repl.txt new file mode 100644 index 00000000000..cba8d7ca8e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/docs/repl.txt @@ -0,0 +1,134 @@ + +{{alias}}( order, uplo, N, α, 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 matrix. + + 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` and `β` equals `1`, the function returns `y` unchanged. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + A: Float32Array + Matrix. + + 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 + -------- + > 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, 2.0, 1.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, A, 2, x, 1, 1.0, y, 1 ) + [ 4.0, 4.0 ] + + +{{alias}}.ndarray( order, uplo, N, α, 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 matrix. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + A: Float32Array + Matrix. + + 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 constant. + + y: Float32Array + Output vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + Returns + ------- + y: Float32Array + Output array. + + Examples + -------- + > 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, 2.0, 1.0 ] ); + > var ord = 'row-major'; + > {{alias}}.ndarray( ord, 'upper', 2, 1.0, A, 2, x, 1, 0, 1.0, y, 1, 0 ) + [ 4.0, 4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/index.d.ts new file mode 100644 index 00000000000..2904b29e9e4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/index.d.ts @@ -0,0 +1,129 @@ +/* +* @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 `ssymv`. +*/ +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 matrix. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced + * @param N - number of elements along each dimension in the matrix `A` + * @param alpha - scalar constant + * @param A - matrix + * @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( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + * + * ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); + * // y => [ 1.0, 2.0, 3.0 ] + */ + ( order: Layout, uplo: MatrixTriangle, N: 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 matrix. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced + * @param N - number of elements along each dimension in the matrix `A` + * @param alpha - scalar constant + * @param A - matrix + * @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( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + * + * ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); + * // y => [ 1.0, 2.0, 3.0 ] + */ + ndarray( order: Layout, uplo: MatrixTriangle, N: 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 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 matrix. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced +* @param N - number of elements along each dimension in the matrix `A` +* @param alpha - scalar constant +* @param A - matrix +* @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( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssymv( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 1.0, y, 2 ); +* // y => [ 3.0, 2.0, 11.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssymv.ndarray( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 0, 1.0, y, 2, 0 ); +* // y => [ 3.0, 2.0, 11.0 ] +*/ +declare var ssymv: Routine; + + +// EXPORTS // + +export = ssymv; diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/test.ts new file mode 100644 index 00000000000..226e81ebcf3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/docs/types/test.ts @@ -0,0 +1,466 @@ +/* +* @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 ssymv = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 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 ); + + ssymv( 10, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( true, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( false, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( null, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( undefined, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( [], 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( {}, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( ( x: number ): number => x, 'upper', 10, 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 ); + + ssymv( 'row-major', 10, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', true, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', false, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', null, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', undefined, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', [ '1' ], 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', {}, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', ( x: number ): number => x, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', '10', 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', true, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', false, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', null, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', undefined, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', [], 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', {}, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', ( 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 fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, '10', A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, true, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, false, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, null, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, undefined, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, [], A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, {}, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, ( x: number ): number => x, 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 Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + ssymv( 'row-major', 'upper', 10, 1.0, 10, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, '10', 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, true, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, false, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, null, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, undefined, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, [ '1' ], 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, {}, 10, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 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 sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, '10', x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, true, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, false, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, null, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, [], x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, {}, x, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, 10, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, '10', 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, true, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, false, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, null, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, undefined, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, {}, 1, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, ( x: number ): number => x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, '10', 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, true, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, false, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, null, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, undefined, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, [], 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, {}, 1.0, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 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 ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, '10', y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, true, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, false, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, null, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, undefined, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, [], y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, {}, y, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, ( x: number ): number => x, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, 10, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, '10', 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, true, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, false, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, null, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, undefined, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, {}, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, ( x: number ): number => x, 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 ); + + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, '10' ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, true ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, false ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, null ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, undefined ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, [] ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, {} ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 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 ); + + ssymv(); // $ExpectError + ssymv( 'row-major' ); // $ExpectError + ssymv( 'row-major', 'upper' ); // $ExpectError + ssymv( 'row-major', 'upper', 10 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0 ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y ); // $ExpectError + ssymv( 'row-major', 'upper', 10, 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 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 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 ); + + ssymv.ndarray( 10, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( true, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( false, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( null, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( undefined, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( [], 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( {}, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( ( x: number ): number => x, 'upper', 10, 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 ); + + ssymv.ndarray( 'row-major', 10, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', true, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', false, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', null, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', undefined, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', [ '1' ], 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', {}, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', ( x: number ): number => x, 10, 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 ); + + ssymv.ndarray( 'row-major', 'upper', '10', 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', true, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', false, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', null, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', undefined, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', [], 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', {}, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', ( 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 fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, '10', A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, true, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, false, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, null, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, undefined, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, [], A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, {}, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, ( 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 fifth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, 10, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, '10', 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, true, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, false, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, null, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, undefined, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, {}, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, '10', x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, [], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, 10, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, '10', 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 an eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, '10', 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, true, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, false, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, null, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, [], 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, {}, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, '10', 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, true, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, false, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, null, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, [], 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, {}, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, '10', y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, true, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, false, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, null, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, [], y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, {}, y, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 an eleventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, 10, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, '10', 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, '10', 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, '10' ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, true ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, false ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, null ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 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 ); + + ssymv.ndarray(); // $ExpectError + ssymv.ndarray( 'row-major' ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper' ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1 ); // $ExpectError + ssymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/examples/index.js b/lib/node_modules/@stdlib/blas/base/ssymv/examples/index.js new file mode 100644 index 00000000000..354e2219486 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/examples/index.js @@ -0,0 +1,36 @@ +/** +* @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 ones = require( '@stdlib/array/ones' ); +var ssymv = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = ones( N*N, opts.dtype ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +ssymv.ndarray( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssymv/lib/index.js new file mode 100644 index 00000000000..6cc9f778db3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/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 matrix. +* +* @module @stdlib/blas/base/ssymv +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssymv = require( '@stdlib/blas/base/ssymv' ); +* +* var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ 1.0, 2.0, 3.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssymv = require( '@stdlib/blas/base/ssymv' ); +* +* var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssymv.ndarray( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); +* // y => [ 1.0, 2.0, 3.0 ] +*/ + +// MODULES // + +var join = require( 'path' ).join; +var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); +var main = require( './main.js' ); + + +// MAIN // + +var ssymv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ssymv = main; +} else { + ssymv = tmp; +} + + +// EXPORTS // + +module.exports = ssymv; + +// exports: { "ndarray": "ssymv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/lib/main.js b/lib/node_modules/@stdlib/blas/base/ssymv/lib/main.js new file mode 100644 index 00000000000..f6ed167285e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/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 ssymv = require( './ssymv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ssymv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ssymv; diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssymv/lib/ndarray.js new file mode 100644 index 00000000000..90855060060 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/lib/ndarray.js @@ -0,0 +1,173 @@ +/** +* @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 f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs 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 matrix. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - 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 to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be greater than or equal to max(1,N) +* @throws {RangeError} eighth 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( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); +* // y => [ 1.0, 2.0, 3.0 ] +*/ +function ssymv( order, uplo, N, alpha, A, LDA, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len + var temp1; + var temp2; + var jmin; + var jmax; + var ix; + var iy; + var jx; + var jy; + var ox; + var oy; + var i; + var j; + var k; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + } + if ( N < 0 ) { + throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ); + } + if ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Twelfth argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Form: y = beta*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; + } + ox = offsetX; + oy = offsetY; + + // Form: y = alpha*A*x + y + if ( + ( order === 'row-major' && uplo === 'upper' ) || + ( order === 'column-major' && uplo === 'lower' ) + ) { + ix = ox; + iy = oy; + for ( i = 0; i < N; i++ ) { + temp1 = f32( alpha * x[ ix ] ); + temp2 = 0.0; + jmin = i + 1; + jmax = N; + jx = ox + ( jmin*strideX ); + jy = oy + ( jmin*strideY ); + y[ iy ] += f32( temp1 * A[(LDA*i)+i] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA*i ) + j; + y[ jy ] += f32( temp1 * A[k] ); + temp2 = f32( temp2 + f32( x[jx] * A[k] ) ); + jx += strideX; + jy += strideY; + } + y[ iy ] += f32( alpha * temp2 ); + ix += strideX; + iy += strideY; + } + return y; + } + // ( order === 'row-major' && uplo === 'lower') || ( order === 'column-major' && uplo === 'upper' ) + ix = ox + ( (N-1)*strideX ); + iy = oy + ( (N-1)*strideY ); + for ( i = N-1; i >= 0; i-- ) { + temp1 = f32( alpha * x[ ix ] ); + temp2 = 0.0; + jmin = 0; + jmax = i; + jx = ox + ( jmin*strideX ); + jy = oy + ( jmin*strideY ); + y[ iy ] += f32( temp1 * A[(LDA*i)+i] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA*i ) + j; + y[ jy ] += f32( temp1 * A[k] ); + temp2 = f32( temp2 + f32( x[jx] * A[k] ) ); + jx += strideX; + jy += strideY; + } + y[ iy ] += f32( alpha * temp2 ); + ix -= strideX; + iy -= strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = ssymv; diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/lib/ssymv.js b/lib/node_modules/@stdlib/blas/base/ssymv/lib/ssymv.js new file mode 100644 index 00000000000..9d1a38d0562 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/lib/ssymv.js @@ -0,0 +1,181 @@ +/** +* @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 f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs 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 matrix. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float32Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input array +* @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be greater than or equal to max(1,N) +* @throws {RangeError} eighth argument must be non-zero +* @throws {RangeError} eleventh argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 0.0, 0.0, 0.0 ] ); +* +* ssymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ 1.0, 2.0, 3.0 ] +*/ +function ssymv( order, uplo, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { // eslint-disable-line max-params + var temp1; + var temp2; + var jmin; + var jmax; + var ix; + var iy; + var jx; + var jy; + var ox; + var oy; + var i; + var j; + var k; + + if ( !isLayout( order ) ) { + throw new TypeError( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ); + } + if ( N < 0 ) { + throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( 'invalid argument. Sixth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ); + } + if ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Eleventh argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Form: y = beta*y + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + if ( strideY < 0 ) { + strideY = -strideY; + } + sscal( N, beta, y, strideY ); + } + } + if ( alpha === 0.0 ) { + return y; + } + if ( strideX > 0 ) { + ox = 0; + } else { + ox = ( 1 - N ) * strideX; + } + if ( strideY > 0 ) { + oy = 0; + } else { + oy = ( 1 - N ) * strideY; + } + // Form: y = alpha*A*x + y + if ( + ( order === 'row-major' && uplo === 'upper' ) || + ( order === 'column-major' && uplo === 'lower' ) + ) { + ix = ox; + iy = oy; + for ( i = 0; i < N; i++ ) { + temp1 = f32( alpha * x[ ix ] ); + temp2 = 0.0; + jmin = i + 1; + jmax = N; + jx = ox + ( jmin*strideX ); + jy = oy + ( jmin*strideY ); + y[ iy ] += f32( temp1 * A[(LDA*i)+i] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA*i ) + j; + y[ jy ] += f32( temp1 * A[k] ); + temp2 = f32( temp2 + f32( x[jx] * A[k] ) ); + jx += strideX; + jy += strideY; + } + y[ iy ] += f32( alpha * temp2 ); + ix += strideX; + iy += strideY; + } + return y; + } + // ( order === 'row-major' && uplo === 'lower') || ( order === 'column-major' && uplo === 'upper' ) + ix = ox + ( (N-1)*strideX ); + iy = oy + ( (N-1)*strideY ); + for ( i = N-1; i >= 0; i-- ) { + temp1 = f32( alpha * x[ ix ] ); + temp2 = 0.0; + jmin = 0; + jmax = i; + jx = ox + ( jmin*strideX ); + jy = oy + ( jmin*strideY ); + y[ iy ] += f32( temp1 * A[(LDA*i)+i] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA*i ) + j; + y[ jy ] += f32( temp1 * A[k] ); + temp2 = f32( temp2 + f32( x[jx] * A[k] ) ); + jx += strideX; + jy += strideY; + } + y[ iy ] += f32( alpha * temp2 ); + ix -= strideX; + iy -= strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = ssymv; diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/package.json b/lib/node_modules/@stdlib/blas/base/ssymv/package.json new file mode 100644 index 00000000000..7f5d309e891 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/ssymv", + "version": "0.0.0", + "description": "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 matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 2", + "ssymv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyn.json new file mode 100644 index 00000000000..2fd5e82f07e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyn.json @@ -0,0 +1,16 @@ +{ + "uplo": "lower", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 4.0, 3.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyp.json new file mode 100644 index 00000000000..ad0199f70d9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xnyp.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 7.0, 10.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xoyt.json new file mode 100644 index 00000000000..52fb03d1f33 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xoyt.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "y_out": [ 3.0, 0.0, 10.0, 0.0, 21.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyn.json new file mode 100644 index 00000000000..0fba9d62725 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyn.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 19.0, 10.0, 5.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyp.json new file mode 100644 index 00000000000..11c4b7ffdcb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/column_major_xpyp.json @@ -0,0 +1,16 @@ +{ + "uplo": "lower", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 0.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 0.0, 0.0, 0.0 ], + "y_out": [ 1.0, 2.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyn.json new file mode 100644 index 00000000000..9f92e653157 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyn.json @@ -0,0 +1,16 @@ +{ + "uplo": "lower", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 4.0, 3.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyp.json new file mode 100644 index 00000000000..eb8d8c18385 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xnyp.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": -1, + "offsetX": 2, + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 7.0, 10.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xoyt.json new file mode 100644 index 00000000000..3d64ae65293 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xoyt.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 2, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ], + "y_out": [ 3.0, 0.0, 10.0, 0.0, 21.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyn.json new file mode 100644 index 00000000000..7db3af0f446 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyn.json @@ -0,0 +1,16 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 2.0, + "beta": 1.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 2.0, 3.0 ], + "y": [ 1.0, 2.0, 3.0 ], + "y_out": [ 19.0, 10.0, 5.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyp.json new file mode 100644 index 00000000000..8dabdefd5af --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/fixtures/row_major_xpyp.json @@ -0,0 +1,16 @@ +{ + "uplo": "lower", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 0.0, + "lda": 3, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 0.0, 0.0, 0.0 ], + "y_out": [ 1.0, 2.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/test.js b/lib/node_modules/@stdlib/blas/base/ssymv/test/test.js new file mode 100644 index 00000000000..b06aa3dba4f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/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 ssymv = 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 ssymv, '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 ssymv.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 ssymv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssymv, 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 ssymv; + var main; + + main = require( './../lib/ssymv.js' ); + + ssymv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssymv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/ssymv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssymv/test/test.ndarray.js new file mode 100644 index 00000000000..33e8c96e7a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/test.ndarray.js @@ -0,0 +1,589 @@ +/** +* @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 ssymv = 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 ssymv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( ssymv.length, 13, '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() { + ssymv( value, rxpyp.uplo, rxpyp.N, 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() { + ssymv( rxpyp.order, value, rxpyp.N, 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() { + ssymv( rxpyp.order, rxpyp.uplo, 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 sixth argument', function test( t ) { + var values; + var i; + + values = [ + 2, + 1, + 0, + -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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 eighth 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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 matrix (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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 matrix (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 = ssymv( cxpyp.order, cxpyp.uplo, cxpyp.N, 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 matrix (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 = ssymv( rxoyt.order, rxoyt.uplo, rxoyt.N, 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 matrix (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 = ssymv( cxoyt.order, cxoyt.uplo, cxoyt.N, 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 matrix (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 = ssymv( rxpyn.order, rxpyn.uplo, rxpyn.N, 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 matrix (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 = ssymv( cxpyn.order, cxpyn.uplo, cxpyn.N, 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 matrix (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 = ssymv( rxnyp.order, rxnyp.uplo, rxnyp.N, 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 matrix (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 = ssymv( cxnyp.order, cxnyp.uplo, cxnyp.N, 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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 = ssymv( rxpyp.order, rxpyp.uplo, 0, 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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 = ssymv( cxpyp.order, cxpyp.uplo, 0, 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 = ssymv( cxpyp.order, cxpyp.uplo, cxpyp.N, 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 = ssymv( 'row-major', 'upper', 3, 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 = ssymv( 'row-major', 'upper', 3, 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 = ssymv( 'row-major', 'lower', 3, 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 = ssymv( 'row-major', 'lower', 3, 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 = ssymv( 'column-major', 'upper', 3, 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 = ssymv( 'column-major', 'upper', 3, 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 = ssymv( 'column-major', 'lower', 3, 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 = ssymv( 'column-major', 'lower', 3, 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 = ssymv( rxnyn.order, rxnyn.uplo, rxnyn.N, 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 = ssymv( cxnyn.order, cxnyn.uplo, cxnyn.N, 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/ssymv/test/test.ssymv.js b/lib/node_modules/@stdlib/blas/base/ssymv/test/test.ssymv.js new file mode 100644 index 00000000000..e743e4ae029 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssymv/test/test.ssymv.js @@ -0,0 +1,589 @@ +/** +* @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 ssymv = require( './../lib/ssymv.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 ssymv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( ssymv.length, 11, '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() { + ssymv( value, rxpyp.uplo, rxpyp.N, 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() { + ssymv( rxpyp.order, value, rxpyp.N, 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() { + ssymv( rxpyp.order, rxpyp.uplo, 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 sixth argument', function test( t ) { + var values; + var i; + + values = [ + 2, + 1, + 0, + -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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 eighth 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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 eleventh 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() { + ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 matrix (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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 matrix (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 = ssymv( cxpyp.order, cxpyp.uplo, cxpyp.N, 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 matrix (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 = ssymv( rxoyt.order, rxoyt.uplo, rxoyt.N, 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 matrix (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 = ssymv( cxoyt.order, cxoyt.uplo, cxoyt.N, 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 matrix (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 = ssymv( rxpyn.order, rxpyn.uplo, rxpyn.N, 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 matrix (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 = ssymv( cxpyn.order, cxpyn.uplo, cxpyn.N, 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 matrix (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 = ssymv( rxnyp.order, rxnyp.uplo, rxnyp.N, 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 matrix (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 = ssymv( cxnyp.order, cxnyp.uplo, cxnyp.N, 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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 = ssymv( rxpyp.order, rxpyp.uplo, 0, 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 = ssymv( rxpyp.order, rxpyp.uplo, rxpyp.N, 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 = ssymv( cxpyp.order, cxpyp.uplo, 0, 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 = ssymv( cxpyp.order, cxpyp.uplo, cxpyp.N, 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 = ssymv( 'row-major', 'upper', 3, 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 = ssymv( 'row-major', 'upper', 3, 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 = ssymv( 'row-major', 'lower', 3, 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 = ssymv( 'row-major', 'lower', 3, 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 = ssymv( 'column-major', 'upper', 3, 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 = ssymv( 'column-major', 'upper', 3, 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 = ssymv( 'column-major', 'lower', 3, 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 = ssymv( 'column-major', 'lower', 3, 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 = ssymv( rxnyn.order, rxnyn.uplo, rxnyn.N, 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 = ssymv( cxnyn.order, cxnyn.uplo, cxnyn.N, 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(); +}); diff --git a/lib/node_modules/@stdlib/types/index.d.ts b/lib/node_modules/@stdlib/types/index.d.ts index a813e0b792b..d982705d4fb 100644 --- a/lib/node_modules/@stdlib/types/index.d.ts +++ b/lib/node_modules/@stdlib/types/index.d.ts @@ -1266,6 +1266,66 @@ declare module '@stdlib/types/iter' { } } +/** +* Module containing definitions for BLAS routines. +* +* @example +* import * as blas from `@stdlib/types/blas`; +* +* const layout: blas.Layout = 'row-major'; +*/ +declare module '@stdlib/types/blas' { + /** + * Diagonal element type. + * + * ## Notes + * + * - **non-unit**: elements along a diagonal are **not** all equal to one. + * - **unit**: elements along a diagonal are all equal to one. + */ + type DiagonalType = 'non-unit' | 'unit'; + + /** + * Array memory layout. + * + * ## Notes + * + * - The array memory layout is either row-major (C-style) or column-major (Fortran-style). + */ + type Layout = 'row-major' | 'column-major'; + + /** + * Matrix triangle. + * + * ## Notes + * + * - **upper**: upper triangular part of a matrix. + * - **lower**: lower triangular part of a matrix. + */ + type MatrixTriangle = 'upper' | 'lower'; + + /** + * Operation side. + * + * ## Notes + * + * - **left**: a triangular matrix is on the left side of a matrix-matrix operation (e.g., AX = B, where A is a triangular matrix). + * - **right**: a triangular matrix is on the right side of a matrix-matrix operation (e.g., XA = B, where A is a triangular matrix). + */ + type OperationSide = 'left' | 'right'; + + /** + * Transpose operations. + * + * ## Notes + * + * - **none**: no transposition. + * - **transpose**: transposition. + * - **conjugate-transpose**: conjugate transposition. + */ + type TransposeOperation = 'none' | 'transpose' | 'conjugate-transpose'; +} + /** * Module containing ndarray definitions. * @@ -1326,6 +1386,7 @@ declare module '@stdlib/types/iter' { declare module '@stdlib/types/ndarray' { import { ArrayLike, AccessorArrayLike, Collection, Complex128Array, Complex64Array, RealOrComplexTypedArray, FloatOrComplexTypedArray, RealTypedArray, ComplexTypedArray, IntegerTypedArray, FloatTypedArray, SignedIntegerTypedArray, UnsignedIntegerTypedArray } from '@stdlib/types/array'; import { ComplexLike, Complex128, Complex64 } from '@stdlib/types/complex'; // eslint-disable-line no-duplicate-imports + import { Layout } from '@stdlib/types/blas'; /** * Data type. @@ -1394,7 +1455,7 @@ declare module '@stdlib/types/ndarray' { * * - The array order is either row-major (C-style) or column-major (Fortran-style). */ - type Order = 'row-major' | 'column-major'; + type Order = Layout; /** * Array index mode. diff --git a/lib/node_modules/@stdlib/types/test.ts b/lib/node_modules/@stdlib/types/test.ts index eae91ef240e..7f1fd8511ab 100644 --- a/lib/node_modules/@stdlib/types/test.ts +++ b/lib/node_modules/@stdlib/types/test.ts @@ -19,10 +19,11 @@ /// import * as array from '@stdlib/types/array'; +import * as blas from '@stdlib/types/blas'; +import * as complex from '@stdlib/types/complex'; import * as iter from '@stdlib/types/iter'; import * as ndarray from '@stdlib/types/ndarray'; import * as obj from '@stdlib/types/object'; -import * as complex from '@stdlib/types/complex'; import * as random from '@stdlib/types/random'; import * as slice from '@stdlib/types/slice'; @@ -391,6 +392,65 @@ function cmplx128Array(): array.Complex128Array { } } +// The compiler should not throw an error when using BLAS types... +{ + const v1: blas.Layout = 'row-major'; + if ( typeof v1 !== 'string' ) { + throw new Error( 'something went wrong' ); + } + + const v2: blas.TransposeOperation = 'transpose'; + if ( typeof v2 !== 'string' ) { + throw new Error( 'something went wrong' ); + } + + const v3: blas.MatrixTriangle = 'upper'; + if ( typeof v3 !== 'string' ) { + throw new Error( 'something went wrong' ); + } + + const v4: blas.DiagonalType = 'unit'; + if ( typeof v4 !== 'string' ) { + throw new Error( 'something went wrong' ); + } + + const v5: blas.OperationSide = 'right'; + if ( typeof v5 !== 'string' ) { + throw new Error( 'something went wrong' ); + } +} + +// The compiler should not throw an error when using complex number types... +{ + const v1: complex.ComplexLike = { + 're': 1.0, + 'im': 1.0 + }; + if ( v1.re !== 1.0 ) { + throw new Error( 'something went wrong' ); + } + + const v2: complex.Complex64 = { + 're': 1.0, + 'im': 1.0, + 'byteLength': 8, + 'BYTES_PER_ELEMENT': 4 + }; + if ( v2.re !== 1.0 ) { + throw new Error( 'something went wrong' ); + } + + const v3: complex.Complex128 = { + 're': 1.0, + 'im': 1.0, + 'byteLength': 16, + 'BYTES_PER_ELEMENT': 8 + }; + if ( v3.re !== 1.0 ) { + throw new Error( 'something went wrong' ); + } +} + // The compiler should not throw an error when using iterator or iterable types... { createIterator1(); @@ -570,37 +630,6 @@ function cmplx128Array(): array.Complex128Array { } } -// The compiler should not throw an error when using complex number types... -{ - const v1: complex.ComplexLike = { - 're': 1.0, - 'im': 1.0 - }; - if ( v1.re !== 1.0 ) { - throw new Error( 'something went wrong' ); - } - - const v2: complex.Complex64 = { - 're': 1.0, - 'im': 1.0, - 'byteLength': 8, - 'BYTES_PER_ELEMENT': 4 - }; - if ( v2.re !== 1.0 ) { - throw new Error( 'something went wrong' ); - } - - const v3: complex.Complex128 = { - 're': 1.0, - 'im': 1.0, - 'byteLength': 16, - 'BYTES_PER_ELEMENT': 8 - }; - if ( v3.re !== 1.0 ) { - throw new Error( 'something went wrong' ); - } -} - // The compiler should not throw an error when using PRNG types... { const rand: random.PRNG = (): number => 3.14;