From 487cf574ecb216ee54758e186b53338553526bc4 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 20 Jun 2024 22:53:01 +0530 Subject: [PATCH 01/19] feat: add BLAS Level 2 routine for sspmv --- .../@stdlib/blas/base/sspmv/README.md | 265 +++++++++++ .../blas/base/sspmv/benchmark/benchmark.js | 105 +++++ .../base/sspmv/benchmark/benchmark.ndarray.js | 105 +++++ .../@stdlib/blas/base/sspmv/docs/repl.txt | 155 +++++++ .../blas/base/sspmv/docs/types/index.d.ts | 132 ++++++ .../blas/base/sspmv/docs/types/test.ts | 432 ++++++++++++++++++ .../@stdlib/blas/base/sspmv/examples/index.js | 35 ++ .../@stdlib/blas/base/sspmv/lib/index.js | 72 +++ .../@stdlib/blas/base/sspmv/lib/main.js | 35 ++ .../@stdlib/blas/base/sspmv/lib/ndarray.js | 162 +++++++ .../@stdlib/blas/base/sspmv/lib/sspmv.js | 168 +++++++ .../@stdlib/blas/base/sspmv/package.json | 68 +++ .../base/sspmv/test/fixtures/julia/REQUIRE | 2 + .../test/fixtures/julia/strides_xnyn.json | 13 + .../test/fixtures/julia/strides_xnyp.json | 13 + .../test/fixtures/julia/strides_xoyt.json | 13 + .../test/fixtures/julia/strides_xpyn.json | 13 + .../test/fixtures/julia/strides_xpyp.json | 13 + .../@stdlib/blas/base/sspmv/test/test.js | 82 ++++ .../blas/base/sspmv/test/test.ndarray.js | 297 ++++++++++++ .../blas/base/sspmv/test/test.sspmv.js | 297 ++++++++++++ 21 files changed, 2477 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md new file mode 100644 index 00000000000..2fb9b2f28bd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -0,0 +1,265 @@ + + +# sspmv + +> Perform one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form AP. + +
+ +## Usage + +```javascript +var sspmv = require( '@stdlib/blas/base/sspmv' ); +``` + +#### sspmv( ord, uplo, N, α, AP, x, sx, β, y, sy ) + +Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form AP. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var sspmv = require( '@stdlib/blas/base/sspmv' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); +// y => [ 7.0, 12.0, 15.0 ] +``` + +The function has the following parameters: + +- **ord**: storage layout. +- **uplo**: specifies the operation to be performed. +- **N**: specifies the order of the matrix `A`. +- **α**: scalar constant. +- **AP**: packed form of symmetric matrix `A` [`Float32Array`][mdn-float32array]. +- **x**: input [`Float32Array`][mdn-float32array]. +- **sx**: index increment for `x`. +- **β**: scalar constant. +- **y**: output [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. + +The stride parameters determine how operations are performed. For example, to +perform one of the matrix-vector operations starting from the second index of `x`, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, -1 ); +// y => [ 15.0, 12.0, 7.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 1.0, 1.0 ] ); +var AP = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); // start at 1st element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); // start at 1st element + +sspmv( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 ); +// y0 => [ 6.0, 4.0 ] +``` + +#### sspmv.ndarray( ord, uplo, N, α, AP, x, sx, ox, β, y, sy, oy ) + +Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); +var sspmv = require( '@stdlib/blas/base/sspmv' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); +// y => [ 7.0, 12.0, 15.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to perform operation with given `x` and `y` offset values`,..., + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + +sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, -1, 2 ); +// y => [ 15.0, 12.0, 7.0 ] +``` + +
+ + + +
+ +## Notes + +- `sspmv()` corresponds to the [BLAS][blas] level 2 function [`sspmv`][sspmv]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sspmv = require( '@stdlib/blas/base/sspmv' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); + +var x = discreteUniform( N, -10, 10, opts ); +var y = discreteUniform( N, -10, 10, opts ); + +sspmv.ndarray( 'row-major', 'upper', N, 1.0, A, 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/sspmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js new file mode 100644 index 00000000000..ea92435d2d8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sspmv = require( './../lib/sspmv.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var AP = uniform( ( ( len ) * ( len + 1 ) / 2 ), -10.0, 10.0, options ); + var x = uniform( len, -10.0, 10.0, options ); + var y = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sspmv( 'row-major', 'upper', len, 1.0, AP, x, 1, 1.0, y, 1 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':size='+( ( len ) * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..f039ab7ccfc --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var sspmv = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var AP = uniform( ( ( len ) * ( len + 1 ) / 2 ), -10.0, 10.0, options ); + var x = uniform( len, -10.0, 10.0, options ); + var y = uniform( len, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = sspmv( 'row-major', 'upper', len, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( len ); + bench( pkg+':ndarray:size='+( ( len ) * ( len + 1 ) / 2 ), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt new file mode 100644 index 00000000000..eeb0dcdd3a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt @@ -0,0 +1,155 @@ + +{{alias}}( ord, uplo, N, α, A, x, sx, β, y, sy ) + Perform one of the matrix-vector operations `y = α*A*x + β*y` + where α and β are scalars, x and y are n element vectors and A is + an n by n symmetric matrix, supplied in packed form. + + The stride parameters determine how operations are performed. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is equal to `0`, the function returns `y` unchanged. + + If `α` equals `0.0` and β equals `1.0`, the function returns `y` + unchanged. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. + + uplo: string + Specifies whether `A` is upper or lower triangular matrix. + + N: integer + Specifies the order of the matrix `A`. + + α: number + Scalar constant. + + A: Float32Array + Matrix. + + x: Float32Array + Input vector `x`. + + sx: integer + Index increment for `x`. + + β: number + Scalar constant. + + y: Float32Array + Input/output vector `y`. + + sy: integer + Index increment for `y`. + + Returns + ------- + y: Float32Array + Output array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x, 1, 1.0, y, 1 ) + [ ~4.0, ~6.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x, -1, 1.0, y, -1 ) + [ ~6.0, ~4.0 ] + + // Using typed array views: + > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); + > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x1, -1, 1.0, y1, -1 ) + > y0 + [ ~6.0, ~4.0 ] + + +{{alias}}.ndarray( ord, uplo, N, α, A, x, sx, ox, β, y, sy, oy ) + Perform one of the matrix-vector operations `y = α*A*x + β*y` + where α and β are scalars, x and y are n element vectors and A is + an n by n symmetric matrix, supplied in packed form using alternative + indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + ord: string + Row-major (C-style) or column-major (Fortran-style) order. + + uplo: string + Specifies whether `A` is upper or lower triangular matrix. + + N: integer + Specifies the order of the matrix `A`. + + α: number + Scalar. + + A: Float32Array + Matrix. + + x: Float32Array + Input vector `x`. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + β: number + Scalar. + + y: Float32Array + Input/output vector `y`. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + Returns + ------- + y: Float32Array + Output array. + + Examples + -------- + // Standard usage: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var ord = 'row-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( ord, uplo, 2, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ) + [ ~4.0, ~6.0 ] + + // Advanced indexing: + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var ord = 'row-major'; + > var uplo = 'upper'; + > {{alias}}.ndarray( ord, uplo, 2, 1.0, A, x, -1, 1, 1.0, y, -1, 1 ) + [ ~6.0, ~4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts new file mode 100644 index 00000000000..76f27c18abd --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts @@ -0,0 +1,132 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Storage layouts. +*/ +type Order = 'row-major' | 'column-major'; + +/** +* Upper or lower triangular indicator. +*/ +type UPLO = 'upper' | 'lower'; + +/** +* Interface describing `sspmv`. +*/ +interface Routine { + /** + * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param N - number of columns in the matrix `A` + * @param alpha - scalar constant + * @param AP - packed form of symmetric matrix `A` + * @param x - first input array + * @param strideX - `x` stride length + * @param beta - scalar constant + * @param y - second input array + * @param strideY - `y` stride length + * @returns output array `y` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * + * sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); + * // y => [ 8.0, 11.0, 16.0 ] + */ + ( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + + /** + * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied + * @param N - number of columns in the matrix `A` + * @param alpha - scalar constant + * @param AP - packed form of symmetric matrix `A` + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - `x` index offset + * @param beta - scalar constant + * @param y - second input array + * @param strideY - `y` stride length + * @param offsetY - `y` index offset + * @returns output array `y` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); + * + * sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); + * // y => [ 8.0, 11.0, 16.0 ] + */ + ndarray( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; +} + +/** +* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied +* @param N - number of columns in the matrix `A` +* @param alpha - scalar constant +* @param AP - packed form of symmetric matrix `A` +* @param x - first input array +* @param strideX - `x` stride length +* @param beta - scalar constant +* @param y - second input array +* @param strideY - `y` stride length +* @returns output array `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, -1 ); +* // y => [ 15.0, 12.0, 7.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, -1, 2 ); +* // y => [ 15.0, 12.0, 7.0 ] +*/ +declare var sspmv: Routine; + + +// EXPORTS // + +export = sspmv; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts new file mode 100644 index 00000000000..71a6ccfe400 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts @@ -0,0 +1,432 @@ +/* +* @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 sspmv = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 10, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( true, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( false, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( null, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( undefined, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( [], 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( {}, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( ( x: number ): number => x, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 10, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', true, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', false, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', null, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', undefined, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', [ '1' ], 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', {}, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', ( x: number ): number => x, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', '10', 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', true, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', false, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', null, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', undefined, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', [], 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', {}, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', ( x: number ): number => x, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, '10', A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, true, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, false, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, null, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, undefined, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, [], A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, {}, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, ( x: number ): number => x, A, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sspmv( 'row-major', 'upper', 10, 1.0, 10, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, '10', x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, true, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, false, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, null, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, [ '1' ], x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, {}, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, 10, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, '10', 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, true, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, false, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, null, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, undefined, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, {}, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, 1, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, x, '10', 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, true, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, false, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, null, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, undefined, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, [], 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, {}, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, '10', y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, true, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, false, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, null, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, undefined, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, [], y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, {}, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, ( x: number ): number => x, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, 10, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, '10', 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, true, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, false, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, null, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, undefined, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, {}, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, ( x: number ): number => x, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an tenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, '10' ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, true ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, false ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, null ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, undefined ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, [] ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, {} ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv(); // $ExpectError + sspmv( 'row-major' ); // $ExpectError + sspmv( 'row-major', 'upper' ); // $ExpectError + sspmv( 'row-major', 'upper', 10 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, 1, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 10, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( true, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( false, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( null, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( undefined, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( [], 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( {}, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( ( x: number ): number => x, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 10, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', true, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', false, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', null, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', undefined, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', [ '1' ], 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', {}, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', ( x: number ): number => x, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', '10', 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', true, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', false, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', null, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', undefined, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', [], 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', {}, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', ( x: number ): number => x, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, '10', A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, true, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, false, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, null, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, undefined, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, [], A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, {}, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, ( x: number ): number => x, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, 10, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, '10', x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, 10, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, '10', 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an seventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, '10', 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, true, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, false, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, null, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, [], 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, {}, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, ( x: number ): number => x, 0, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, '10', 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, true, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, false, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, null, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, [], 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, {}, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, '10', y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, true, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, false, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, null, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, [], y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, {}, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, ( x: number ): number => x, y, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an tenth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, 10, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, '10', 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, '10', 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, '10' ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, true ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, false ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, null ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 55 ); + + sspmv.ndarray(); // $ExpectError + sspmv.ndarray( 'row-major' ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper' ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js new file mode 100644 index 00000000000..c8f8350414a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var sspmv = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; +var A = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); + +var x = discreteUniform( N, -10, 10, opts ); +var y = discreteUniform( N, -10, 10, opts ); + +sspmv.ndarray( 'row-major', 'upper', N, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); +console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js new file mode 100644 index 00000000000..1657b8162ff --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/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, supplied in packed form. +* +* @module @stdlib/blas/base/sspmv +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sspmv = require( '@stdlib/blas/base/sspmv' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); +* // y => [ ~8.0, ~11.0, ~16.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var sspmv = require( '@stdlib/blas/base/sspmv' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); +* // y => [ ~8.0, ~11.0, ~16.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 sspmv; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + sspmv = main; +} else { + sspmv = tmp; +} + + +// EXPORTS // + +module.exports = sspmv; + +// exports: { "ndarray": "sspmv.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/main.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/main.js new file mode 100644 index 00000000000..c74ce24fae5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/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 sspmv = require( './sspmv.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( sspmv, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = sspmv; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js new file mode 100644 index 00000000000..3e01d84a1b7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js @@ -0,0 +1,162 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var sfill = require( '@stdlib/blas/ext/base/sfill' ); +var sscal = require( '@stdlib/blas/base/sscal' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix, supplied in packed form. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} AP - packed form of symmetric matrix `A` +* @param {Float32Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - `x` index offset +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input array +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - `y` index offset +* @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} seventh argument must be non-zero +* @throws {RangeError} eleventh argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); +* // y => [ ~7.0, ~12.0, ~15.0 ] +*/ +function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params + var temp1; + var temp2; + var ix; + var iy; + var jx; + var jy; + var kk; + var kx; + var ky; + var sy; + 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 ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Form: y = beta*y + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + if ( strideY < 0 ) { + sy = strideY * ( -1 ); + } + sscal( N, beta, y, sy ); + } + } + if ( alpha === 0.0 ) { + return y; + } + kx = offsetX; + ky = offsetY; + kk = 0; + if ( + ( order === 'row-major' && uplo === 'upper' ) || + ( order === 'column-major' && uplo === 'lower' ) + ) { + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + y[ jy ] += f32( temp1 * AP[ kk ] ); + ix = jx; + iy = jy; + for ( k = ( kk + 1 ); k < ( kk + N - j ); k++ ) { + ix += strideX; + iy += strideY; + y[ iy ] += f32( temp1 * AP[ k ] ); + temp2 += f32( AP[ k ] * x[ ix ] ); + } + y[ jy ] += f32( alpha * temp2 ); + jx += strideX; + jy += strideY; + kk += N - j; + } + return y; + } + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + ix = kx; + iy = ky; + for ( k = kk; k < ( kk + j ); k++ ) { + y[ iy ] += f32( temp1 * AP[ k ] ); + temp2 += f32( AP[ k ] * x[ ix ] ); + ix += strideX; + iy += strideY; + } + y[ jy ] += f32( f32( temp1 * AP[ kk + j ] ) + f32( alpha * temp2 ) ); + jx += strideX; + jy += strideY; + kk += j + 1; + } + return y; +} + + +// EXPORTS // + +module.exports = sspmv; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js new file mode 100644 index 00000000000..6f93ede1dab --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js @@ -0,0 +1,168 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var sfill = require( '@stdlib/blas/ext/base/sfill' ); +var sscal = require( '@stdlib/blas/base/sscal' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); + + +// MAIN // + +/** +* Performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix, supplied in packed form. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar constant +* @param {Float32Array} AP - packed form of symmetric matrix `A` +* @param {Float32Array} x - first input array +* @param {integer} strideX - `x` stride length +* @param {number} beta - scalar constant +* @param {Float32Array} y - second input array +* @param {integer} strideY - `y` stride length +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} seventh argument must be non-zero +* @throws {RangeError} tenth argument must be non-zero +* @returns {Float32Array} `y` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +* +* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); +* // y => [ ~7.0, ~12.0, ~15.0 ] +*/ +function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { + var temp1; + var temp2; + var ix; + var iy; + var jx; + var jy; + var kk; + var kx; + var ky; + var sy; + 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 ( strideX === 0 ) { + throw new RangeError( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideX ); + } + if ( strideY === 0 ) { + throw new RangeError( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideY ); + } + if ( N === 0 || ( alpha === 0.0 && beta === 1.0 ) ) { + return y; + } + // Form: y = beta*y + if ( beta !== 1.0 ) { + if ( beta === 0.0 ) { + sfill( N, 0.0, y, strideY ); + } else { + if ( strideY < 0 ) { + sy = strideY * ( -1 ); + } + sscal( N, beta, y, sy ); + } + } + if ( alpha === 0.0 ) { + return y; + } + if ( strideX > 0 ) { + kx = 0; + } else { + kx = ( 1 - N ) * strideX; + } + if ( strideY > 0 ) { + ky = 0; + } else { + ky = ( 1 - N ) * strideY; + } + kk = 0; + if ( + ( order === 'row-major' && uplo === 'upper' ) || + ( order === 'column-major' && uplo === 'lower' ) + ) { + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + y[ jy ] += f32( temp1 * AP[ kk ] ); + ix = jx; + iy = jy; + for ( k = ( kk + 1 ); k < ( kk + N - j ); k++ ) { + ix += strideX; + iy += strideY; + y[ iy ] += f32( temp1 * AP[ k ] ); + temp2 += f32( AP[ k ] * x[ ix ] ); + } + y[ jy ] += f32( alpha * temp2 ); + jx += strideX; + jy += strideY; + kk += N - j; + } + return y; + } + jx = kx; + jy = ky; + for ( j = 0; j < N; j++ ) { + temp1 = f32( alpha * x[ jx ] ); + temp2 = 0.0; + ix = kx; + iy = ky; + for ( k = kk; k < ( kk + j ); k++ ) { + y[ iy ] += f32( temp1 * AP[ k ] ); + temp2 += f32( AP[ k ] * x[ ix ] ); + ix += strideX; + iy += strideY; + } + y[ jy ] += f32( f32( temp1 * AP[ kk + j ] ) + f32( alpha * temp2 ) ); + jx += strideX; + jy += strideY; + kk += j + 1; + } + return y; +} + + +// EXPORTS // + +module.exports = sspmv; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/package.json b/lib/node_modules/@stdlib/blas/base/sspmv/package.json new file mode 100644 index 00000000000..48af1a9b22d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/sspmv", + "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, supplied in packed form.", + "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", + "sspmv", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE new file mode 100644 index 00000000000..308c3be89c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json new file mode 100644 index 00000000000..ee5f65b1ef5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json @@ -0,0 +1,13 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": -1, + "strideY": -1, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 15.0, 12.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json new file mode 100644 index 00000000000..a93ec1bd65c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json @@ -0,0 +1,13 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": -1, + "strideY": 1, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 7.0, 12.0, 15.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json new file mode 100644 index 00000000000..5383cc6a151 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json @@ -0,0 +1,13 @@ +{ + "uplo": "lower", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "strideY": 2, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 8.0, 1.0, 11.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json new file mode 100644 index 00000000000..2949c1e47c8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json @@ -0,0 +1,13 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "strideY": -1, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 15.0, 12.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json new file mode 100644 index 00000000000..843b27c2a9b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json @@ -0,0 +1,13 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "strideY": 1, + "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 8.0, 11.0, 16.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.js new file mode 100644 index 00000000000..5385cb2ef23 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/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 sspmv = 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 sspmv, '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 sspmv.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 sspmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sspmv, 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 sspmv; + var main; + + main = require( './../lib/sspmv.js' ); + + sspmv = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( sspmv, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js new file mode 100644 index 00000000000..d5f490a2c85 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js @@ -0,0 +1,297 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sspmv = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var stridexoyt = require( './fixtures/julia/strides_xoyt.json' ); +var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); +var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); +var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); +var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sspmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 12', function test( t ) { + t.strictEqual( sspmv.length, 12, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=1)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + expected = new Float32Array( stridexpyp.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=2)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexoyt.order; + uplo = stridexoyt.uplo; + + n = stridexoyt.N; + + strideX = stridexoyt.strideX; + strideY = stridexoyt.strideY; + + alpha = stridexoyt.alpha; + beta = stridexoyt.beta; + + a = new Float32Array( stridexoyt.A ); + x = new Float32Array( stridexoyt.x ); + y = new Float32Array( stridexoyt.y ); + + expected = new Float32Array( stridexoyt.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexnyp.order; + uplo = stridexnyp.uplo; + + n = stridexnyp.N; + + strideX = stridexnyp.strideX; + strideY = stridexnyp.strideY; + + alpha = stridexnyp.alpha; + beta = stridexnyp.beta; + + a = new Float32Array( stridexnyp.A ); + x = new Float32Array( stridexnyp.x ); + y = new Float32Array( stridexnyp.y ); + + expected = new Float32Array( stridexnyp.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 2, beta, y, strideY, 0 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyn.order; + uplo = stridexpyn.uplo; + + n = stridexpyn.N; + + strideX = stridexpyn.strideX; + strideY = stridexpyn.strideY; + + alpha = stridexpyn.alpha; + beta = stridexpyn.beta; + + a = new Float32Array( stridexpyn.A ); + x = new Float32Array( stridexpyn.x ); + y = new Float32Array( stridexpyn.y ); + + expected = new Float32Array( stridexpyn.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 2 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input array', function test( t ) { + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexnyn.order; + uplo = stridexnyn.uplo; + + n = stridexnyn.N; + + strideX = stridexnyn.strideX; + strideY = stridexnyn.strideY; + + alpha = stridexnyn.alpha; + beta = stridexnyn.beta; + + a = new Float32Array( stridexnyn.A ); + x = new Float32Array( stridexnyn.x ); + y = new Float32Array( stridexnyn.y ); + + expected = new Float32Array( stridexnyn.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, 2, beta, y, strideY, 2 ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js new file mode 100644 index 00000000000..be52a0e82e5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js @@ -0,0 +1,297 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var sspmv = require( './../lib/sspmv.js' ); + + +// FIXTURES // + +var stridexoyt = require( './fixtures/julia/strides_xoyt.json' ); +var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); +var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); +var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); +var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof sspmv, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( sspmv.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=1)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + expected = new Float32Array( stridexpyp.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=2)', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexoyt.order; + uplo = stridexoyt.uplo; + + n = stridexoyt.N; + + strideX = stridexoyt.strideX; + strideY = stridexoyt.strideY; + + alpha = stridexoyt.alpha; + beta = stridexoyt.beta; + + a = new Float32Array( stridexoyt.A ); + x = new Float32Array( stridexoyt.x ); + y = new Float32Array( stridexoyt.y ); + + expected = new Float32Array( stridexoyt.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `x` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexnyp.order; + uplo = stridexnyp.uplo; + + n = stridexnyp.N; + + strideX = stridexnyp.strideX; + strideY = stridexnyp.strideY; + + alpha = stridexnyp.alpha; + beta = stridexnyp.beta; + + a = new Float32Array( stridexnyp.A ); + x = new Float32Array( stridexnyp.x ); + y = new Float32Array( stridexnyp.y ); + + expected = new Float32Array( stridexnyp.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports a negative `y` stride', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyn.order; + uplo = stridexpyn.uplo; + + n = stridexpyn.N; + + strideX = stridexpyn.strideX; + strideY = stridexpyn.strideY; + + alpha = stridexpyn.alpha; + beta = stridexpyn.beta; + + a = new Float32Array( stridexpyn.A ); + x = new Float32Array( stridexpyn.x ); + y = new Float32Array( stridexpyn.y ); + + expected = new Float32Array( stridexpyn.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns a reference to the second input array', function test( t ) { + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexpyp.order; + uplo = stridexpyp.uplo; + + n = stridexpyp.N; + + strideX = stridexpyp.strideX; + strideY = stridexpyp.strideY; + + alpha = stridexpyp.alpha; + beta = stridexpyp.beta; + + a = new Float32Array( stridexpyp.A ); + x = new Float32Array( stridexpyp.x ); + y = new Float32Array( stridexpyp.y ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports complex access patterns', function test( t ) { + var expected; + var strideX; + var strideY; + var alpha; + var order; + var beta; + var uplo; + var out; + var a; + var n; + var x; + var y; + + order = stridexnyn.order; + uplo = stridexnyn.uplo; + + n = stridexnyn.N; + + strideX = stridexnyn.strideX; + strideY = stridexnyn.strideY; + + alpha = stridexnyn.alpha; + beta = stridexnyn.beta; + + a = new Float32Array( stridexnyn.A ); + x = new Float32Array( stridexnyn.x ); + y = new Float32Array( stridexnyn.y ); + + expected = new Float32Array( stridexnyn.y_out ); + + out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + isApprox( t, y, expected, 2.0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.end(); +}); From a175a7cd54b39edea6115e221d0cefcdb00ff080 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 20 Jun 2024 23:04:34 +0530 Subject: [PATCH 02/19] docs: update description --- .../@stdlib/blas/base/sspmv/README.md | 4 +-- .../blas/base/sspmv/docs/types/index.d.ts | 24 ++++++------- .../@stdlib/blas/base/sspmv/examples/index.js | 4 +-- .../@stdlib/blas/base/sspmv/lib/index.js | 12 +++---- .../@stdlib/blas/base/sspmv/lib/sspmv.js | 4 +-- .../test/fixtures/julia/strides_xnyn.json | 2 +- .../test/fixtures/julia/strides_xnyp.json | 2 +- .../test/fixtures/julia/strides_xoyt.json | 2 +- .../test/fixtures/julia/strides_xpyn.json | 2 +- .../test/fixtures/julia/strides_xpyp.json | 2 +- .../blas/base/sspmv/test/test.ndarray.js | 36 +++++++++---------- .../blas/base/sspmv/test/test.sspmv.js | 36 +++++++++---------- 12 files changed, 65 insertions(+), 65 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index 2fb9b2f28bd..0f0e5c9e060 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -156,12 +156,12 @@ var opts = { }; var N = 3; -var A = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); +var AP = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); var x = discreteUniform( N, -10, 10, opts ); var y = discreteUniform( N, -10, 10, opts ); -sspmv.ndarray( 'row-major', 'upper', N, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); +sspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); console.log( y ); ``` diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts index 76f27c18abd..8a08729f0bd 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts @@ -50,14 +50,14 @@ interface Routine { * @example * var Float32Array = require( '@stdlib/array/float32' ); * - * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * - * sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); - * // y => [ 8.0, 11.0, 16.0 ] + * sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); + * // y => [ 7.0, 12.0, 15.0 ] */ - ( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + ( order: Order, uplo: UPLO, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. @@ -79,14 +79,14 @@ interface Routine { * @example * var Float32Array = require( '@stdlib/array/float32' ); * - * var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * - * sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); - * // y => [ 8.0, 11.0, 16.0 ] + * sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); + * // y => [ 7.0, 12.0, 15.0 ] */ - ndarray( order: Order, uplo: UPLO, N: number, k: number, alpha: number, A: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; + ndarray( order: Order, uplo: UPLO, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; } /** @@ -107,21 +107,21 @@ interface Routine { * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * -* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, -1 ); +* sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, -1 ); * // y => [ 15.0, 12.0, 7.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * -* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, -1, 2 ); +* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, -1, 2 ); * // y => [ 15.0, 12.0, 7.0 ] */ declare var sspmv: Routine; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js index c8f8350414a..0390e59d7a7 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js @@ -26,10 +26,10 @@ var opts = { }; var N = 3; -var A = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); +var AP = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); var x = discreteUniform( N, -10, 10, opts ); var y = discreteUniform( N, -10, 10, opts ); -sspmv.ndarray( 'row-major', 'upper', N, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); +sspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); console.log( y ); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js index 1657b8162ff..2281ee60285 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js @@ -27,23 +27,23 @@ * var Float32Array = require( '@stdlib/array/float32' ); * var sspmv = require( '@stdlib/blas/base/sspmv' ); * -* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * -* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); -* // y => [ ~8.0, ~11.0, ~16.0 ] +* sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); +* // y => [ ~7.0, ~12.0, ~15.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); * var sspmv = require( '@stdlib/blas/base/sspmv' ); * -* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * -* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); -* // y => [ ~8.0, ~11.0, ~16.0 ] +* sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); +* // y => [ ~7.0, ~12.0, ~15.0 ] */ // MODULES // diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js index 6f93ede1dab..8877235ad33 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js @@ -52,11 +52,11 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * @example * var Float32Array = require( '@stdlib/array/float32' ); * -* var A = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); +* var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); * var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * var y = new Float32Array( [ 1.0, 1.0, 1.0 ] ); * -* sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 1.0, y, 1 ); +* sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); * // y => [ ~7.0, ~12.0, ~15.0 ] */ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json index ee5f65b1ef5..80315f037c9 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json @@ -6,7 +6,7 @@ "beta": 1.0, "strideX": -1, "strideY": -1, - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], "y_out": [ 15.0, 12.0, 7.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json index a93ec1bd65c..6f71afa6ef8 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json @@ -6,7 +6,7 @@ "beta": 1.0, "strideX": -1, "strideY": 1, - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], "y_out": [ 7.0, 12.0, 15.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json index 5383cc6a151..bd3e1dc7694 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json @@ -6,7 +6,7 @@ "beta": 1.0, "strideX": 1, "strideY": 2, - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], "y_out": [ 8.0, 1.0, 11.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json index 2949c1e47c8..d853cfa26cf 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json @@ -6,7 +6,7 @@ "beta": 1.0, "strideX": 1, "strideY": -1, - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], "y_out": [ 15.0, 12.0, 7.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json index 843b27c2a9b..74571017498 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json @@ -6,7 +6,7 @@ "beta": 1.0, "strideX": 1, "strideY": 1, - "A": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], "y_out": [ 8.0, 11.0, 16.0 ] diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js index d5f490a2c85..ac8b4f20270 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js @@ -87,7 +87,7 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -103,13 +103,13 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o alpha = stridexpyp.alpha; beta = stridexpyp.beta; - a = new Float32Array( stridexpyp.A ); + ap = new Float32Array( stridexpyp.AP ); x = new Float32Array( stridexpyp.x ); y = new Float32Array( stridexpyp.y ); expected = new Float32Array( stridexpyp.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -124,7 +124,7 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -140,13 +140,13 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o alpha = stridexoyt.alpha; beta = stridexoyt.beta; - a = new Float32Array( stridexoyt.A ); + ap = new Float32Array( stridexoyt.AP ); x = new Float32Array( stridexoyt.x ); y = new Float32Array( stridexoyt.y ); expected = new Float32Array( stridexoyt.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -161,7 +161,7 @@ tape( 'the function supports a negative `x` stride', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -177,13 +177,13 @@ tape( 'the function supports a negative `x` stride', function test( t ) { alpha = stridexnyp.alpha; beta = stridexnyp.beta; - a = new Float32Array( stridexnyp.A ); + ap = new Float32Array( stridexnyp.AP ); x = new Float32Array( stridexnyp.x ); y = new Float32Array( stridexnyp.y ); expected = new Float32Array( stridexnyp.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 2, beta, y, strideY, 0 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 2, beta, y, strideY, 0 ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -198,7 +198,7 @@ tape( 'the function supports a negative `y` stride', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -214,13 +214,13 @@ tape( 'the function supports a negative `y` stride', function test( t ) { alpha = stridexpyn.alpha; beta = stridexpyn.beta; - a = new Float32Array( stridexpyn.A ); + ap = new Float32Array( stridexpyn.AP ); x = new Float32Array( stridexpyn.x ); y = new Float32Array( stridexpyn.y ); expected = new Float32Array( stridexpyn.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 2 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 2 ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -234,7 +234,7 @@ tape( 'the function returns a reference to the second input array', function tes var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -250,11 +250,11 @@ tape( 'the function returns a reference to the second input array', function tes alpha = stridexpyp.alpha; beta = stridexpyp.beta; - a = new Float32Array( stridexpyp.A ); + ap = new Float32Array( stridexpyp.AP ); x = new Float32Array( stridexpyp.x ); y = new Float32Array( stridexpyp.y ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 0, beta, y, strideY, 0 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); }); @@ -268,7 +268,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -284,13 +284,13 @@ tape( 'the function supports complex access patterns', function test( t ) { alpha = stridexnyn.alpha; beta = stridexnyn.beta; - a = new Float32Array( stridexnyn.A ); + ap = new Float32Array( stridexnyn.AP ); x = new Float32Array( stridexnyn.x ); y = new Float32Array( stridexnyn.y ); expected = new Float32Array( stridexnyn.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, 2, beta, y, strideY, 2 ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, 2, beta, y, strideY, 2 ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js index be52a0e82e5..529149a0619 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js @@ -87,7 +87,7 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -103,13 +103,13 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o alpha = stridexpyp.alpha; beta = stridexpyp.beta; - a = new Float32Array( stridexpyp.A ); + ap = new Float32Array( stridexpyp.AP ); x = new Float32Array( stridexpyp.x ); y = new Float32Array( stridexpyp.y ); expected = new Float32Array( stridexpyp.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -124,7 +124,7 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -140,13 +140,13 @@ tape( 'the function performs one of the matrix-vector operations matrix-vector o alpha = stridexoyt.alpha; beta = stridexoyt.beta; - a = new Float32Array( stridexoyt.A ); + ap = new Float32Array( stridexoyt.AP ); x = new Float32Array( stridexoyt.x ); y = new Float32Array( stridexoyt.y ); expected = new Float32Array( stridexoyt.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -161,7 +161,7 @@ tape( 'the function supports a negative `x` stride', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -177,13 +177,13 @@ tape( 'the function supports a negative `x` stride', function test( t ) { alpha = stridexnyp.alpha; beta = stridexnyp.beta; - a = new Float32Array( stridexnyp.A ); + ap = new Float32Array( stridexnyp.AP ); x = new Float32Array( stridexnyp.x ); y = new Float32Array( stridexnyp.y ); expected = new Float32Array( stridexnyp.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -198,7 +198,7 @@ tape( 'the function supports a negative `y` stride', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -214,13 +214,13 @@ tape( 'the function supports a negative `y` stride', function test( t ) { alpha = stridexpyn.alpha; beta = stridexpyn.beta; - a = new Float32Array( stridexpyn.A ); + ap = new Float32Array( stridexpyn.AP ); x = new Float32Array( stridexpyn.x ); y = new Float32Array( stridexpyn.y ); expected = new Float32Array( stridexpyn.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); @@ -234,7 +234,7 @@ tape( 'the function returns a reference to the second input array', function tes var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -250,11 +250,11 @@ tape( 'the function returns a reference to the second input array', function tes alpha = stridexpyp.alpha; beta = stridexpyp.beta; - a = new Float32Array( stridexpyp.A ); + ap = new Float32Array( stridexpyp.AP ); x = new Float32Array( stridexpyp.x ); y = new Float32Array( stridexpyp.y ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); t.strictEqual( out, y, 'returns expected value' ); t.end(); }); @@ -268,7 +268,7 @@ tape( 'the function supports complex access patterns', function test( t ) { var beta; var uplo; var out; - var a; + var ap; var n; var x; var y; @@ -284,13 +284,13 @@ tape( 'the function supports complex access patterns', function test( t ) { alpha = stridexnyn.alpha; beta = stridexnyn.beta; - a = new Float32Array( stridexnyn.A ); + ap = new Float32Array( stridexnyn.AP ); x = new Float32Array( stridexnyn.x ); y = new Float32Array( stridexnyn.y ); expected = new Float32Array( stridexnyn.y_out ); - out = sspmv( order, uplo, n, alpha, a, x, strideX, beta, y, strideY ); + out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); isApprox( t, y, expected, 2.0 ); t.strictEqual( out, y, 'returns expected value' ); t.end(); From ad4be75b68371fdaf7dfe3bf681119a487766dfc Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 21 Jun 2024 12:15:35 +0530 Subject: [PATCH 03/19] docs: remove trailing empty line --- lib/node_modules/@stdlib/blas/base/sspmv/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index 0f0e5c9e060..61ba451b091 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -163,7 +163,6 @@ var y = discreteUniform( N, -10, 10, opts ); sspmv.ndarray( 'row-major', 'upper', N, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); console.log( y ); - ``` From f5dbe8fbdf22948067f0aa81da3147b86b1d70a7 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 21 Jun 2024 14:19:38 +0530 Subject: [PATCH 04/19] test: refactor to add tests for column-major --- .../@stdlib/blas/base/sspmv/lib/ndarray.js | 14 +- .../@stdlib/blas/base/sspmv/lib/sspmv.js | 3 +- .../test/fixtures/column_major_xnyn.json | 15 + .../test/fixtures/column_major_xnyp.json | 15 + .../test/fixtures/column_major_xoyt.json | 15 + .../test/fixtures/column_major_xpyn.json | 15 + ...rides_xpyp.json => column_major_xpyp.json} | 2 + .../base/sspmv/test/fixtures/julia/REQUIRE | 2 - .../strides_xnyn.json => row_major_xnyn.json} | 2 + .../strides_xnyp.json => row_major_xnyp.json} | 2 + .../strides_xoyt.json => row_major_xoyt.json} | 2 + .../strides_xpyn.json => row_major_xpyn.json} | 2 + .../sspmv/test/fixtures/row_major_xpyp.json | 15 + .../blas/base/sspmv/test/test.ndarray.js | 517 +++++++++++++----- .../blas/base/sspmv/test/test.sspmv.js | 517 +++++++++++++----- 15 files changed, 876 insertions(+), 262 deletions(-) create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyn.json rename lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/{julia/strides_xpyp.json => column_major_xpyp.json} (88%) delete mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE rename lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/{julia/strides_xnyn.json => row_major_xnyn.json} (88%) rename lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/{julia/strides_xnyp.json => row_major_xnyp.json} (88%) rename lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/{julia/strides_xoyt.json => row_major_xoyt.json} (88%) rename lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/{julia/strides_xpyn.json => row_major_xpyn.json} (88%) create mode 100644 lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyp.json diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js index 3e01d84a1b7..c77d069e17f 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js @@ -20,8 +20,8 @@ // MODULES // -var sfill = require( '@stdlib/blas/ext/base/sfill' ); -var sscal = require( '@stdlib/blas/base/sscal' ); +var sfill = require( '@stdlib/blas/ext/base/sfill' ).ndarray; +var sscal = require( '@stdlib/blas/base/sscal' ).ndarray; var f32 = require( '@stdlib/number/float64/base/to-float32' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); @@ -71,7 +71,6 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY var kk; var kx; var ky; - var sy; var j; var k; @@ -88,7 +87,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY throw new RangeError( 'invalid argument. Seventh argument must be non-zero. Value: `%d`.', strideX ); } if ( strideY === 0 ) { - throw new RangeError( 'invalid argument. Tenth argument must be non-zero. Value: `%d`.', strideY ); + 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; @@ -96,12 +95,9 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY // Form: y = beta*y if ( beta !== 1.0 ) { if ( beta === 0.0 ) { - sfill( N, 0.0, y, strideY ); + sfill( N, 0.0, y, strideY, offsetY ); } else { - if ( strideY < 0 ) { - sy = strideY * ( -1 ); - } - sscal( N, beta, y, sy ); + sscal( N, beta, y, strideY, offsetY ); } } if ( alpha === 0.0 ) { diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js index 8877235ad33..ee1421ffe82 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js @@ -92,12 +92,13 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { return y; } // Form: y = beta*y + sy = strideY; if ( beta !== 1.0 ) { if ( beta === 0.0 ) { sfill( N, 0.0, y, strideY ); } else { if ( strideY < 0 ) { - sy = strideY * ( -1 ); + sy = -sy; } sscal( N, beta, y, sy ); } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyn.json new file mode 100644 index 00000000000..dd535606e05 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyn.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": -1, + "offsetX": 2, + "strideY": -1, + "offsetY": 2, + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 16.0, 11.0, 8.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyp.json new file mode 100644 index 00000000000..88b876d9478 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xnyp.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": -1, + "offsetX": 2, + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 8.0, 11.0, 16.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json new file mode 100644 index 00000000000..35340ff1722 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json @@ -0,0 +1,15 @@ +{ + "uplo": "lower", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "offsetX": 0, + "strideY": 2, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 7.0, 1.0, 12.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyn.json new file mode 100644 index 00000000000..8fedbd44397 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyn.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "column-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "offsetX": 0, + "strideY": -1, + "offsetY": 2, + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 16.0, 11.0, 8.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyp.json similarity index 88% rename from lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json rename to lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyp.json index 74571017498..0e57578aba8 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyp.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xpyp.json @@ -5,7 +5,9 @@ "alpha": 1.0, "beta": 1.0, "strideX": 1, + "offsetX": 0, "strideY": 1, + "offsetY": 0, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE deleted file mode 100644 index 308c3be89c8..00000000000 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/REQUIRE +++ /dev/null @@ -1,2 +0,0 @@ -julia 1.5 -JSON 0.21 diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyn.json similarity index 88% rename from lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json rename to lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyn.json index 80315f037c9..4763913667f 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyn.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyn.json @@ -5,7 +5,9 @@ "alpha": 1.0, "beta": 1.0, "strideX": -1, + "offsetX": 2, "strideY": -1, + "offsetY": 2, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyp.json similarity index 88% rename from lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json rename to lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyp.json index 6f71afa6ef8..fc5df6d7ce9 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xnyp.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xnyp.json @@ -5,7 +5,9 @@ "alpha": 1.0, "beta": 1.0, "strideX": -1, + "offsetX": 2, "strideY": 1, + "offsetY": 0, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json similarity index 88% rename from lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json rename to lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json index bd3e1dc7694..cefb8a7aa90 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json @@ -5,7 +5,9 @@ "alpha": 1.0, "beta": 1.0, "strideX": 1, + "offsetX": 0, "strideY": 2, + "offsetY": 0, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyn.json similarity index 88% rename from lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json rename to lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyn.json index d853cfa26cf..82387497ca3 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/julia/strides_xpyn.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyn.json @@ -5,7 +5,9 @@ "alpha": 1.0, "beta": 1.0, "strideX": 1, + "offsetX": 0, "strideY": -1, + "offsetY": 2, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 1.0, 1.0 ], diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyp.json new file mode 100644 index 00000000000..d4deab60a3f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xpyp.json @@ -0,0 +1,15 @@ +{ + "uplo": "upper", + "order": "row-major", + "N": 3, + "alpha": 1.0, + "beta": 1.0, + "strideX": 1, + "offsetX": 0, + "strideY": 1, + "offsetY": 0, + "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], + "x": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 1.0, 1.0 ], + "y_out": [ 7.0, 12.0, 15.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js index ac8b4f20270..df627aa2090 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -24,16 +26,23 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); var sspmv = require( './../lib/ndarray.js' ); // FIXTURES // -var stridexoyt = require( './fixtures/julia/strides_xoyt.json' ); -var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); -var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); -var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); -var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); +var rxoyt = require( './fixtures/row_major_xoyt.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + +var cxoyt = require( './fixtures/column_major_xoyt.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); // FUNCTIONS // @@ -78,220 +87,478 @@ tape( 'the function has an arity of 12', function test( t ) { t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=1)', function test( t ) { +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( value, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( rxpyp.order, value, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( rxpyp.order, rxpyp.uplo, value, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { + var values; + var i; + + values = [ + 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() { + sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), value, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid 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() { + sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, new Float32Array( rxpyp.y ), value, rxpyp.offsetY ); + }; + } +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y_out ); - n = stridexpyp.N; + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, ap, 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 ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + t.end(); +}); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (column-major, sx=1, sy=1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexpyp.AP ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + ap = new Float32Array( cxpyp.AP ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); - expected = new Float32Array( stridexpyp.y_out ); + expected = new Float32Array( cxpyp.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); + out = sspmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.alpha, ap, 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, supplied in packed form (row-major, sx=1, sy=2)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( rxoyt.AP ); + x = new Float32Array( rxoyt.x ); + y = new Float32Array( rxoyt.y ); + + expected = new Float32Array( rxoyt.y_out ); + + out = sspmv( rxoyt.order, rxoyt.uplo, rxoyt.N, rxoyt.alpha, ap, x, rxoyt.strideX, rxoyt.offsetX, rxoyt.beta, y, rxoyt.strideY, rxoyt.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (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, supplied in packed form (column-major, sx=1, sy=2)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexoyt.order; - uplo = stridexoyt.uplo; + ap = new Float32Array( cxoyt.AP ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); - n = stridexoyt.N; + expected = new Float32Array( cxoyt.y_out ); - strideX = stridexoyt.strideX; - strideY = stridexoyt.strideY; + out = sspmv( cxoyt.order, cxoyt.uplo, cxoyt.N, cxoyt.alpha, ap, 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 ); - alpha = stridexoyt.alpha; - beta = stridexoyt.beta; + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexoyt.AP ); - x = new Float32Array( stridexoyt.x ); - y = new Float32Array( stridexoyt.y ); + ap = new Float32Array( rxpyn.AP ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); - expected = new Float32Array( stridexoyt.y_out ); + expected = new Float32Array( rxpyn.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); + out = sspmv( rxpyn.order, rxpyn.uplo, rxpyn.N, rxpyn.alpha, ap, 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, supplied in packed form (column-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( cxpyn.AP ); + x = new Float32Array( cxpyn.x ); + y = new Float32Array( cxpyn.y ); + + expected = new Float32Array( cxpyn.y_out ); + + out = sspmv( cxpyn.order, cxpyn.uplo, cxpyn.N, cxpyn.alpha, ap, x, cxpyn.strideX, cxpyn.offsetX, cxpyn.beta, y, cxpyn.strideY, cxpyn.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function supports a negative `x` stride', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=-1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexnyp.order; - uplo = stridexnyp.uplo; + ap = new Float32Array( rxnyp.AP ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); - n = stridexnyp.N; + expected = new Float32Array( rxnyp.y_out ); - strideX = stridexnyp.strideX; - strideY = stridexnyp.strideY; + out = sspmv( rxnyp.order, rxnyp.uplo, rxnyp.N, rxnyp.alpha, ap, x, rxnyp.strideX, rxnyp.offsetX, rxnyp.beta, y, rxnyp.strideY, rxnyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexnyp.alpha; - beta = stridexnyp.beta; + t.end(); +}); - ap = new Float32Array( stridexnyp.AP ); - x = new Float32Array( stridexnyp.x ); - y = new Float32Array( stridexnyp.y ); +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (column-major, sx=-1, sy=1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( cxnyp.AP ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); - expected = new Float32Array( stridexnyp.y_out ); + expected = new Float32Array( cxnyp.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 2, beta, y, strideY, 0 ); + out = sspmv( cxnyp.order, cxnyp.uplo, cxnyp.N, cxnyp.alpha, ap, 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 ap; + var x; + var y; + + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, ap, x, rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, y, rxpyp.strideY, rxpyp.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); -tape( 'the function supports a negative `y` stride', function test( t ) { +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (row-major)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexpyn.order; - uplo = stridexpyn.uplo; + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyn.N; + expected = new Float32Array( rxpyp.y ); - strideX = stridexpyn.strideX; - strideY = stridexpyn.strideY; + out = sspmv( rxpyp.order, rxpyp.uplo, 0, rxpyp.alpha, ap, x, rxpyp.strideX, rxpyp.offsetX, rxpyp.beta, y, rxpyp.strideY, rxpyp.offsetY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyn.alpha; - beta = stridexpyn.beta; + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, 0.0, ap, 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' ); - ap = new Float32Array( stridexpyn.AP ); - x = new Float32Array( stridexpyn.x ); - y = new Float32Array( stridexpyn.y ); + t.end(); +}); - expected = new Float32Array( stridexpyn.y_out ); +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 2 ); - isApprox( t, y, expected, 2.0 ); + ap = new Float32Array( cxpyp.AP ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y ); + + out = sspmv( cxpyp.order, cxpyp.uplo, 0, cxpyp.alpha, ap, 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 = sspmv( cxpyp.order, cxpyp.uplo, cxpyp.N, 0.0, ap, 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( 'the function returns a reference to the second input array', function test( t ) { - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; +tape( 'when `α` is zero, the function scales the second input vector (row-major, upper)', function test( t ) { + var expected; var out; var ap; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexpyp.N; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = sspmv( 'row-major', 'upper', 3, 0.0, ap, x, 1, 0, 5.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'row-major', 'upper', 3, 0.0, ap, x, 1, 0, 0.0, y, -1, 2 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; +tape( 'when `α` is zero, the function scales the second input vector (row-major, lower)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexpyp.AP ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 0, beta, y, strideY, 0 ); + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'row-major', 'lower', 3, 0.0, ap, x, 1, 0, 5.0, y, -1, 2 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'row-major', 'lower', 3, 0.0, ap, 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 ap; + var x; + var y; + + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'column-major', 'upper', 3, 0.0, ap, x, 1, 0, 5.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'column-major', 'upper', 3, 0.0, ap, x, 1, 0, 0.0, y, -1, 2 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { +tape( 'when `α` is zero, the function scales the second input vector (column-major, lower)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexnyn.order; - uplo = stridexnyn.uplo; + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'column-major', 'lower', 3, 0.0, ap, x, 1, 0, 5.0, y, -1, 2 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - n = stridexnyn.N; + out = sspmv( 'column-major', 'lower', 3, 0.0, ap, x, 1, 0, 0.0, y, 1, 0 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - strideX = stridexnyn.strideX; - strideY = stridexnyn.strideY; + t.end(); +}); - alpha = stridexnyn.alpha; - beta = stridexnyn.beta; +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexnyn.AP ); - x = new Float32Array( stridexnyn.x ); - y = new Float32Array( stridexnyn.y ); + ap = new Float32Array( rxnyn.AP ); + x = new Float32Array( rxnyn.x ); + y = new Float32Array( rxnyn.y ); - expected = new Float32Array( stridexnyn.y_out ); + expected = new Float32Array( rxnyn.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, 2, beta, y, strideY, 2 ); + out = sspmv( rxnyn.order, rxnyn.uplo, rxnyn.N, rxnyn.alpha, ap, 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 ap; + var x; + var y; + + ap = new Float32Array( cxnyn.AP ); + x = new Float32Array( cxnyn.x ); + y = new Float32Array( cxnyn.y ); + + expected = new Float32Array( cxnyn.y_out ); + + out = sspmv( cxnyn.order, cxnyn.uplo, cxnyn.N, cxnyn.alpha, ap, x, cxnyn.strideX, cxnyn.offsetX, cxnyn.beta, y, cxnyn.strideY, cxnyn.offsetY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js index 529149a0619..84ebe4c8436 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -24,16 +26,23 @@ var tape = require( 'tape' ); var Float32Array = require( '@stdlib/array/float32' ); var EPS = require( '@stdlib/constants/float32/eps' ); var abs = require( '@stdlib/math/base/special/abs' ); +var ones = require( '@stdlib/array/ones' ); var sspmv = require( './../lib/sspmv.js' ); // FIXTURES // -var stridexoyt = require( './fixtures/julia/strides_xoyt.json' ); -var stridexpyp = require( './fixtures/julia/strides_xpyp.json' ); -var stridexnyp = require( './fixtures/julia/strides_xnyp.json' ); -var stridexpyn = require( './fixtures/julia/strides_xpyn.json' ); -var stridexnyn = require( './fixtures/julia/strides_xnyn.json' ); +var rxoyt = require( './fixtures/row_major_xoyt.json' ); +var rxpyp = require( './fixtures/row_major_xpyp.json' ); +var rxnyp = require( './fixtures/row_major_xnyp.json' ); +var rxpyn = require( './fixtures/row_major_xpyn.json' ); +var rxnyn = require( './fixtures/row_major_xnyn.json' ); + +var cxoyt = require( './fixtures/column_major_xoyt.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); // FUNCTIONS // @@ -78,220 +87,478 @@ tape( 'the function has an arity of 10', function test( t ) { t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (sx=1, sy=1)', function test( t ) { +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( value, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( rxpyp.order, value, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var i; + + values = [ + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + sspmv( rxpyp.order, rxpyp.uplo, value, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid seventh argument', function test( t ) { + var values; + var i; + + values = [ + 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() { + sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), value, rxpyp.beta, new Float32Array( rxpyp.y ), rxpyp.strideY ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth 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() { + sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, new Float32Array( rxpyp.AP ), new Float32Array( rxpyp.x ), rxpyp.strideX, rxpyp.beta, new Float32Array( rxpyp.y ), value ); + }; + } +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + expected = new Float32Array( rxpyp.y_out ); - n = stridexpyp.N; + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, ap, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + t.end(); +}); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (column-major, sx=1, sy=1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexpyp.AP ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + ap = new Float32Array( cxpyp.AP ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); - expected = new Float32Array( stridexpyp.y_out ); + expected = new Float32Array( cxpyp.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); + out = sspmv( cxpyp.order, cxpyp.uplo, cxpyp.N, cxpyp.alpha, ap, 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, supplied in packed form (row-major, sx=1, sy=2)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( rxoyt.AP ); + x = new Float32Array( rxoyt.x ); + y = new Float32Array( rxoyt.y ); + + expected = new Float32Array( rxoyt.y_out ); + + out = sspmv( rxoyt.order, rxoyt.uplo, rxoyt.N, rxoyt.alpha, ap, x, rxoyt.strideX, rxoyt.beta, y, rxoyt.strideY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); -tape( 'the function performs one of the matrix-vector operations matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form (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, supplied in packed form (column-major, sx=1, sy=2)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexoyt.order; - uplo = stridexoyt.uplo; + ap = new Float32Array( cxoyt.AP ); + x = new Float32Array( cxoyt.x ); + y = new Float32Array( cxoyt.y ); - n = stridexoyt.N; + expected = new Float32Array( cxoyt.y_out ); - strideX = stridexoyt.strideX; - strideY = stridexoyt.strideY; + out = sspmv( cxoyt.order, cxoyt.uplo, cxoyt.N, cxoyt.alpha, ap, x, cxoyt.strideX, cxoyt.beta, y, cxoyt.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexoyt.alpha; - beta = stridexoyt.beta; + t.end(); +}); + +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexoyt.AP ); - x = new Float32Array( stridexoyt.x ); - y = new Float32Array( stridexoyt.y ); + ap = new Float32Array( rxpyn.AP ); + x = new Float32Array( rxpyn.x ); + y = new Float32Array( rxpyn.y ); - expected = new Float32Array( stridexoyt.y_out ); + expected = new Float32Array( rxpyn.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); + out = sspmv( rxpyn.order, rxpyn.uplo, rxpyn.N, rxpyn.alpha, ap, 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, supplied in packed form (column-major, sx=1, sy=-1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( cxpyn.AP ); + x = new Float32Array( cxpyn.x ); + y = new Float32Array( cxpyn.y ); + + expected = new Float32Array( cxpyn.y_out ); + + out = sspmv( cxpyn.order, cxpyn.uplo, cxpyn.N, cxpyn.alpha, ap, 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 supports a negative `x` stride', function test( t ) { +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (row-major, sx=-1, sy=1)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexnyp.order; - uplo = stridexnyp.uplo; + ap = new Float32Array( rxnyp.AP ); + x = new Float32Array( rxnyp.x ); + y = new Float32Array( rxnyp.y ); - n = stridexnyp.N; + expected = new Float32Array( rxnyp.y_out ); - strideX = stridexnyp.strideX; - strideY = stridexnyp.strideY; + out = sspmv( rxnyp.order, rxnyp.uplo, rxnyp.N, rxnyp.alpha, ap, x, rxnyp.strideX, rxnyp.beta, y, rxnyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); - alpha = stridexnyp.alpha; - beta = stridexnyp.beta; + t.end(); +}); - ap = new Float32Array( stridexnyp.AP ); - x = new Float32Array( stridexnyp.x ); - y = new Float32Array( stridexnyp.y ); +tape( 'the function performs the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `n` element vectors, and `A` is an `n` by `n` symmetric matrix, supplied in packed form (column-major, sx=-1, sy=1)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; + + ap = new Float32Array( cxnyp.AP ); + x = new Float32Array( cxnyp.x ); + y = new Float32Array( cxnyp.y ); - expected = new Float32Array( stridexnyp.y_out ); + expected = new Float32Array( cxnyp.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); + out = sspmv( cxnyp.order, cxnyp.uplo, cxnyp.N, cxnyp.alpha, ap, 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 ap; + var x; + var y; + + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); + + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, rxpyp.alpha, ap, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); t.strictEqual( out, y, 'returns expected value' ); + t.end(); }); -tape( 'the function supports a negative `y` stride', function test( t ) { +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (row-major)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexpyn.order; - uplo = stridexpyn.uplo; + ap = new Float32Array( rxpyp.AP ); + x = new Float32Array( rxpyp.x ); + y = new Float32Array( rxpyp.y ); - n = stridexpyn.N; + expected = new Float32Array( rxpyp.y ); - strideX = stridexpyn.strideX; - strideY = stridexpyn.strideY; + out = sspmv( rxpyp.order, rxpyp.uplo, 0, rxpyp.alpha, ap, x, rxpyp.strideX, rxpyp.beta, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - alpha = stridexpyn.alpha; - beta = stridexpyn.beta; + out = sspmv( rxpyp.order, rxpyp.uplo, rxpyp.N, 0.0, ap, x, rxpyp.strideX, 1.0, y, rxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - ap = new Float32Array( stridexpyn.AP ); - x = new Float32Array( stridexpyn.x ); - y = new Float32Array( stridexpyn.y ); + t.end(); +}); - expected = new Float32Array( stridexpyn.y_out ); +tape( 'if `N` is zero or the scalar constants are zero and unity, respectively, the function returns the second input vector unchanged (column-major)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); - isApprox( t, y, expected, 2.0 ); + ap = new Float32Array( cxpyp.AP ); + x = new Float32Array( cxpyp.x ); + y = new Float32Array( cxpyp.y ); + + expected = new Float32Array( cxpyp.y ); + + out = sspmv( cxpyp.order, cxpyp.uplo, 0, cxpyp.alpha, ap, x, cxpyp.strideX, cxpyp.beta, y, cxpyp.strideY ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + out = sspmv( cxpyp.order, cxpyp.uplo, cxpyp.N, 0.0, ap, 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( 'the function returns a reference to the second input array', function test( t ) { - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; +tape( 'when `α` is zero, the function scales the second input vector (row-major, upper)', function test( t ) { + var expected; var out; var ap; - var n; var x; var y; - order = stridexpyp.order; - uplo = stridexpyp.uplo; + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - n = stridexpyp.N; + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); - strideX = stridexpyp.strideX; - strideY = stridexpyp.strideY; + out = sspmv( 'row-major', 'upper', 3, 0.0, ap, x, 1, 5.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'row-major', 'upper', 3, 0.0, ap, x, 1, 0.0, y, -1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + t.end(); +}); - alpha = stridexpyp.alpha; - beta = stridexpyp.beta; +tape( 'when `α` is zero, the function scales the second input vector (row-major, lower)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexpyp.AP ); - x = new Float32Array( stridexpyp.x ); - y = new Float32Array( stridexpyp.y ); + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'row-major', 'lower', 3, 0.0, ap, x, 1, 5.0, y, -1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'row-major', 'lower', 3, 0.0, ap, 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 ap; + var x; + var y; + + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'column-major', 'upper', 3, 0.0, ap, x, 1, 5.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); + + out = sspmv( 'column-major', 'upper', 3, 0.0, ap, x, 1, 0.0, y, -1 ); t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + t.end(); }); -tape( 'the function supports complex access patterns', function test( t ) { +tape( 'when `α` is zero, the function scales the second input vector (column-major, lower)', function test( t ) { var expected; - var strideX; - var strideY; - var alpha; - var order; - var beta; - var uplo; var out; var ap; - var n; var x; var y; - order = stridexnyn.order; - uplo = stridexnyn.uplo; + ap = ones( 6, 'float32' ); + x = ones( 3, 'float32' ); + y = ones( 3, 'float32' ); + + expected = new Float32Array( [ 5.0, 5.0, 5.0 ] ); + + out = sspmv( 'column-major', 'lower', 3, 0.0, ap, x, 1, 5.0, y, -1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); + + expected = new Float32Array( [ 0.0, 0.0, 0.0 ] ); - n = stridexnyn.N; + out = sspmv( 'column-major', 'lower', 3, 0.0, ap, x, 1, 0.0, y, 1 ); + t.strictEqual( out, y, 'returns expected value' ); + t.deepEqual( y, expected, 'returns expected value' ); - strideX = stridexnyn.strideX; - strideY = stridexnyn.strideY; + t.end(); +}); - alpha = stridexnyn.alpha; - beta = stridexnyn.beta; +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var out; + var ap; + var x; + var y; - ap = new Float32Array( stridexnyn.AP ); - x = new Float32Array( stridexnyn.x ); - y = new Float32Array( stridexnyn.y ); + ap = new Float32Array( rxnyn.AP ); + x = new Float32Array( rxnyn.x ); + y = new Float32Array( rxnyn.y ); - expected = new Float32Array( stridexnyn.y_out ); + expected = new Float32Array( rxnyn.y_out ); - out = sspmv( order, uplo, n, alpha, ap, x, strideX, beta, y, strideY ); + out = sspmv( rxnyn.order, rxnyn.uplo, rxnyn.N, rxnyn.alpha, ap, 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 ap; + var x; + var y; + + ap = new Float32Array( cxnyn.AP ); + x = new Float32Array( cxnyn.x ); + y = new Float32Array( cxnyn.y ); + + expected = new Float32Array( cxnyn.y_out ); + + out = sspmv( cxnyn.order, cxnyn.uplo, cxnyn.N, cxnyn.alpha, ap, x, cxnyn.strideX, cxnyn.beta, y, cxnyn.strideY ); t.strictEqual( out, y, 'returns expected value' ); + isApprox( t, y, expected, 2.0 ); + t.end(); }); From a477d6402e39a4828ee2379c17f94fc35e1a3cfb Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 21 Jun 2024 14:28:31 +0530 Subject: [PATCH 05/19] docs: add BLAS types and update descriptions --- .../blas/base/sspmv/docs/types/index.d.ts | 18 ++++++------------ .../@stdlib/blas/base/sspmv/lib/ndarray.js | 4 ++-- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts index 8a08729f0bd..310b34d28f5 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts @@ -18,15 +18,9 @@ // TypeScript Version: 4.1 -/** -* Storage layouts. -*/ -type Order = 'row-major' | 'column-major'; +/// -/** -* Upper or lower triangular indicator. -*/ -type UPLO = 'upper' | 'lower'; +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; /** * Interface describing `sspmv`. @@ -57,7 +51,7 @@ interface Routine { * sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); * // y => [ 7.0, 12.0, 15.0 ] */ - ( order: Order, uplo: UPLO, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + ( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. @@ -69,11 +63,11 @@ interface Routine { * @param AP - packed form of symmetric matrix `A` * @param x - first input array * @param strideX - `x` stride length - * @param offsetX - `x` index offset + * @param offsetX - starting `x` index * @param beta - scalar constant * @param y - second input array * @param strideY - `y` stride length - * @param offsetY - `y` index offset + * @param offsetY - starting `y` index * @returns output array `y` * * @example @@ -86,7 +80,7 @@ interface Routine { * sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); * // y => [ 7.0, 12.0, 15.0 ] */ - ndarray( order: Order, uplo: UPLO, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; + ndarray( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; } /** diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js index c77d069e17f..f90eab2fca7 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js @@ -39,11 +39,11 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * @param {Float32Array} AP - packed form of symmetric matrix `A` * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length -* @param {NonNegativeInteger} offsetX - `x` index offset +* @param {NonNegativeInteger} offsetX - starting `x` index * @param {number} beta - scalar constant * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length -* @param {NonNegativeInteger} offsetY - `y` index offset +* @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 From 61e9e082b7b875edac9fe24be70dae17303bc1c1 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 21 Jun 2024 14:39:12 +0530 Subject: [PATCH 06/19] docs: update descriptions --- .../@stdlib/blas/base/sspmv/README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index 61ba451b091..f96e3d0d2f0 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -20,7 +20,7 @@ limitations under the License. # sspmv -> Perform one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form AP. +> 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, supplied in packed form `AP`.
@@ -30,9 +30,9 @@ limitations under the License. var sspmv = require( '@stdlib/blas/base/sspmv' ); ``` -#### sspmv( ord, uplo, N, α, AP, x, sx, β, y, sy ) +#### sspmv( order, uplo, N, α, AP, x, sx, β, y, sy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form AP. +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, supplied in packed form `AP`. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -48,8 +48,8 @@ sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); The function has the following parameters: -- **ord**: storage layout. -- **uplo**: specifies the operation to be performed. +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. - **N**: specifies the order of the matrix `A`. - **α**: scalar constant. - **AP**: packed form of symmetric matrix `A` [`Float32Array`][mdn-float32array]. @@ -59,8 +59,7 @@ The function has the following parameters: - **y**: output [`Float32Array`][mdn-float32array]. - **sy**: index increment for `y`. -The stride parameters determine how operations are performed. For example, to -perform one of the matrix-vector operations starting from the second index of `x`, +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `y` in reverse order, ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -93,9 +92,9 @@ sspmv( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 ); // y0 => [ 6.0, 4.0 ] ``` -#### sspmv.ndarray( ord, uplo, N, α, AP, x, sx, ox, β, y, sy, oy ) +#### sspmv.ndarray( order, uplo, N, α, AP, x, sx, ox, β, y, sy, oy ) -Performs one of the matrix-vector operations `y = α*A*x + β*y` where α and β are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. +Performs the matrix-vector operation `y = α*A*x + β*y` using alternative indexing semantics and where `α` and `β` are scalars, `x` and `y` are `N` element vectors, and A is an `N` by `N` symmetric matrix, supplied in packed form. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -114,7 +113,7 @@ The function has the following additional parameters: - **ox**: starting index for `x`. - **oy**: starting index for `y`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to perform operation with given `x` and `y` offset values`,..., +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, ```javascript var Float32Array = require( '@stdlib/array/float32' ); From 5b4aa57609bf378aede6c89bb8381eed96070889 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Fri, 21 Jun 2024 14:45:34 +0530 Subject: [PATCH 07/19] chore: update comment for max-len and max-param --- lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js index f90eab2fca7..d77000c4ac1 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js @@ -61,7 +61,7 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * sspmv( 'column-major', 'lower', 3, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); * // y => [ ~7.0, ~12.0, ~15.0 ] */ -function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params +function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY, offsetY ) { // eslint-disable-line max-params, max-len var temp1; var temp2; var ix; From f8906990886f802e3472ce72c991e279b0219621 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 14:04:31 -0700 Subject: [PATCH 08/19] style: remove unnecessary parentheses --- .../@stdlib/blas/base/sspmv/benchmark/benchmark.js | 4 ++-- .../@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js index ea92435d2d8..fee324e074a 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.js @@ -46,7 +46,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var AP = uniform( ( ( len ) * ( len + 1 ) / 2 ), -10.0, 10.0, options ); + var AP = uniform( len * ( len + 1 ) / 2, -10.0, 10.0, options ); var x = uniform( len, -10.0, 10.0, options ); var y = uniform( len, -10.0, 10.0, options ); return benchmark; @@ -98,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( len ); - bench( pkg+':size='+( ( len ) * ( len + 1 ) / 2 ), f ); + bench( pkg+':size='+( len * ( len + 1 ) / 2 ), f ); } } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js index f039ab7ccfc..ed179effd94 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/benchmark/benchmark.ndarray.js @@ -46,7 +46,7 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var AP = uniform( ( ( len ) * ( len + 1 ) / 2 ), -10.0, 10.0, options ); + var AP = uniform( len * ( len + 1 ) / 2, -10.0, 10.0, options ); var x = uniform( len, -10.0, 10.0, options ); var y = uniform( len, -10.0, 10.0, options ); return benchmark; @@ -98,7 +98,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = floor( pow( pow( 10, i ), 1.0/2.0 ) ); f = createBenchmark( len ); - bench( pkg+':ndarray:size='+( ( len ) * ( len + 1 ) / 2 ), f ); + bench( pkg+':ndarray:size='+( len * ( len + 1 ) / 2 ), f ); } } From 6c4a0c481682e68cd91add4b6a0973f9c89d39ad Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 14:18:41 -0700 Subject: [PATCH 09/19] fix: update type declarations --- .../blas/base/sspmv/docs/types/index.d.ts | 16 ++--- .../blas/base/sspmv/docs/types/test.ts | 58 +++++++++---------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts index 310b34d28f5..0a5055b6e86 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts @@ -27,7 +27,7 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form. + * 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 supplied in packed form. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -39,7 +39,7 @@ interface Routine { * @param beta - scalar constant * @param y - second input array * @param strideY - `y` stride length - * @returns output array `y` + * @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -51,10 +51,10 @@ interface Routine { * sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); * // y => [ 7.0, 12.0, 15.0 ] */ - ( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; + ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float32Array, x: Float32Array, strideX: number, beta: number, y: Float32Array, strideY: number ): Float32Array; /** - * Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form using alternative indexing semantics. + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix supplied in packed form. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -68,7 +68,7 @@ interface Routine { * @param y - second input array * @param strideY - `y` stride length * @param offsetY - starting `y` index - * @returns output array `y` + * @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -80,11 +80,11 @@ interface Routine { * sspmv.ndarray( 'column-major', 'lower', 3, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ); * // y => [ 7.0, 12.0, 15.0 ] */ - ndarray( order: Layout, uplo: MatrixTriangle, N: number, k: number, alpha: number, AP: Float32Array, LDA: number, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; + ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, AP: Float32Array, x: Float32Array, strideX: number, offsetX: number, beta: number, y: Float32Array, strideY: number, offsetY: number ): Float32Array; } /** -* Performs one of the matrix-vector operations `y = alpha*A*x + beta*y` where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix, supplied in packed form. +* 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 supplied in packed form. * * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied @@ -96,7 +96,7 @@ interface Routine { * @param beta - scalar constant * @param y - second input array * @param strideY - `y` stride length -* @returns output array `y` +* @returns `y` * * @example * var Float32Array = require( '@stdlib/array/float32' ); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts index 71a6ccfe400..930e5f39428 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/test.ts @@ -40,7 +40,7 @@ import sspmv = require( './index' ); sspmv( true, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( false, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( null, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError - sspmv( undefined, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( void 0, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( [], 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( {}, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( ( x: number ): number => x, 'upper', 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError @@ -56,7 +56,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', true, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', false, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', null, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', undefined, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', void 0, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', [ '1' ], 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', {}, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', ( x: number ): number => x, 10, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError @@ -72,7 +72,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', true, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', false, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', null, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', undefined, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', void 0, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', [], 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', {}, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', ( x: number ): number => x, 1.0, A, x, 1, 1.0, y, 1 ); // $ExpectError @@ -88,7 +88,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, true, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, false, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, null, A, x, 1, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, undefined, A, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, void 0, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, [], A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, {}, A, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, ( x: number ): number => x, A, x, 1, 1.0, y, 1 ); // $ExpectError @@ -104,7 +104,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, true, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, false, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, null, x, 1, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, undefined, x, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, void 0, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, [ '1' ], x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, {}, x, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, x, 1, 1.0, y, 1 ); // $ExpectError @@ -120,13 +120,13 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, A, true, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, false, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, null, 1, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, A, undefined, 1, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, void 0, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, [ '1' ], 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, {}, 1, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, 1, 1.0, y, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided an seventh argument which is not a number... +// The compiler throws an error if the function is provided a seventh argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -136,13 +136,13 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, A, x, true, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, false, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, null, 1.0, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, A, x, undefined, 1.0, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, void 0, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, [], 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, {}, 1.0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided a eighth argument which is not a number... +// The compiler throws an error if the function is provided an eighth argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -152,7 +152,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, true, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, false, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, null, y, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, undefined, y, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, void 0, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, [], y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, {}, y, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, ( x: number ): number => x, y, 1 ); // $ExpectError @@ -168,13 +168,13 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, true, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, false, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, null, 1 ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, undefined, 1 ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, void 0, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, [ '1' ], 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, {}, 1 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, ( x: number ): number => x, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided an tenth argument which is not a number... +// The compiler throws an error if the function is provided a tenth argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -184,7 +184,7 @@ import sspmv = require( './index' ); sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, true ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, false ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, null ); // $ExpectError - sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, undefined ); // $ExpectError + sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, void 0 ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, [] ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, {} ); // $ExpectError sspmv( 'row-major', 'upper', 10, 1.0, A, x, 1, 1.0, y, ( x: number ): number => x ); // $ExpectError @@ -228,7 +228,7 @@ import sspmv = require( './index' ); sspmv.ndarray( true, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( false, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( null, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( undefined, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( void 0, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( [], 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( {}, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( ( x: number ): number => x, 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError @@ -244,7 +244,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', true, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', false, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', null, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', undefined, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', void 0, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', [ '1' ], 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', {}, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', ( x: number ): number => x, 10, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError @@ -260,7 +260,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', true, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', false, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', null, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', undefined, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', void 0, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', [], 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', {}, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', ( x: number ): number => x, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError @@ -276,7 +276,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, true, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, false, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, null, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, undefined, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, void 0, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, [], A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, {}, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, ( x: number ): number => x, A, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError @@ -292,7 +292,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, true, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, false, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, null, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, undefined, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, void 0, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, {}, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError @@ -308,13 +308,13 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, true, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, false, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, null, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, undefined, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, void 0, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, [ '1' ], 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, {}, 1, 0, 1.0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, ( x: number ): number => x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an seventh argument which is not a number... +// The compiler throws an error if the function is provided a seventh argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -324,13 +324,13 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, true, 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, false, 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, null, 0, 1.0, y, 1 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, undefined, 0, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, void 0, 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, [], 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, {}, 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, ( x: number ): number => x, 0, 1.0, y, 1 ); // $ExpectError } -// The compiler throws an error if the function is provided a eighth argument which is not a number... +// The compiler throws an error if the function is provided an eighth argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -340,7 +340,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, true, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, false, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, null, 1.0, y, 1 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, undefined, 1.0, y, 1 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, void 0, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, [], 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, {}, 1.0, y, 1 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, ( x: number ): number => x, 1.0, y, 1 ); // $ExpectError @@ -356,13 +356,13 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, true, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, false, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, null, y, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, undefined, y, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, void 0, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, [], y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, {}, y, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, ( x: number ): number => x, y, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an tenth argument which is not a Float32Array... +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... { const x = new Float32Array( 10 ); const A = new Float32Array( 55 ); @@ -372,13 +372,13 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, true, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, false, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, null, 1, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, undefined, 1, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, void 0, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, [ '1' ], 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, {}, 1, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, ( x: number ): number => x, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a eleventh argument which is not a number... +// The compiler throws an error if the function is provided an eleventh argument which is not a number... { const x = new Float32Array( 10 ); const y = new Float32Array( 10 ); @@ -388,7 +388,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, true, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, false, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, null, 0 ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, undefined, 0 ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, void 0, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, [], 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, {}, 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, ( x: number ): number => x, 0 ); // $ExpectError @@ -404,7 +404,7 @@ import sspmv = require( './index' ); sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, true ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, false ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, null ); // $ExpectError - sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, undefined ); // $ExpectError + sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, void 0 ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, [] ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, {} ); // $ExpectError sspmv.ndarray( 'row-major', 'upper', 10, 1.0, A, x, 1, 0, 1.0, y, 1, ( x: number ): number => x ); // $ExpectError From d18eb80674b266514cfe2c1e2221baba5b04f9f3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 14:20:33 -0700 Subject: [PATCH 10/19] style: remove unnecessary parentheses --- lib/node_modules/@stdlib/blas/base/sspmv/README.md | 2 +- lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index f96e3d0d2f0..fbd28af22b4 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -155,7 +155,7 @@ var opts = { }; var N = 3; -var AP = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); +var AP = discreteUniform( N * ( N + 1 ) / 2, -10, 10, opts ); var x = discreteUniform( N, -10, 10, opts ); var y = discreteUniform( N, -10, 10, opts ); diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js index 0390e59d7a7..23391078e6b 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/examples/index.js @@ -26,7 +26,7 @@ var opts = { }; var N = 3; -var AP = discreteUniform( ( N * ( N + 1 ) / 2 ), -10, 10, opts ); +var AP = discreteUniform( N * ( N + 1 ) / 2, -10, 10, opts ); var x = discreteUniform( N, -10, 10, opts ); var y = discreteUniform( N, -10, 10, opts ); From 1a8e112975ea9ec0b93cf02d1bf34da926bcf557 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:06:09 -0700 Subject: [PATCH 11/19] docs: update examples and descriptions --- lib/node_modules/@stdlib/blas/base/sspmv/README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index fbd28af22b4..3c9c823cb85 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -20,7 +20,7 @@ limitations under the License. # sspmv -> 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, supplied in packed form `AP`. +> 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 supplied in packed form.
@@ -32,11 +32,10 @@ var sspmv = require( '@stdlib/blas/base/sspmv' ); #### sspmv( order, uplo, N, α, AP, 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, supplied in packed form `AP`. +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 supplied in packed form `AP`. ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var sspmv = require( '@stdlib/blas/base/sspmv' ); var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); @@ -49,10 +48,10 @@ sspmv( 'column-major', 'lower', 3, 1.0, AP, x, 1, 1.0, y, 1 ); 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. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: specifies the order of the matrix `A`. - **α**: scalar constant. -- **AP**: packed form of symmetric matrix `A` [`Float32Array`][mdn-float32array]. +- **AP**: packed form of a symmetric matrix `A`. - **x**: input [`Float32Array`][mdn-float32array]. - **sx**: index increment for `x`. - **β**: scalar constant. @@ -94,11 +93,10 @@ sspmv( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 ); #### sspmv.ndarray( order, uplo, N, α, AP, 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, supplied in packed form. +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 supplied in packed form `AP`. ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var sspmv = require( '@stdlib/blas/base/sspmv' ); var AP = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); var x = new Float32Array( [ 1.0, 1.0, 1.0 ] ); From 38f1cd825c52f5e7b139dea2aa401aacb54b70a1 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:07:02 -0700 Subject: [PATCH 12/19] docs: update description --- lib/node_modules/@stdlib/blas/base/sspmv/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/README.md b/lib/node_modules/@stdlib/blas/base/sspmv/README.md index 3c9c823cb85..e90adf1c5e2 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/README.md +++ b/lib/node_modules/@stdlib/blas/base/sspmv/README.md @@ -51,7 +51,7 @@ The function has the following parameters: - **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied. - **N**: specifies the order of the matrix `A`. - **α**: scalar constant. -- **AP**: packed form of a symmetric matrix `A`. +- **AP**: packed form of a symmetric matrix `A` stored in linear memory as a [`Float32Array`][mdn-float32array]. - **x**: input [`Float32Array`][mdn-float32array]. - **sx**: index increment for `x`. - **β**: scalar constant. From 8c34829936cfb518bbb07ab454f47e7ed91eb33c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:07:58 -0700 Subject: [PATCH 13/19] docs: update description --- lib/node_modules/@stdlib/blas/base/sspmv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/package.json b/lib/node_modules/@stdlib/blas/base/sspmv/package.json index 48af1a9b22d..9bcc532b090 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/package.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/sspmv", "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, supplied in packed form.", + "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 supplied in packed form.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From f149c0698dc90c7ef663edff5966e566760d93e1 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:12:26 -0700 Subject: [PATCH 14/19] test: update fixtures to accommodate stride length --- .../sspmv/test/fixtures/column_major_xoyt.json | 2 +- .../base/sspmv/test/fixtures/row_major_xoyt.json | 2 +- .../@stdlib/blas/base/sspmv/test/test.sspmv.js | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json index 35340ff1722..eef92036fab 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json @@ -10,6 +10,6 @@ "offsetY": 0, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], - "y": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], "y_out": [ 7.0, 1.0, 12.0 ] } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json index cefb8a7aa90..9ac2c31765a 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json @@ -10,6 +10,6 @@ "offsetY": 0, "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], - "y": [ 1.0, 1.0, 1.0 ], + "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], "y_out": [ 8.0, 1.0, 11.0 ] } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js index 84ebe4c8436..605e1a62698 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.sspmv.js @@ -195,7 +195,7 @@ tape( 'the function throws an error if provided an invalid tenth argument', func } }); -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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -215,7 +215,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -235,7 +235,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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=2)', function test( t ) { var expected; var out; var ap; @@ -255,7 +255,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=2)', function test( t ) { var expected; var out; var ap; @@ -275,7 +275,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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=-1)', function test( t ) { var expected; var out; var ap; @@ -295,7 +295,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=-1)', function test( t ) { var expected; var out; var ap; @@ -315,7 +315,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, supplied in packed form (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 supplied in packed form (row-major, sx=-1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -335,7 +335,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, supplied in packed form (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 supplied in packed form (column-major, sx=-1, sy=1)', function test( t ) { var expected; var out; var ap; From 6a5d95362e1ce669346d56b11b8b9450eb6bf0c4 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:15:13 -0700 Subject: [PATCH 15/19] test: update descriptions --- .../@stdlib/blas/base/sspmv/test/test.ndarray.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js index df627aa2090..c3c1d111cc4 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/test.ndarray.js @@ -195,7 +195,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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -215,7 +215,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -235,7 +235,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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=2)', function test( t ) { var expected; var out; var ap; @@ -255,7 +255,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=2)', function test( t ) { var expected; var out; var ap; @@ -275,7 +275,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, supplied in packed form (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 supplied in packed form (row-major, sx=1, sy=-1)', function test( t ) { var expected; var out; var ap; @@ -295,7 +295,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, supplied in packed form (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 supplied in packed form (column-major, sx=1, sy=-1)', function test( t ) { var expected; var out; var ap; @@ -315,7 +315,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, supplied in packed form (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 supplied in packed form (row-major, sx=-1, sy=1)', function test( t ) { var expected; var out; var ap; @@ -335,7 +335,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, supplied in packed form (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 supplied in packed form (column-major, sx=-1, sy=1)', function test( t ) { var expected; var out; var ap; From 1f35b1e21e5a37d3945e68a766f6fc9501374ba8 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:17:23 -0700 Subject: [PATCH 16/19] test: fix expected values --- .../blas/base/sspmv/test/fixtures/column_major_xoyt.json | 2 +- .../@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json index eef92036fab..7ce888f02a0 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/column_major_xoyt.json @@ -11,5 +11,5 @@ "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], - "y_out": [ 7.0, 1.0, 12.0 ] + "y_out": [ 7.0, 0.0, 12.0, 0.0, 15.0, 0.0 ] } diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json index 9ac2c31765a..f77e7da3427 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json +++ b/lib/node_modules/@stdlib/blas/base/sspmv/test/fixtures/row_major_xoyt.json @@ -11,5 +11,5 @@ "AP": [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], "x": [ 1.0, 1.0, 1.0 ], "y": [ 1.0, 0.0, 1.0, 0.0, 1.0, 0.0 ], - "y_out": [ 8.0, 1.0, 11.0 ] + "y_out": [ 8.0, 0.0, 11.0, 0.0, 16.0, 0.0 ] } From 462ab9b4a2b0bc55cd9094b3a0d0ae5bf5707d08 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:34:41 -0700 Subject: [PATCH 17/19] docs: update descriptions and remove unnecessary parentheses --- .../@stdlib/blas/base/sspmv/lib/index.js | 2 +- .../@stdlib/blas/base/sspmv/lib/ndarray.js | 16 +++++++++------- .../@stdlib/blas/base/sspmv/lib/sspmv.js | 16 +++++++++------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js index 2281ee60285..7313620df24 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix, supplied in packed form. +* 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 supplied in packed form. * * @module @stdlib/blas/base/sspmv * diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js index d77000c4ac1..f27999fabd9 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/ndarray.js @@ -30,13 +30,13 @@ 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, supplied in packed form. +* 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 supplied in packed form. * * @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 {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {number} alpha - scalar constant -* @param {Float32Array} AP - packed form of symmetric matrix `A` +* @param {Float32Array} AP - packed form of a symmetric matrix `A` * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length * @param {NonNegativeInteger} offsetX - starting `x` index @@ -45,7 +45,7 @@ var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); * @param {integer} strideY - `y` stride length * @param {NonNegativeInteger} offsetY - starting `y` index * @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} seventh argument must be non-zero * @throws {RangeError} eleventh argument must be non-zero @@ -78,7 +78,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY 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 ); + throw new TypeError( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ); } if ( N < 0 ) { throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); @@ -103,6 +103,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY if ( alpha === 0.0 ) { return y; } + // Form: y = alpha*A*x + y kx = offsetX; ky = offsetY; kk = 0; @@ -118,7 +119,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY y[ jy ] += f32( temp1 * AP[ kk ] ); ix = jx; iy = jy; - for ( k = ( kk + 1 ); k < ( kk + N - j ); k++ ) { + for ( k = kk + 1; k < kk + N - j; k++ ) { ix += strideX; iy += strideY; y[ iy ] += f32( temp1 * AP[ k ] ); @@ -131,6 +132,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY } return y; } + // ( order === 'row-major' && uplo === 'lower') || ( order === 'column-major' && uplo === 'upper' ) jx = kx; jy = ky; for ( j = 0; j < N; j++ ) { @@ -138,7 +140,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, offsetX, beta, y, strideY temp2 = 0.0; ix = kx; iy = ky; - for ( k = kk; k < ( kk + j ); k++ ) { + for ( k = kk; k < kk + j; k++ ) { y[ iy ] += f32( temp1 * AP[ k ] ); temp2 += f32( AP[ k ] * x[ ix ] ); ix += strideX; diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js index ee1421ffe82..1982ab3929b 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js +++ b/lib/node_modules/@stdlib/blas/base/sspmv/lib/sspmv.js @@ -30,20 +30,20 @@ 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, supplied in packed form. +* 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 supplied in packed form. * * @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 {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is supplied * @param {NonNegativeInteger} N - number of elements along each dimension of `A` * @param {number} alpha - scalar constant -* @param {Float32Array} AP - packed form of symmetric matrix `A` +* @param {Float32Array} AP - packed form of a symmetric matrix `A` * @param {Float32Array} x - first input array * @param {integer} strideX - `x` stride length * @param {number} beta - scalar constant * @param {Float32Array} y - second input array * @param {integer} strideY - `y` stride length * @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} seventh argument must be non-zero * @throws {RangeError} tenth argument must be non-zero @@ -77,7 +77,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { 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 ); + throw new TypeError( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ); } if ( N < 0 ) { throw new RangeError( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ); @@ -116,6 +116,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { } else { ky = ( 1 - N ) * strideY; } + // Form: y = alpha*A*x + y kk = 0; if ( ( order === 'row-major' && uplo === 'upper' ) || @@ -129,7 +130,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { y[ jy ] += f32( temp1 * AP[ kk ] ); ix = jx; iy = jy; - for ( k = ( kk + 1 ); k < ( kk + N - j ); k++ ) { + for ( k = kk + 1; k < kk + N - j; k++ ) { ix += strideX; iy += strideY; y[ iy ] += f32( temp1 * AP[ k ] ); @@ -142,6 +143,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { } return y; } + // ( order === 'row-major' && uplo === 'lower') || ( order === 'column-major' && uplo === 'upper' ) jx = kx; jy = ky; for ( j = 0; j < N; j++ ) { @@ -149,7 +151,7 @@ function sspmv( order, uplo, N, alpha, AP, x, strideX, beta, y, strideY ) { temp2 = 0.0; ix = kx; iy = ky; - for ( k = kk; k < ( kk + j ); k++ ) { + for ( k = kk; k < kk + j; k++ ) { y[ iy ] += f32( temp1 * AP[ k ] ); temp2 += f32( AP[ k ] * x[ ix ] ); ix += strideX; From 7077f4dea846fdb1e427f69fba6638329b1f646c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:41:32 -0700 Subject: [PATCH 18/19] docs: update descriptions and fix examples --- .../@stdlib/blas/base/sspmv/docs/repl.txt | 77 +++++++++---------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt index eeb0dcdd3a8..424383dd11f 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/repl.txt @@ -1,35 +1,34 @@ -{{alias}}( ord, uplo, N, α, A, x, sx, β, y, sy ) - Perform one of the matrix-vector operations `y = α*A*x + β*y` - where α and β are scalars, x and y are n element vectors and A is - an n by n symmetric matrix, supplied in packed form. - - The stride parameters determine how operations are performed. +{{alias}}( ord, uplo, N, α, AP, 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 supplied in packed form. Indexing is relative to the first index. To introduce an offset, use typed array views. If `N` is equal to `0`, the function returns `y` unchanged. - If `α` equals `0.0` and β equals `1.0`, the function returns `y` - unchanged. + If `α` equals `0` and `β` equals `1`, the function returns `y` unchanged. Parameters ---------- ord: string - Row-major (C-style) or column-major (Fortran-style) order. + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. uplo: string - Specifies whether `A` is upper or lower triangular matrix. + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. N: integer - Specifies the order of the matrix `A`. + Number of elements along each dimension of `A`. α: number Scalar constant. - A: Float32Array - Matrix. + AP: Float32Array + Matrix in packed form. x: Float32Array Input vector `x`. @@ -56,33 +55,33 @@ // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x, 1, 1.0, y, 1 ) + > var AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, AP, x, 1, 1.0, y, 1 ) [ ~4.0, ~6.0 ] // Advanced indexing: - > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x, -1, 1.0, y, -1 ) + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, AP, x, -1, 1.0, y, -1 ) [ ~6.0, ~4.0 ] // Using typed array views: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > var y0 = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); + > AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0 ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); > var y1 = new {{alias:@stdlib/array/float32}}( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); - > {{alias}}( 'row-major', 'upper', 2, 1.0, A, x1, -1, 1.0, y1, -1 ) + > {{alias}}( 'row-major', 'upper', 2, 1.0, AP, x1, -1, 1.0, y1, -1 ) > y0 [ ~6.0, ~4.0 ] -{{alias}}.ndarray( ord, uplo, N, α, A, x, sx, ox, β, y, sy, oy ) - Perform one of the matrix-vector operations `y = α*A*x + β*y` - where α and β are scalars, x and y are n element vectors and A is - an n by n symmetric matrix, supplied in packed form using alternative - indexing semantics. +{{alias}}.ndarray( ord, uplo, N, α, AP, 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 supplied in + packed form. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting @@ -91,19 +90,21 @@ Parameters ---------- ord: string - Row-major (C-style) or column-major (Fortran-style) order. + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. uplo: string - Specifies whether `A` is upper or lower triangular matrix. + Specifies whether the upper or lower triangular matrix of `A` is + supplied. Must be either 'upper' or 'lower'. N: integer - Specifies the order of the matrix `A`. + Number of elements along each dimension of `A`. α: number Scalar. - A: Float32Array - Matrix. + AP: Float32Array + Matrix in packed form. x: Float32Array Input vector `x`. @@ -136,19 +137,17 @@ // Standard usage: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > var AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > var ord = 'row-major'; > var uplo = 'upper'; - > {{alias}}.ndarray( ord, uplo, 2, 1.0, A, x, 1, 0, 1.0, y, 1, 0 ) + > {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, x, 1, 0, 1.0, y, 1, 0 ) [ ~4.0, ~6.0 ] // Advanced indexing: - > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); - > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); - > var ord = 'row-major'; - > var uplo = 'upper'; - > {{alias}}.ndarray( ord, uplo, 2, 1.0, A, x, -1, 1, 1.0, y, -1, 1 ) + > x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > AP = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 3.0, 4.0 ] ); + > {{alias}}.ndarray( ord, uplo, 2, 1.0, AP, x, -1, 1, 1.0, y, -1, 1 ) [ ~6.0, ~4.0 ] See Also From 1598acded93cabf1c6f59a0cba98e341c2eee052 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Fri, 21 Jun 2024 21:43:08 -0700 Subject: [PATCH 19/19] docs: update descriptions --- .../@stdlib/blas/base/sspmv/docs/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts index 0a5055b6e86..cf08d1ccba8 100644 --- a/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/sspmv/docs/types/index.d.ts @@ -33,7 +33,7 @@ interface Routine { * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied * @param N - number of columns in the matrix `A` * @param alpha - scalar constant - * @param AP - packed form of symmetric matrix `A` + * @param AP - packed form of a symmetric matrix `A` * @param x - first input array * @param strideX - `x` stride length * @param beta - scalar constant @@ -60,7 +60,7 @@ interface Routine { * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied * @param N - number of columns in the matrix `A` * @param alpha - scalar constant - * @param AP - packed form of symmetric matrix `A` + * @param AP - packed form of a symmetric matrix `A` * @param x - first input array * @param strideX - `x` stride length * @param offsetX - starting `x` index @@ -90,7 +90,7 @@ interface Routine { * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is being supplied * @param N - number of columns in the matrix `A` * @param alpha - scalar constant -* @param AP - packed form of symmetric matrix `A` +* @param AP - packed form of a symmetric matrix `A` * @param x - first input array * @param strideX - `x` stride length * @param beta - scalar constant