From 625cc72cd5201fff45c6195450bb9ee3867be024 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Wed, 26 Jun 2024 12:33:25 +0530 Subject: [PATCH 1/3] feat: add BLAS Level 2 routine for dsymv --- .../@stdlib/blas/base/dsymv/README.md | 263 ++++++++ .../blas/base/dsymv/benchmark/benchmark.js | 106 ++++ .../base/dsymv/benchmark/benchmark.ndarray.js | 106 ++++ .../@stdlib/blas/base/dsymv/docs/repl.txt | 134 ++++ .../blas/base/dsymv/docs/types/index.d.ts | 129 ++++ .../blas/base/dsymv/docs/types/test.ts | 466 ++++++++++++++ .../@stdlib/blas/base/dsymv/examples/index.js | 36 ++ .../@stdlib/blas/base/dsymv/lib/dsymv.js | 183 ++++++ .../@stdlib/blas/base/dsymv/lib/index.js | 72 +++ .../@stdlib/blas/base/dsymv/lib/main.js | 35 ++ .../@stdlib/blas/base/dsymv/lib/ndarray.js | 172 +++++ .../@stdlib/blas/base/dsymv/package.json | 68 ++ .../test/fixtures/column_major_xnyn.json | 16 + .../test/fixtures/column_major_xnyp.json | 16 + .../test/fixtures/column_major_xoyt.json | 16 + .../test/fixtures/column_major_xpyn.json | 16 + .../test/fixtures/column_major_xpyp.json | 16 + .../dsymv/test/fixtures/row_major_xnyn.json | 16 + .../dsymv/test/fixtures/row_major_xnyp.json | 16 + .../dsymv/test/fixtures/row_major_xoyt.json | 16 + .../dsymv/test/fixtures/row_major_xpyn.json | 16 + .../dsymv/test/fixtures/row_major_xpyp.json | 16 + .../blas/base/dsymv/test/test.dsymv.js | 589 ++++++++++++++++++ .../@stdlib/blas/base/dsymv/test/test.js | 82 +++ .../blas/base/dsymv/test/test.ndarray.js | 589 ++++++++++++++++++ 25 files changed, 3190 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/README.md b/lib/node_modules/@stdlib/blas/base/dsymv/README.md new file mode 100644 index 000000000000..4168a81bd981 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/README.md @@ -0,0 +1,263 @@ + + +# dsymv + +> 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 dsymv = require( '@stdlib/blas/base/dsymv' ); +``` + +#### dsymv( 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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + +dsymv( '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 [`Float64Array`][mdn-float64array]. +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). +- **x**: input [`Float64Array`][mdn-float64array]. +- **sx**: index increment for `x`. +- **β**: scalar constant. +- **y**: output [`Float64Array`][mdn-float64array]. +- **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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dsymv( '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 Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var y0 = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dsymv( 'row-major', 'upper', 3, 1.0, A, 3, x1, -1, 1.0, y1, -1 ); +// y0 => [ 1.0, 4.0, 3.0, 2.0 ] +``` + +#### dsymv.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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dsymv.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 Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + +dsymv.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 + +- `dsymv()` corresponds to the [BLAS][blas] level 2 function [`dsymv`][dsymv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var dsymv = require( '@stdlib/blas/base/dsymv' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 3; +var A = ones( N*N, opts.dtype ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +dsymv.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/dsymv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dsymv/benchmark/benchmark.js new file mode 100644 index 000000000000..3268a80cf94b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +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 dsymv = require( './../lib/dsymv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 = dsymv( 'row-major', 'upper', N, 1.0, A, N, x, 1, 1.0, y, 1 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var 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/dsymv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsymv/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b612f6e7c380 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +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 dsymv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// 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 = dsymv( 'row-major', 'upper', N, 1.0, A, N, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var 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/dsymv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsymv/docs/repl.txt new file mode 100644 index 000000000000..c7fc6bf494ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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: Float64Array + Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + x: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + β: number + Scalar constant. + + y: Float64Array + Output vector. + + sy: integer + Index increment for `y`. + + Returns + ------- + y: Float64Array + Output vector. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 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: Float64Array + Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + x: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + β: number + Scalar constant. + + y: Float64Array + Output vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + Returns + ------- + y: Float64Array + Output array. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 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/dsymv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dsymv/docs/types/index.d.ts new file mode 100644 index 000000000000..47e632ca052f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 `dsymv`. +*/ +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 Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + * + * dsymv( '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: Float64Array, LDA: number, x: Float64Array, strideX: number, beta: number, y: Float64Array, strideY: number ): Float64Array; + + /** + * 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 Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); + * var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); + * + * dsymv.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: Float64Array, LDA: number, x: Float64Array, strideX: number, offsetX: number, beta: number, y: Float64Array, strideY: number, offsetY: number ): Float64Array; +} + +/** +* 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 Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsymv( 'row-major', 'upper', 3, 2.0, A, 3, x, 1, 1.0, y, 2 ); +* // y => [ 3.0, 2.0, 11.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsymv.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 dsymv: Routine; + + +// EXPORTS // + +export = dsymv; diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dsymv/docs/types/test.ts new file mode 100644 index 000000000000..12c0c5590cb3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 dsymv = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 10, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( true, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( false, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( null, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( undefined, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( [], 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( {}, 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( ( 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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 10, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', true, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', false, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', null, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', undefined, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', [ '1' ], 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', {}, 10, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', '10', 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', true, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', false, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', null, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', undefined, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', [], 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', {}, 1.0, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, '10', A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, true, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, false, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, null, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, undefined, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, [], A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, {}, A, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + dsymv( 'row-major', 'upper', 10, 1.0, 10, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, '10', 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, true, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, false, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, null, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, undefined, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, [ '1' ], 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, {}, 10, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, '10', x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, true, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, false, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, null, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, [], x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, {}, x, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array... +{ + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, 10, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, '10', 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, true, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, false, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, null, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, undefined, 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, {}, 1, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, '10', 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, true, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, false, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, null, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, undefined, 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, [], 1.0, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, {}, 1.0, y, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, '10', y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, true, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, false, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, null, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, undefined, y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, [], y, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, {}, y, 1 ); // $ExpectError + dsymv( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, 10, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, '10', 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, true, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, false, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, null, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, undefined, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, {}, 1 ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, '10' ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, true ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, false ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, null ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, undefined ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, [] ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y, {} ); // $ExpectError + dsymv( '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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv(); // $ExpectError + dsymv( 'row-major' ); // $ExpectError + dsymv( 'row-major', 'upper' ); // $ExpectError + dsymv( 'row-major', 'upper', 10 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0 ); // $ExpectError + dsymv( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 1.0, y ); // $ExpectError + dsymv( '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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 10, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( true, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( false, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( null, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( undefined, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( [], 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( {}, 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 10, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', true, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', false, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', null, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', undefined, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', [ '1' ], 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', {}, 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', '10', 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', true, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', false, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', null, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', undefined, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', [], 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', {}, 1.0, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, '10', A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, true, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, false, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, null, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, undefined, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, [], A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, {}, A, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, 10, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, '10', 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, true, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, false, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, null, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, undefined, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, {}, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, '10', x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, [], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array... +{ + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, 10, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, '10', 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, '10', 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, true, 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, false, 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, null, 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, [], 0, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, {}, 0, 1.0, y, 1 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, '10', 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, true, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, false, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, null, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, [], 1.0, y, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, {}, 1.0, y, 1 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, '10', y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, true, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, false, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, null, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, [], y, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, {}, y, 1, 0 ); // $ExpectError + dsymv.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 Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, 10, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, '10', 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, '10', 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, '10' ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, true ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, false ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, null ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError + dsymv.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 Float64Array( 10 ); + const y = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsymv.ndarray(); // $ExpectError + dsymv.ndarray( 'row-major' ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper' ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0 ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y ); // $ExpectError + dsymv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, x, 1, 0, 1.0, y, 1 ); // $ExpectError + dsymv.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/dsymv/examples/index.js b/lib/node_modules/@stdlib/blas/base/dsymv/examples/index.js new file mode 100644 index 000000000000..26ee7647750c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 dsymv = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 3; +var A = ones( N*N, opts.dtype ); + +var x = discreteUniform( N, 0, 255, opts ); +var y = discreteUniform( N, 0, 255, opts ); + +dsymv.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/dsymv/lib/dsymv.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js new file mode 100644 index 000000000000..d41be1ab6a6a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js @@ -0,0 +1,183 @@ +/** +* @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 dfill = require( '@stdlib/blas/ext/base/dfill' ); +var dscal = require( '@stdlib/blas/base/dscal' ); +var max = require( '@stdlib/math/base/special/max' ); +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 {Float64Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float64Array} 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 {Float64Array} `y` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +* +* dsymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ 1.0, 2.0, 3.0 ] +*/ +function dsymv( 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 sy; + 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 + sy = strideY; + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + dfill( N, 0.0, y, strideY ); + } else { + if ( sy < 0 ) { + sy = -sy; + } + dscal( N, beta, y, sy ); + } + } + 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 = alpha * x[ ix ]; + temp2 = 0.0; + jmin = i + 1; + jmax = N; + jx = ox + ( jmin*strideX ); + jy = oy + ( jmin*strideY ); + y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA * i ) + j; + y[ jy ] += ( temp1 * A[ k ] ); + temp2 += ( x[ jx ] * A[ k ] ); + jx += strideX; + jy += strideY; + } + y[ iy ] += ( 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 = alpha * x[ ix ]; + temp2 = 0.0; + jmin = 0; + jmax = i; + jx = ox + ( jmin * strideX ); + jy = oy + ( jmin * strideY ); + y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA * i ) + j; + y[ jy ] += ( temp1 * A[ k ] ); + temp2 += ( x[ jx ] * A[ k ] ); + jx += strideX; + jy += strideY; + } + y[ iy ] += ( alpha * temp2 ); + ix -= strideX; + iy -= strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = dsymv; diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/lib/index.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/index.js new file mode 100644 index 000000000000..e5cf53d01eea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dsymv = require( '@stdlib/blas/base/dsymv' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +* +* dsymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0.0, y, 1 ); +* // y => [ 1.0, 2.0, 3.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dsymv = require( '@stdlib/blas/base/dsymv' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +* +* dsymv.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 dsymv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dsymv = main; +} else { + dsymv = tmp; +} + + +// EXPORTS // + +module.exports = dsymv; + +// exports: { "ndarray": "dsymv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/lib/main.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/main.js new file mode 100644 index 000000000000..7ffb670bf478 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 dsymv = require( './dsymv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dsymv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dsymv; diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js new file mode 100644 index 000000000000..887b44fbc326 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js @@ -0,0 +1,172 @@ +/** +* @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 dfill = require( '@stdlib/blas/ext/base/dfill' ).ndarray; +var dscal = require( '@stdlib/blas/base/dscal' ).ndarray; +var max = require( '@stdlib/math/base/special/max' ); +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 {Float64Array} A - matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {Float64Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting `x` index +* @param {number} beta - scalar constant +* @param {Float64Array} 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 {Float64Array} `y` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 0.0, 0.0, 0.0, 2.0, 0.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float64Array( [ 0.0, 0.0, 0.0 ] ); +* +* dsymv( 'row-major', 'lower', 3, 1.0, A, 3, x, 1, 0, 0.0, y, 1, 0 ); +* // y => [ 1.0, 2.0, 3.0 ] +*/ +function dsymv( 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 ) { + dfill( N, 0.0, y, strideY, offsetY ); + } else { + dscal( 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 = alpha * x[ ix ]; + temp2 = 0.0; + jmin = i + 1; + jmax = N; + jx = ox + ( jmin * strideX ); + jy = oy + ( jmin * strideY ); + y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA * i ) + j; + y[ jy ] += ( temp1 * A[ k ] ); + temp2 += ( x[ jx ] * A[ k ] ); + jx += strideX; + jy += strideY; + } + y[ iy ] += ( 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 = alpha * x[ ix ]; + temp2 = 0.0; + jmin = 0; + jmax = i; + jx = ox + ( jmin * strideX ); + jy = oy + ( jmin * strideY ); + y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + for ( j = jmin; j < jmax; j++ ) { + k = ( LDA * i ) + j; + y[ jy ] += ( temp1 * A[ k ] ); + temp2 += ( x[ jx ] * A[ k ] ); + jx += strideX; + jy += strideY; + } + y[ iy ] += ( alpha * temp2 ); + ix -= strideX; + iy -= strideY; + } + return y; +} + + +// EXPORTS // + +module.exports = dsymv; diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/package.json b/lib/node_modules/@stdlib/blas/base/dsymv/package.json new file mode 100644 index 000000000000..fe7e7ba5fec7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/dsymv", + "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", + "dsymv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xnyn.json new file mode 100644 index 000000000000..2fd5e82f07e3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xnyp.json new file mode 100644 index 000000000000..ad0199f70d9b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xoyt.json new file mode 100644 index 000000000000..52fb03d1f33a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xpyn.json new file mode 100644 index 000000000000..0fba9d62725a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/column_major_xpyp.json new file mode 100644 index 000000000000..11c4b7ffdcbc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xnyn.json new file mode 100644 index 000000000000..9f92e653157a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xnyp.json new file mode 100644 index 000000000000..eb8d8c183858 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/row_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xoyt.json new file mode 100644 index 000000000000..3d64ae652939 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xpyn.json new file mode 100644 index 000000000000..7db3af0f446d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/dsymv/test/fixtures/row_major_xpyp.json new file mode 100644 index 000000000000..8dabdefd5af6 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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/dsymv/test/test.dsymv.js b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js new file mode 100644 index 000000000000..2d10edaa1793 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); +var dsymv = require( './../lib/dsymv.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 dsymv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dsymv.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() { + dsymv( value, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, value, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, value, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), value, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), value, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float64Array( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + expected = new Float64Array( rxpyp.y_out ); + + out = dsymv( 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 Float64Array( cxpyp.A ); + x = new Float64Array( cxpyp.x ); + y = new Float64Array( cxpyp.y ); + + expected = new Float64Array( cxpyp.y_out ); + + out = dsymv( 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 Float64Array( rxoyt.A ); + x = new Float64Array( rxoyt.x ); + y = new Float64Array( rxoyt.y ); + + expected = new Float64Array( rxoyt.y_out ); + + out = dsymv( 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 Float64Array( cxoyt.A ); + x = new Float64Array( cxoyt.x ); + y = new Float64Array( cxoyt.y ); + + expected = new Float64Array( cxoyt.y_out ); + + out = dsymv( 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 Float64Array( rxpyn.A ); + x = new Float64Array( rxpyn.x ); + y = new Float64Array( rxpyn.y ); + + expected = new Float64Array( rxpyn.y_out ); + + out = dsymv( 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 Float64Array( cxpyn.A ); + x = new Float64Array( cxpyn.x ); + y = new Float64Array( cxpyn.y ); + + expected = new Float64Array( cxpyn.y_out ); + + out = dsymv( 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 Float64Array( rxnyp.A ); + x = new Float64Array( rxnyp.x ); + y = new Float64Array( rxnyp.y ); + + expected = new Float64Array( rxnyp.y_out ); + + out = dsymv( 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 Float64Array( cxnyp.A ); + x = new Float64Array( cxnyp.x ); + y = new Float64Array( cxnyp.y ); + + expected = new Float64Array( cxnyp.y_out ); + + out = dsymv( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + out = dsymv( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + expected = new Float64Array( rxpyp.y ); + + out = dsymv( 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 = dsymv( 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 Float64Array( cxpyp.A ); + x = new Float64Array( cxpyp.x ); + y = new Float64Array( cxpyp.y ); + + expected = new Float64Array( cxpyp.y ); + + out = dsymv( 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 = dsymv( 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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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 Float64Array( rxnyn.A ); + x = new Float64Array( rxnyn.x ); + y = new Float64Array( rxnyn.y ); + + expected = new Float64Array( rxnyn.y_out ); + + out = dsymv( 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 Float64Array( cxnyn.A ); + x = new Float64Array( cxnyn.x ); + y = new Float64Array( cxnyn.y ); + + expected = new Float64Array( cxnyn.y_out ); + + out = dsymv( 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/blas/base/dsymv/test/test.js b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.js new file mode 100644 index 000000000000..4b82fe45b466 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 dsymv = 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 dsymv, '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 dsymv.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 dsymv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dsymv, 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 dsymv; + var main; + + main = require( './../lib/dsymv.js' ); + + dsymv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dsymv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js new file mode 100644 index 000000000000..5c7c3fd2b13c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsymv/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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); +var dsymv = 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 dsymv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( dsymv.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() { + dsymv( value, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, value, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, value, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), value, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), value, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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() { + dsymv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float64Array( rxpyp.a ), rxpyp.lda, new Float64Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float64Array( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + expected = new Float64Array( rxpyp.y_out ); + + out = dsymv( 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 Float64Array( cxpyp.A ); + x = new Float64Array( cxpyp.x ); + y = new Float64Array( cxpyp.y ); + + expected = new Float64Array( cxpyp.y_out ); + + out = dsymv( 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 Float64Array( rxoyt.A ); + x = new Float64Array( rxoyt.x ); + y = new Float64Array( rxoyt.y ); + + expected = new Float64Array( rxoyt.y_out ); + + out = dsymv( 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 Float64Array( cxoyt.A ); + x = new Float64Array( cxoyt.x ); + y = new Float64Array( cxoyt.y ); + + expected = new Float64Array( cxoyt.y_out ); + + out = dsymv( 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 Float64Array( rxpyn.A ); + x = new Float64Array( rxpyn.x ); + y = new Float64Array( rxpyn.y ); + + expected = new Float64Array( rxpyn.y_out ); + + out = dsymv( 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 Float64Array( cxpyn.A ); + x = new Float64Array( cxpyn.x ); + y = new Float64Array( cxpyn.y ); + + expected = new Float64Array( cxpyn.y_out ); + + out = dsymv( 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 Float64Array( rxnyp.A ); + x = new Float64Array( rxnyp.x ); + y = new Float64Array( rxnyp.y ); + + expected = new Float64Array( rxnyp.y_out ); + + out = dsymv( 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 Float64Array( cxnyp.A ); + x = new Float64Array( cxnyp.x ); + y = new Float64Array( cxnyp.y ); + + expected = new Float64Array( cxnyp.y_out ); + + out = dsymv( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + out = dsymv( 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 Float64Array( rxpyp.A ); + x = new Float64Array( rxpyp.x ); + y = new Float64Array( rxpyp.y ); + + expected = new Float64Array( rxpyp.y ); + + out = dsymv( 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 = dsymv( 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 Float64Array( cxpyp.A ); + x = new Float64Array( cxpyp.x ); + y = new Float64Array( cxpyp.y ); + + expected = new Float64Array( cxpyp.y ); + + out = dsymv( 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 = dsymv( 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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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, 'float64' ); + x = ones( 3, 'float64' ); + y = ones( 3, 'float64' ); + + expected = new Float64Array( [ 5.0, 5.0, 5.0 ] ); + + out = dsymv( '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 Float64Array( [ 0.0, 0.0, 0.0 ] ); + + out = dsymv( '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 Float64Array( rxnyn.A ); + x = new Float64Array( rxnyn.x ); + y = new Float64Array( rxnyn.y ); + + expected = new Float64Array( rxnyn.y_out ); + + out = dsymv( 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 Float64Array( cxnyn.A ); + x = new Float64Array( cxnyn.x ); + y = new Float64Array( cxnyn.y ); + + expected = new Float64Array( cxnyn.y_out ); + + out = dsymv( 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(); +}); From cc46325ba998163c3b09027a0f9b899c1e25482b Mon Sep 17 00:00:00 2001 From: aman-095 Date: Wed, 26 Jun 2024 12:40:46 +0530 Subject: [PATCH 2/3] test: update descriptions --- .../@stdlib/blas/base/dsymv/test/test.dsymv.js | 16 ++++++++-------- .../@stdlib/blas/base/dsymv/test/test.ndarray.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js index 2d10edaa1793..c0118a154b51 100644 --- a/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js +++ b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.dsymv.js @@ -220,7 +220,7 @@ tape( 'the function throws an error if provided an invalid eleventh argument', f } }); -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 ) { +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; @@ -240,7 +240,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -260,7 +260,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -280,7 +280,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -300,7 +300,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -320,7 +320,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -340,7 +340,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -360,7 +360,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js index 5c7c3fd2b13c..c6c7028ad0fb 100644 --- a/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsymv/test/test.ndarray.js @@ -220,7 +220,7 @@ tape( 'the function throws an error if provided an invalid twelfth argument', fu } }); -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 ) { +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; @@ -240,7 +240,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -260,7 +260,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -280,7 +280,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -300,7 +300,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -320,7 +320,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -340,7 +340,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; @@ -360,7 +360,7 @@ tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y 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 ) { +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; From 32e2fd0c84cefde1c4d98084eac39586c16afeca Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 26 Jun 2024 17:30:34 -0700 Subject: [PATCH 3/3] style: remove unnecessary parentheses --- .../@stdlib/blas/base/dsymv/lib/dsymv.js | 16 ++++++++-------- .../@stdlib/blas/base/dsymv/lib/ndarray.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js index d41be1ab6a6a..b34af44bc491 100644 --- a/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js +++ b/lib/node_modules/@stdlib/blas/base/dsymv/lib/dsymv.js @@ -138,15 +138,15 @@ function dsymv( order, uplo, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { jmax = N; jx = ox + ( jmin*strideX ); jy = oy + ( jmin*strideY ); - y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + y[ iy ] += temp1 * A[ ( LDA * i ) + i ]; for ( j = jmin; j < jmax; j++ ) { k = ( LDA * i ) + j; - y[ jy ] += ( temp1 * A[ k ] ); - temp2 += ( x[ jx ] * A[ k ] ); + y[ jy ] += temp1 * A[ k ]; + temp2 += x[ jx ] * A[ k ]; jx += strideX; jy += strideY; } - y[ iy ] += ( alpha * temp2 ); + y[ iy ] += alpha * temp2; ix += strideX; iy += strideY; } @@ -162,15 +162,15 @@ function dsymv( order, uplo, N, alpha, A, LDA, x, strideX, beta, y, strideY ) { jmax = i; jx = ox + ( jmin * strideX ); jy = oy + ( jmin * strideY ); - y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + y[ iy ] += temp1 * A[ ( LDA * i ) + i ]; for ( j = jmin; j < jmax; j++ ) { k = ( LDA * i ) + j; - y[ jy ] += ( temp1 * A[ k ] ); - temp2 += ( x[ jx ] * A[ k ] ); + y[ jy ] += temp1 * A[ k ]; + temp2 += x[ jx ] * A[ k ]; jx += strideX; jy += strideY; } - y[ iy ] += ( alpha * temp2 ); + y[ iy ] += alpha * temp2; ix -= strideX; iy -= strideY; } diff --git a/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js index 887b44fbc326..f44649171e3a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsymv/lib/ndarray.js @@ -127,15 +127,15 @@ function dsymv( order, uplo, N, alpha, A, LDA, x, strideX, offsetX, beta, y, str jmax = N; jx = ox + ( jmin * strideX ); jy = oy + ( jmin * strideY ); - y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + y[ iy ] += temp1 * A[ ( LDA * i ) + i ]; for ( j = jmin; j < jmax; j++ ) { k = ( LDA * i ) + j; - y[ jy ] += ( temp1 * A[ k ] ); - temp2 += ( x[ jx ] * A[ k ] ); + y[ jy ] += temp1 * A[ k ]; + temp2 += x[ jx ] * A[ k ]; jx += strideX; jy += strideY; } - y[ iy ] += ( alpha * temp2 ); + y[ iy ] += alpha * temp2; ix += strideX; iy += strideY; } @@ -151,15 +151,15 @@ function dsymv( order, uplo, N, alpha, A, LDA, x, strideX, offsetX, beta, y, str jmax = i; jx = ox + ( jmin * strideX ); jy = oy + ( jmin * strideY ); - y[ iy ] += ( temp1 * A[ ( LDA * i ) + i ] ); + y[ iy ] += temp1 * A[ ( LDA * i ) + i ]; for ( j = jmin; j < jmax; j++ ) { k = ( LDA * i ) + j; - y[ jy ] += ( temp1 * A[ k ] ); - temp2 += ( x[ jx ] * A[ k ] ); + y[ jy ] += temp1 * A[ k ]; + temp2 += x[ jx ] * A[ k ]; jx += strideX; jy += strideY; } - y[ iy ] += ( alpha * temp2 ); + y[ iy ] += alpha * temp2; ix -= strideX; iy -= strideY; }