From 1f131d3396780a3a798b3ccc17b3975a9b741813 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 30 Jul 2024 08:54:04 +0530 Subject: [PATCH 01/10] feat: add BLAS Level 2 routine for ssyr2 --- .../@stdlib/blas/base/ssyr2/README.md | 265 ++++++ .../blas/base/ssyr2/benchmark/benchmark.js | 105 +++ .../base/ssyr2/benchmark/benchmark.ndarray.js | 105 +++ .../@stdlib/blas/base/ssyr2/docs/repl.txt | 128 +++ .../blas/base/ssyr2/docs/types/index.d.ts | 128 +++ .../blas/base/ssyr2/docs/types/test.ts | 450 ++++++++++ .../@stdlib/blas/base/ssyr2/examples/index.js | 36 + .../@stdlib/blas/base/ssyr2/lib/base.js | 135 +++ .../@stdlib/blas/base/ssyr2/lib/index.js | 72 ++ .../@stdlib/blas/base/ssyr2/lib/main.js | 35 + .../@stdlib/blas/base/ssyr2/lib/ndarray.js | 84 ++ .../@stdlib/blas/base/ssyr2/lib/ssyr2.js | 105 +++ .../@stdlib/blas/base/ssyr2/package.json | 68 ++ .../column_major_complex_access_pattern.json | 17 + .../ssyr2/test/fixtures/column_major_l.json | 18 + .../ssyr2/test/fixtures/column_major_oa.json | 17 + .../test/fixtures/column_major_sa1_sa2.json | 17 + .../test/fixtures/column_major_sa1_sa2n.json | 17 + .../test/fixtures/column_major_sa1n_sa2.json | 17 + .../test/fixtures/column_major_sa1n_sa2n.json | 17 + .../ssyr2/test/fixtures/column_major_u.json | 18 + .../test/fixtures/column_major_xnyn.json | 18 + .../test/fixtures/column_major_xnyp.json | 18 + .../test/fixtures/column_major_xpyn.json | 18 + .../test/fixtures/column_major_xpyp.json | 18 + .../row_major_complex_access_pattern.json | 17 + .../base/ssyr2/test/fixtures/row_major_l.json | 18 + .../ssyr2/test/fixtures/row_major_oa.json | 17 + .../test/fixtures/row_major_sa1_sa2.json | 17 + .../test/fixtures/row_major_sa1_sa2n.json | 17 + .../test/fixtures/row_major_sa1n_sa2.json | 17 + .../test/fixtures/row_major_sa1n_sa2n.json | 17 + .../base/ssyr2/test/fixtures/row_major_u.json | 18 + .../ssyr2/test/fixtures/row_major_xnyn.json | 18 + .../ssyr2/test/fixtures/row_major_xnyp.json | 18 + .../ssyr2/test/fixtures/row_major_xpyn.json | 18 + .../ssyr2/test/fixtures/row_major_xpyp.json | 18 + .../@stdlib/blas/base/ssyr2/test/test.js | 82 ++ .../blas/base/ssyr2/test/test.ndarray.js | 823 ++++++++++++++++++ .../blas/base/ssyr2/test/test.ssyr2.js | 589 +++++++++++++ 40 files changed, 3630 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_l.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_l.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyn.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyp.json create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/README.md b/lib/node_modules/@stdlib/blas/base/ssyr2/README.md new file mode 100644 index 000000000000..2eb53c9a0d7b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/README.md @@ -0,0 +1,265 @@ + + +# ssyr2 + +> Perform the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + +
+ +## Usage + +```javascript +var ssyr2 = require( '@stdlib/blas/base/ssyr2' ); +``` + +#### ssyr2( order, uplo, N, α, x, sx, y, sy, A, LDA ) + +Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced. +- **N**: number of elements along each dimension of `A`. +- **α**: scalar constant. +- **x**: first input [`Float32Array`][mdn-float32array]. +- **sx**: index increment for `x`. +- **y**: second input [`Float32Array`][mdn-float32array]. +- **sy**: index increment for `y`. +- **A**: input matrix stored in linear memory as a [`Float32Array`][mdn-float32array]. +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over every other element of `x`, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssyr2( 'row-major', 'upper', 3, 1.0, x, 2, y, 1, A, 3 ); +// A => [ 3.0, 7.0, 11.0, 0.0, 13.0, 21.0, 0.0, 0.0, 31.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +// Initial arrays... +var x0 = new Float32Array( [ 1.0, 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); + +// Create offset views... +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); // start at 2nd element + +ssyr2( 'row-major', 'upper', 3, 1.0, x1, 1, y1, 1, A, 3 ); +// A => [ 3.0, 5.0, 7.0, 0.0, 5.0, 7.0, 0.0, 0.0, 7.0 ] +``` + +#### ssyr2.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) + +Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssyr2.ndarray( 'upper', 3, 1.0, x, -2, 4, y, 1, 0, A, 3, 1, 0 ); +// A => [ 11.0, 15.0, 19.0, 0.0, 13.0, 13.0, 0.0, 0.0, 7.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. +- **sa1**: stride of the first dimension of `A`. +- **sa2**: stride of the second dimension of `A`. +- **oa**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + +ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +``` + +
+ + + +
+ +## Notes + +- `ssyr2()` corresponds to the [BLAS][blas] level 2 function [`ssyr2`][ssyr2]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var ssyr2 = require( '@stdlib/blas/base/ssyr2' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; + +var A = ones( N*N, opts.dtype ); +var x = discreteUniform( N, -10.0, 10.0, opts ); +var y = discreteUniform( N, -10.0, 10.0, opts ); + +ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +console.log( A ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +TODO +``` + +#### TODO + +TODO. + +```c +TODO +``` + +TODO + +```c +TODO +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +TODO +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.js new file mode 100644 index 000000000000..265f486ca84d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssyr2 = require( './../lib/ssyr2.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var y = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = ssyr2( 'row-major', 'upper', N, 1.0, x, 1, y, 1, A, N ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..3ad7c35d797e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var ssyr2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float32' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = ones( N, options.dtype ); + var y = ones( N, options.dtype ); + var A = ones( N*N, options.dtype ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = ssyr2( 'upper', N, 1.0, x, 1, 0, y, 1, 0, A, N, 1, 0 ); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnanf( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt new file mode 100644 index 000000000000..b029be3e62a8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt @@ -0,0 +1,128 @@ + +{{alias}}( order, uplo, N, α, x, sx, y, sy, A, lda ) + Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where + `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by + `N` symmetric matrix. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + If `N` is equal to `0`, the function returns `A` unchanged. + + If `α` is equal to `0`, the function returns `A` unchanged. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + A: Float32Array + Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float32Array + Output vector. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, x, 1, y, 1, A, 2 ) + [ 3.0, 4.0, 0.0, 4.0 ] + + +{{alias}}.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) + Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, + using alternative indexing semantics, where `α` is a scalar, `x` and `y` + are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + uplo: string + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + x: Float32Array + First input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + y: Float32Array + Second input vector. + + sy: integer + Index increment for `y`. + + oy: integer + Starting index for `y`. + + A: Float32Array + Matrix. + + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. + + oa: integer + Starting index for `A`. + + Returns + ------- + A: Float32Array + Output array. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var y = new {{alias:@stdlib/array/float32}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float32}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > {{alias}}.ndarray( 'upper', 2, 1.0, x, 1, 0, y, 1, 0, A, 2, 1, 0 ) + [ 3.0, 4.0, 0.0, 4.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts new file mode 100644 index 000000000000..23f807602366 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts @@ -0,0 +1,128 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Layout, MatrixTriangle } from '@stdlib/types/blas'; + +/** +* Interface describing `ssyr2`. +*/ +interface Routine { + /** + * Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced + * @param N - number of elements along each dimension in the matrix `A` + * @param alpha - scalar constant + * @param x - first input array + * @param strideX - `x` stride length + * @param y - second input array + * @param strideY - `y` stride length + * @param A - matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns `A` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * + * ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); + * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] + */ + ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number, A: Float32Array, LDA: number ): Float32Array; + + /** + * Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced + * @param N - number of elements along each dimension in the matrix `A` + * @param alpha - scalar constant + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @param y - second input array + * @param strideY - `y` stride length + * @param offsetY - starting index for `y` + * @param A - matrix + * @param strideA1 - stride of the first dimension of `A` + * @param strideA2 - stride of the second dimension of `A` + * @param offsetA - starting index for `A` + * @returns `A` + * + * @example + * var Float32Array = require( '@stdlib/array/float32' ); + * + * var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] + * var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); + * + * ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); + * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] + */ + ndarray( uplo: MatrixTriangle, N: number, alpha: number, x: Float32Array, strideX: number, offsetX: number, A: Float32Array, strideA1: number, strideA2: number, offsetA: number ): Float32Array; +} + +/** +* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced +* @param N - number of elements along each dimension in the matrix `A` +* @param alpha - scalar constant +* @param x - first input array +* @param strideX - `x` stride length +* @param y - second input array +* @param strideY - `y` stride length +* @param A - matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2( 'column-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* // y => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 1, 3, 0 ); +* // y => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +*/ +declare var ssyr2: Routine; + + +// EXPORTS // + +export = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts new file mode 100644 index 000000000000..d10c999feb88 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts @@ -0,0 +1,450 @@ +/* +* @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 ssyr2 = require( './index' ); + + +// TESTS // + +// The function returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 10, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( true, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( false, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( null, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( undefined, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( [], 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( {}, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( ( x: number ): number => x, 'upper', 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 10, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', true, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', false, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', null, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', undefined, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', [ '1' ], 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', {}, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', ( x: number ): number => x, 10, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', '10', 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', true, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', false, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', null, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', undefined, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', [], 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', {}, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', 10, '10', x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, true, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, false, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, null, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, undefined, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, [], x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, {}, x, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, 10, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, '10', 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, true, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, false, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, null, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, undefined, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, {}, 1, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 1, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, '10', y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, true, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, false, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, null, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, undefined, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, [], y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, {}, y, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, y, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, 10, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, '10', 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, true, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, false, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, null, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, undefined, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, [ '1' ], 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, {}, 1, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, 1, A, 10 ); // $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( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, '10', A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, true, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, false, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, null, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, undefined, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, [], A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, {}, A, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, ( x: number ): number => x, A, 10 ); // $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 y = new Float32Array( 10 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, 10, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, '10', 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, true, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, false, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, null, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, undefined, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, [ '1' ], 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, {}, 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, ( x: number ): number => x, 10 ); // $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( 20 ); + + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, '10' ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, true ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, false ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, null ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, undefined ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, [] ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, {} ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2(); // $ExpectError + ssyr2( 'row-major' ); // $ExpectError + ssyr2( 'row-major', 'upper' ); // $ExpectError + ssyr2( 'row-major', 'upper', 10 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1 ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A ); // $ExpectError + ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, A, 10, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectType Float32Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 10, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( true, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( false, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( null, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( undefined, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( [ '1' ], 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( {}, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( ( x: number ): number => x, 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', '10', 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', true, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', false, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', null, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', undefined, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', [], 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', {}, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', ( x: number ): number => x, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, '10', x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, true, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, false, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, null, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, undefined, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, [], x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, {}, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, ( x: number ): number => x, x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a Float32Array... +{ + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, 10, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, '10', 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, true, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, false, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, null, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, undefined, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, [ '1' ], 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, {}, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, ( x: number ): number => x, 1, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, '10', 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, true, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, false, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, null, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, undefined, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, [], 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, {}, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, ( x: number ): number => x, 0, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, '10', y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, true, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, false, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, null, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, undefined, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, [], y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, {}, y, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, ( x: number ): number => x, y, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 1, 0, A, 10, 1, 0 ); // $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( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, '10', 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, true, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, false, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, null, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, undefined, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, [], 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, {}, 0, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, ( x: number ): number => x, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, '10', A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, true, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, false, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, null, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, undefined, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, [], A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, {}, A, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, ( x: number ): number => x, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a Float32Array... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, 10, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, '10', 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, true, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, false, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, null, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, {}, 10, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, '10', 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, true, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, false, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, null, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, undefined, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, [], 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, {}, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a twelfth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, '10', 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, true, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, false, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, null, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, undefined, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, [], 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, {}, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a thirteenth argument which is not a number... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, '10' ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, true ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, false ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, null ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, undefined ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, [] ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, {} ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float32Array( 10 ); + const y = new Float32Array( 10 ); + const A = new Float32Array( 20 ); + + ssyr2.ndarray(); // $ExpectError + ssyr2.ndarray(); // $ExpectError + ssyr2.ndarray( 'upper' ); // $ExpectError + ssyr2.ndarray( 'upper', 10 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1 ); // $ExpectError + ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, y, 1, 0, A, 10, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/examples/index.js b/lib/node_modules/@stdlib/blas/base/ssyr2/examples/index.js new file mode 100644 index 000000000000..107de2f608ec --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var ssyr2 = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +var N = 3; + +var A = ones( N*N, opts.dtype ); +var x = discreteUniform( N, -10.0, 10.0, opts ); +var y = discreteUniform( N, -10.0, 10.0, opts ); + +ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +console.log( A ); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js new file mode 100644 index 000000000000..4ef86164d0df --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js @@ -0,0 +1,135 @@ +/** +* @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 isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var isColMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); +var f32 = require( '@stdlib/number/float64/base/to-float32' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @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 +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +*/ +function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + var temp1; + var temp2; + var ix0; + var ix1; + var iy0; + var iy1; + var sa0; + var sa1; + var i0; + var i1; + var oa; + var ox; + var oy; + + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // isColMajor + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + + ox = offsetX; + oy = offsetY; + ix1 = ox; + iy1 = oy; + if ( + ( isColMajor( [ strideA1, strideA2 ] ) && uplo === 'upper' ) || + ( isRowMajor( [ strideA1, strideA2 ] ) && uplo === 'lower' ) + ) { + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { + temp1 = f32( alpha * y[ iy1 ] ); + temp2 = f32( alpha * x[ ix1 ] ); + oa = offsetA + (sa1*i1); + ix0 = ox; + iy0 = oy; + for ( i0 = 0; i0 <= i1; i0++ ) { + A[ oa + (sa0*i0) ] += f32( f32( x[ ix0 ] * temp1 ) + f32( y[ iy0 ] * temp2 ) ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return A; + } + for ( i1 = 0; i1 < N; i1++ ) { + if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { + temp1 = f32( alpha * y[ iy1 ] ); + temp2 = f32( alpha * x[ ix1 ] ); + ix0 = ix1; + iy0 = iy1; + oa = offsetA + (sa1*i1); + for ( i0 = i1; i0 < N; i0++ ) { + A[ oa + (sa0*i0) ] += f32( f32( x[ ix0 ] * temp1 ) + f32( y[ iy0 ] * temp2 ) ); // eslint-disable-line max-len + ix0 += strideX; + iy0 += strideY; + } + } + ix1 += strideX; + iy1 += strideY; + } + return A; +} + + +// EXPORTS // + +module.exports = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js new file mode 100644 index 000000000000..e383f5805a8b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/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 symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @module @stdlib/blas/base/ssyr2 +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssyr2 = require( '@stdlib/blas/base/ssyr2' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* var ssyr2 = require( '@stdlib/blas/base/ssyr2' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.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 ssyr2; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + ssyr2 = main; +} else { + ssyr2 = tmp; +} + + +// EXPORTS // + +module.exports = ssyr2; + +// exports: { "ndarray": "ssyr2.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/main.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/main.js new file mode 100644 index 000000000000..514776b5252e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/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 ssyr2 = require( './ssyr2.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( ssyr2, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js new file mode 100644 index 000000000000..9028ac77eb5a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js @@ -0,0 +1,84 @@ +/** +* @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 isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @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 +* @param {Float32Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Float32Array} A - input matrix +* @param {integer} strideA1 - stride of the first dimension of `A` +* @param {integer} strideA2 - stride of the second dimension of `A` +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +*/ +function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( N === 0 || alpha === 0.0 ) { + return A; + } + return base( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js new file mode 100644 index 000000000000..031028cb1e59 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.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 max = require( '@stdlib/math/base/special/max' ); +var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced +* @param {NonNegativeInteger} N - number of elements along each dimension of `A` +* @param {number} alpha - scalar +* @param {Float32Array} x - first input vector +* @param {integer} strideX - `x` stride length +* @param {Float32Array} y - second input vector +* @param {integer} strideY - `y` stride length +* @param {Float32Array} A - input matrix +* @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @throws {TypeError} first argument must be a valid order +* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} third argument must be a nonnegative integer +* @throws {RangeError} sixth argument must be non-zero +* @throws {RangeError} eighth argument must be greater than or equal to max(1,N) +* @returns {Float32Array} `A` +* +* @example +* var Float32Array = require( '@stdlib/array/float32' ); +* +* var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // => [ [ 1.0, 2.0, 3.0 ], [ 0.0, 1.0, 2.0 ], [ 0.0, 0.0, 1.0 ] ] +* var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +* +* ssyr2( 'row-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); +* // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +*/ +function ssyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { + var sa1; + var sa2; + var ox; + var oy; + + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + if ( !isMatrixTriangle( uplo ) ) { + throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + } + if ( N < 0 ) { + throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + } + if ( strideX === 0 ) { + throw new RangeError( format( 'invalid argument. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( strideY === 0 ) { + throw new RangeError( format( 'invalid argument. Eighth argument must be non-zero. Value: `%d`.', strideX ) ); + } + if ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Tenth argument must be greater than or equal to max(1,%d). Value: `%d`.', N, LDA ) ); + } + if ( N === 0 || alpha === 0.0 ) { + return A; + } + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + ox = stride2offset( N, strideX ); + oy = stride2offset( N, strideY ); + return base( uplo, N, alpha, x, strideX, ox, y, strideY, oy, A, sa1, sa2, 0 ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ssyr2; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/package.json b/lib/node_modules/@stdlib/blas/base/ssyr2/package.json new file mode 100644 index 000000000000..a1d4d66d96b2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/ssyr2", + "version": "0.0.0", + "description": "Perform the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "blas", + "level 2", + "ssyr2", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float32", + "float", + "float32array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_complex_access_pattern.json new file mode 100644 index 000000000000..f62579868149 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_complex_access_pattern.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": -1, + "offsetX": 2, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 2.0, 999.0, 3.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 1.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 1.0 ], + "strideA1": -2, + "strideA2": -10, + "offsetA": 29, + "A_out": [ 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 6.0, 999.0, 9.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 9.0, 999.0, 14.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_l.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_l.json new file mode 100644 index 000000000000..781a5a56fc1b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_l.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 5.0, 9.0, 13.0, 0.0, 18.0, 26.0, 0.0, 0.0, 39.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_oa.json new file mode 100644 index 000000000000..b01a1efbe2a5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_oa.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 1.0, 1.0, 1.0, 999.0, 999.0, 0.0, 2.0, 2.0, 999.0, 999.0, 0.0, 0.0, 3.0, 999.0 ], + "strideA1": 1, + "strideA2": 5, + "offsetA": 1, + "A_out": [ 999.0, 5.0, 9.0, 13.0, 999.0, 999.0, 0.0, 18.0, 26.0, 999.0, 999.0, 0.0, 0.0, 39.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2.json new file mode 100644 index 000000000000..62cdc5b269d7 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 1.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 2.0, 999.0, 1.0 ], + "strideA1": 2, + "strideA2": 10, + "offsetA": 5, + "A_out": [ 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 6.0, 999.0, 9.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 9.0, 999.0, 14.0, 999.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2n.json new file mode 100644 index 000000000000..d77b0e2955de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1_sa2n.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 2.0, 999.0, 1.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 1.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 0.0, 999.0, 0.0 ], + "strideA1": 2, + "strideA2": -10, + "offsetA": 25, + "A_out": [ 999.0, 999.0, 999.0, 999.0, 999.0, 9.0, 999.0, 14.0, 999.0, 19.0, 999.0, 999.0, 999.0, 999.0, 999.0, 6.0, 999.0, 9.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 0.0, 999.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2.json new file mode 100644 index 000000000000..bd1fea14ca2d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 1.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 1.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 2.0, 999.0, 3.0 ], + "strideA1": -2, + "strideA2": 10, + "offsetA": 9, + "A_out": [ 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 3.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 9.0, 999.0, 6.0, 999.0, 999.0, 999.0, 999.0, 999.0, 19.0, 999.0, 14.0, 999.0, 9.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2n.json new file mode 100644 index 000000000000..32e3298705ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_sa1n_sa2n.json @@ -0,0 +1,17 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 2.0, 999.0, 3.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 1.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 1.0 ], + "strideA1": -2, + "strideA2": -10, + "offsetA": 29, + "A_out": [ 999.0, 999.0, 999.0, 999.0, 999.0, 19.0, 999.0, 14.0, 999.0, 9.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 9.0, 999.0, 6.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_u.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_u.json new file mode 100644 index 000000000000..fac00d3bf1cb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_u.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyn.json new file mode 100644 index 000000000000..790473bbd53f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyn.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 31.0, 0.0, 0.0, 21.0, 13.0, 0.0, 11.0, 7.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyp.json new file mode 100644 index 000000000000..3cbe3d71e9a3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xnyp.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 11.0, 0.0, 0.0, 15.0, 13.0, 0.0, 19.0, 13.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyn.json new file mode 100644 index 000000000000..072dcef02fc9 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyn.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 7.0, 0.0, 0.0, 13.0, 13.0, 0.0, 19.0, 15.0, 11.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyp.json new file mode 100644 index 000000000000..d8685725d61a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/column_major_xpyp.json @@ -0,0 +1,18 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 2.0, 1.0, 0.0, 3.0, 2.0, 1.0 ], + "lda": 3, + "strideA1": 1, + "strideA2": 3, + "offsetA": 0, + "A_out": [ 3.0, 0.0, 0.0, 7.0, 13.0, 0.0, 11.0, 21.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_complex_access_pattern.json new file mode 100644 index 000000000000..5f837f8085ee --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_complex_access_pattern.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": -1, + "offsetX": 2, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 999.0, 1.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 1.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 2.0, 999.0, 1.0, 999.0 ], + "strideA1": -14, + "strideA2": -2, + "offsetA": 33, + "A_out": [ 999.0, 3.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 6.0, 999.0, 9.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 9.0, 999.0, 14.0, 999.0, 19.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_l.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_l.json new file mode 100644 index 000000000000..c012cf3c4087 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_l.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 5.0, 0.0, 0.0, 9.0, 18.0, 0.0, 13.0, 26.0, 39.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_oa.json new file mode 100644 index 000000000000..719ee5a0d020 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_oa.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 999.0, 999.0, 1.0, 0.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 3.0, 999.0, 999.0, 999.0 ], + "strideA1": 3, + "strideA2": 1, + "offsetA": 3, + "A_out": [ 999.0, 999.0, 999.0, 5.0, 0.0, 0.0, 9.0, 18.0, 0.0, 13.0, 26.0, 39.0, 999.0, 999.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2.json new file mode 100644 index 000000000000..fca54b56fe48 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 1.0, 999.0, 2.0, 999.0, 3.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 1.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 1.0, 999.0 ], + "strideA1": 14, + "strideA2": 2, + "offsetA": 1, + "A_out": [ 999.0, 3.0, 999.0, 6.0, 999.0, 9.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 9.0, 999.0, 14.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 19.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2n.json new file mode 100644 index 000000000000..b61992d216bf --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1_sa2n.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 3.0, 999.0, 2.0, 999.0, 1.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 1.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 0.0, 999.0, 0.0, 999.0 ], + "strideA1": 14, + "strideA2": -2, + "offsetA": 5, + "A_out": [ 999.0, 9.0, 999.0, 6.0, 999.0, 3.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 14.0, 999.0, 9.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 19.0, 999.0, 0.0, 999.0, 0.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2.json new file mode 100644 index 000000000000..d57c31d84494 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 0.0, 999.0, 0.0, 999.0, 1.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 1.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 1.0, 999.0, 2.0, 999.0, 3.0, 999.0 ], + "strideA1": -14, + "strideA2": 2, + "offsetA": 29, + "A_out": [ 999.0, 0.0, 999.0, 0.0, 999.0, 19.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 9.0, 999.0, 14.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 6.0, 999.0, 9.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2n.json new file mode 100644 index 000000000000..7233e480e28d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_sa1n_sa2n.json @@ -0,0 +1,17 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 999.0, 1.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 1.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 3.0, 999.0, 2.0, 999.0, 1.0, 999.0 ], + "strideA1": -14, + "strideA2": -2, + "offsetA": 33, + "A_out": [ 999.0, 19.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 14.0, 999.0, 9.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 9.0, 999.0, 6.0, 999.0, 3.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_u.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_u.json new file mode 100644 index 000000000000..b499e7cb6e5d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_u.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyn.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyn.json new file mode 100644 index 000000000000..95d3b0a50ddb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyn.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 31.0, 21.0, 11.0, 0.0, 13.0, 7.0, 0.0, 0.0, 3.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyp.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyp.json new file mode 100644 index 000000000000..68d29ef3823e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xnyp.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": -2, + "offsetX": 4, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 11.0, 15.0, 19.0, 0.0, 13.0, 13.0, 0.0, 0.0, 7.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyn.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyn.json new file mode 100644 index 000000000000..b1bf41bbbff8 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyn.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": -1, + "offsetY": 2, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 7.0, 13.0, 19.0, 0.0, 13.0, 15.0, 0.0, 0.0, 11.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyp.json b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyp.json new file mode 100644 index 000000000000..f9a3880cb2e3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/fixtures/row_major_xpyp.json @@ -0,0 +1,18 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0, 4.0, 5.0 ], + "strideX": 2, + "offsetX": 0, + "y": [ 1.0, 2.0, 3.0 ], + "strideY": 1, + "offsetY": 0, + "A": [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ], + "lda": 3, + "strideA1": 3, + "strideA2": 1, + "offsetA": 0, + "A_out": [ 3.0, 7.0, 11.0, 0.0, 13.0, 21.0, 0.0, 0.0, 31.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.js new file mode 100644 index 000000000000..334ed8b828fe --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/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 ssyr2 = 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 ssyr2, '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 ssyr2.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 ssyr2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssyr2, 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 ssyr2; + var main; + + main = require( './../lib/ssyr2.js' ); + + ssyr2 = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( ssyr2, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js new file mode 100644 index 000000000000..7d080e3f309a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js @@ -0,0 +1,823 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ssyr2 = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.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 roa = require( './fixtures/row_major_oa.json' ); +var rsa1sa2 = require( './fixtures/row_major_sa1_sa2.json' ); +var rsa1nsa2 = require( './fixtures/row_major_sa1n_sa2.json' ); +var rsa1sa2n = require( './fixtures/row_major_sa1_sa2n.json' ); +var rsa1nsa2n = require( './fixtures/row_major_sa1n_sa2n.json' ); +var rcap = require( './fixtures/row_major_complex_access_pattern.json' ); + +var cu = require( './fixtures/column_major_u.json' ); +var cl = require( './fixtures/column_major_l.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' ); +var coa = require( './fixtures/column_major_oa.json' ); +var csa1sa2 = require( './fixtures/column_major_sa1_sa2.json' ); +var csa1nsa2 = require( './fixtures/column_major_sa1n_sa2.json' ); +var csa1sa2n = require( './fixtures/column_major_sa1_sa2n.json' ); +var csa1nsa2n = require( './fixtures/column_major_sa1n_sa2n.json' ); +var ccap = require( './fixtures/column_major_complex_access_pattern.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 ssyr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 13', function test( t ) { + t.strictEqual( ssyr2.length, 13, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.uplo, value, data.alpha, new Float32Array( data.x ), data.strideX, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, data.offsetX, new Float32Array( data.y ), data.strideY, data.offsetY, new Float32Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cu; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the input matrix `A`', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = ssyr2( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = ssyr2( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = ssyr2( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = ssyr2( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying stride of the first and the second dimension of `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying stride of the first and the second dimension of `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `strideA1` parameter (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `strideA1` parameter (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `strideA2` parameter (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports a negative `strideA2` parameter (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1sa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rsa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports negative strides for `A` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = csa1nsa2n; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `A` offset (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = roa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `A` offset (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = coa; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` stride values (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying `x` and `y` stride values (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying negative strides for `x` and `y` (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rcap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ccap; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, y, data.strideY, data.offsetY, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js new file mode 100644 index 000000000000..dece73c280c4 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js @@ -0,0 +1,589 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float32Array = require( '@stdlib/array/float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var ssyr2 = require( './../lib/ssyr2.js' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.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 cu = require( './fixtures/column_major_u.json' ); +var cl = require( './fixtures/column_major_l.json' ); +var cxpyp = require( './fixtures/column_major_xpyp.json' ); +var cxnyp = require( './fixtures/column_major_xnyp.json' ); +var cxpyn = require( './fixtures/column_major_xpyn.json' ); +var cxnyn = require( './fixtures/column_major_xnyn.json' ); + + +// FUNCTIONS // + +/** +* Tests for element-wise approximate equality. +* +* @private +* @param {Object} t - test object +* @param {Collection} actual - actual values +* @param {Collection} expected - expected values +* @param {number} rtol - relative tolerance +*/ +function isApprox( t, actual, expected, rtol ) { + var delta; + var tol; + var i; + + t.strictEqual( actual.length, expected.length, 'returns expected value' ); + for ( i = 0; i < expected.length; i++ ) { + if ( actual[ i ] === expected[ i ] ) { + t.strictEqual( actual[ i ], expected[ i ], 'returns expected value' ); + } else { + delta = abs( actual[ i ] - expected[ i ] ); + tol = rtol * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. actual: '+actual[ i ]+'. expected: '+expected[ i ]+'. delta: '+delta+'. tol: '+tol+'.' ); + } + } +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ssyr2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( ssyr2.length, 10, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( value, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid second argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.order, value, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid third argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.order, data.uplo, value, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), value, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid eighth argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + 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() { + ssyr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), value, new Float32Array( data.A ), data.lda ); + }; + } +}); + +tape( 'the function throws an error if provided an invalid tenth argument', function test( t ) { + var values; + var data; + var i; + + data = ru; + + values = [ + 2, + 1, + 0, + -1, + -2, + -3 + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[ i ] ), RangeError, 'throws an error when provided ' + values[ i ] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + ssyr2( data.order, data.uplo, data.N, data.alpha, new Float32Array( data.x ), data.strideX, new Float32Array( data.y ), data.strideY, new Float32Array( data.A ), value ); + }; + } +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cu; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function returns a reference to the input matrix `A`', function test( t ) { + var data; + var out; + var a; + var x; + var y; + + data = ru; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = ssyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = ssyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'if `N` is zero or the scalar constant is zero, the function returns the input matrix `A` unchanged (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cl; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A ); + + out = ssyr2( data.order, data.uplo, 0, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = ssyr2( data.order, data.uplo, data.N, 0.0, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying strides (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying strides (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyp; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying a negative `y` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxpyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = rxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports complex access patterns (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + var y; + + data = cxnyn; + + a = new Float32Array( data.A ); + x = new Float32Array( data.x ); + y = new Float32Array( data.y ); + + expected = new Float32Array( data.A_out ); + + out = ssyr2( data.order, data.uplo, data.N, data.alpha, x, data.strideX, y, data.strideY, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); From 214f0582c179d9b62e97b9a2bd15388eed796c2e Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 30 Jul 2024 10:08:13 +0530 Subject: [PATCH 02/10] docs: update descriptions and error types --- lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js | 4 ---- lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js index 4ef86164d0df..4eb98f84e4b5 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js @@ -43,10 +43,6 @@ var f32 = require( '@stdlib/number/float64/base/to-float32' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` -* @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied -* @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} sixth argument must be non-zero * @returns {Float32Array} `A` * * @example diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js index 9028ac77eb5a..90b8783f075c 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js @@ -43,10 +43,10 @@ var base = require( './base.js' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` -* @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied -* @throws {RangeError} third argument must be a nonnegative integer -* @throws {RangeError} sixth argument must be non-zero +* @throws {TypeError} first argument must specify whether the lower or upper triangular matrix is supplied +* @throws {RangeError} second argument must be a nonnegative integer +* @throws {RangeError} fifth argument must be non-zero +* @throws {RangeError} eighth argument must be non-zero * @returns {Float32Array} `A` * * @example From 79692fb1a8e91fe9d250a78a52e975a552b6277c Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:46:17 -0700 Subject: [PATCH 03/10] refactor: update descriptions, fix missing tag, and light clean-up --- .../@stdlib/blas/base/ssyr2/lib/base.js | 34 ++++++++++--------- .../@stdlib/blas/base/ssyr2/lib/index.js | 2 +- .../@stdlib/blas/base/ssyr2/lib/ndarray.js | 6 ++-- .../@stdlib/blas/base/ssyr2/lib/ssyr2.js | 8 ++--- 4 files changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js index 4eb98f84e4b5..ff990d7755cc 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/base.js @@ -21,15 +21,15 @@ // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var isColMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); var f32 = require( '@stdlib/number/float64/base/to-float32' ); // MAIN // /** -* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * +* @private * @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 @@ -56,8 +56,9 @@ var f32 = require( '@stdlib/number/float64/base/to-float32' ); * // A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] */ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params - var temp1; - var temp2; + var tmp1; + var tmp2; + var isrm; var ix0; var ix1; var iy0; @@ -70,33 +71,33 @@ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str var ox; var oy; - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + isrm = isRowMajor( [ strideA1, strideA2 ] ); + if ( isrm ) { // row-major // For row-major matrices, the last dimension has the fastest changing index... sa0 = strideA2; // stride for innermost loop sa1 = strideA1; // stride for outermost loop - } else { // isColMajor + } else { // column-major // For column-major matrices, the first dimension has the fastest changing index... sa0 = strideA1; // stride for innermost loop sa1 = strideA2; // stride for outermost loop } - ox = offsetX; oy = offsetY; ix1 = ox; iy1 = oy; if ( - ( isColMajor( [ strideA1, strideA2 ] ) && uplo === 'upper' ) || - ( isRowMajor( [ strideA1, strideA2 ] ) && uplo === 'lower' ) + ( isrm && uplo === 'lower' ) || + ( !isrm && uplo === 'upper' ) ) { for ( i1 = 0; i1 < N; i1++ ) { if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { - temp1 = f32( alpha * y[ iy1 ] ); - temp2 = f32( alpha * x[ ix1 ] ); + tmp1 = f32( alpha * y[ iy1 ] ); + tmp2 = f32( alpha * x[ ix1 ] ); oa = offsetA + (sa1*i1); ix0 = ox; iy0 = oy; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa + (sa0*i0) ] += f32( f32( x[ ix0 ] * temp1 ) + f32( y[ iy0 ] * temp2 ) ); // eslint-disable-line max-len + A[ oa+(sa0*i0) ] += f32( f32( x[ ix0 ] * tmp1 ) + f32( y[ iy0 ] * tmp2 ) ); // eslint-disable-line max-len ix0 += strideX; iy0 += strideY; } @@ -106,15 +107,16 @@ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, str } return A; } + // ( isrm && uplo === 'upper' ) || ( !isrm && uplo === 'lower' ) for ( i1 = 0; i1 < N; i1++ ) { if ( ( x[ ix1 ] !== 0.0 ) || ( y[ iy1 ] !== 0.0 ) ) { - temp1 = f32( alpha * y[ iy1 ] ); - temp2 = f32( alpha * x[ ix1 ] ); + tmp1 = f32( alpha * y[ iy1 ] ); + tmp2 = f32( alpha * x[ ix1 ] ); + oa = offsetA + (sa1*i1); ix0 = ix1; iy0 = iy1; - oa = offsetA + (sa1*i1); for ( i0 = i1; i0 < N; i0++ ) { - A[ oa + (sa0*i0) ] += f32( f32( x[ ix0 ] * temp1 ) + f32( y[ iy0 ] * temp2 ) ); // eslint-disable-line max-len + A[ oa+(sa0*i0) ] += f32( f32( x[ ix0 ] * tmp1 ) + f32( y[ iy0 ] * tmp2 ) ); // eslint-disable-line max-len ix0 += strideX; iy0 += strideY; } diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js index e383f5805a8b..d7c735e345fe 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* BLAS level 2 routine to perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @module @stdlib/blas/base/ssyr2 * diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js index 90b8783f075c..bd593f06a18c 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ndarray.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @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` @@ -43,7 +43,7 @@ var base = require( './base.js' ); * @param {integer} strideA1 - stride of the first dimension of `A` * @param {integer} strideA2 - stride of the second dimension of `A` * @param {NonNegativeInteger} offsetA - starting index for `A` -* @throws {TypeError} first argument must specify whether the lower or upper triangular matrix is supplied +* @throws {TypeError} first argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} second argument must be a nonnegative integer * @throws {RangeError} fifth argument must be non-zero * @throws {RangeError} eighth argument must be non-zero @@ -61,7 +61,7 @@ var base = require( './base.js' ); */ function ssyr2( uplo, N, alpha, x, strideX, offsetX, y, strideY, offsetY, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params if ( !isMatrixTriangle( uplo ) ) { - throw new TypeError( format( 'invalid argument. First argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + throw new TypeError( format( 'invalid argument. First argument must specify whether the reference the lower or upper triangular matrix. Value: `%s`.', uplo ) ); } if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Second argument must be a nonnegative integer. Value: `%d`.', N ) ); diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js index 031028cb1e59..87adeb40c646 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/lib/ssyr2.js @@ -20,7 +20,7 @@ // MODULES // -var max = require( '@stdlib/math/base/special/max' ); +var max = require( '@stdlib/math/base/special/fast/max' ); var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); var stride2offset = require( '@stdlib/strided/base/stride2offset' ); @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced @@ -44,7 +44,7 @@ var base = require( './base.js' ); * @param {Float32Array} A - input matrix * @param {integer} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) * @throws {TypeError} first argument must be a valid order -* @throws {TypeError} second argument must specify whether the lower or upper triangular matrix is supplied +* @throws {TypeError} second argument must specify whether to reference the lower or upper triangular matrix * @throws {RangeError} third argument must be a nonnegative integer * @throws {RangeError} sixth argument must be non-zero * @throws {RangeError} eighth argument must be greater than or equal to max(1,N) @@ -70,7 +70,7 @@ function ssyr2( order, uplo, N, alpha, x, strideX, y, strideY, A, LDA ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } if ( !isMatrixTriangle( uplo ) ) { - throw new TypeError( format( 'invalid argument. Second argument must specify whether the lower or upper triangular matrix is supplied. Value: `%s`.', uplo ) ); + throw new TypeError( format( 'invalid argument. Second argument must specify whether to reference the lower or upper triangular matrix. Value: `%s`.', uplo ) ); } if ( N < 0 ) { throw new RangeError( format( 'invalid argument. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); From 523df35211e7e0b8a536ae6d9d9b3f00377a5f08 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:49:14 -0700 Subject: [PATCH 04/10] docs: fix interface docs --- .../@stdlib/blas/base/ssyr2/docs/types/index.d.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts index 23f807602366..78911e139f05 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/index.d.ts @@ -27,10 +27,10 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param order - storage layout - * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N - number of elements along each dimension in the matrix `A` * @param alpha - scalar constant * @param x - first input array @@ -54,9 +54,8 @@ interface Routine { ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float32Array, strideX: number, y: Float32Array, strideY: number, A: Float32Array, LDA: number ): Float32Array; /** - * Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + * Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * - * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N - number of elements along each dimension in the matrix `A` * @param alpha - scalar constant @@ -86,10 +85,10 @@ interface Routine { } /** -* Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. * * @param order - storage layout -* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` is to be referenced +* @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced * @param N - number of elements along each dimension in the matrix `A` * @param alpha - scalar constant * @param x - first input array @@ -108,7 +107,7 @@ interface Routine { * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * * ssyr2( 'column-major', 'upper', 3, 1.0, x, 1, y, 1, A, 3 ); -* // y => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +* // A => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] * * @example * var Float32Array = require( '@stdlib/array/float32' ); @@ -118,7 +117,7 @@ interface Routine { * var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); * * ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 1, 3, 0 ); -* // y => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] +* // A => [ 3.0, 0.0, 0.0, 6.0, 9.0, 0.0, 9.0, 14.0, 19.0 ] */ declare var ssyr2: Routine; From 0c1c72295cca1216d6ffb8b3a7e4da5a6599b11a Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:50:58 -0700 Subject: [PATCH 05/10] docs: fix grammar --- lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts index d10c999feb88..bd160723ebc1 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/types/test.ts @@ -142,7 +142,7 @@ import ssyr2 = require( './index' ); ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, 1, A, 10 ); // $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 ); @@ -174,7 +174,7 @@ import ssyr2 = require( './index' ); ssyr2( 'row-major', 'upper', 10, 1.0, x, 1, y, 1, ( x: number ): number => x, 10 ); // $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 ); @@ -330,7 +330,7 @@ import ssyr2 = require( './index' ); ssyr2.ndarray( 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 1, 0, A, 10, 1, 0 ); // $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 ); From 3ae8492aa9ee3722fb8530fcadb2c3fd7621b6fd Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:53:03 -0700 Subject: [PATCH 06/10] docs: update descriptions --- .../@stdlib/blas/base/ssyr2/docs/repl.txt | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt index b029be3e62a8..d1191871895a 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/docs/repl.txt @@ -1,15 +1,14 @@ {{alias}}( order, uplo, N, α, x, sx, y, sy, A, lda ) - Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where + Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. Indexing is relative to the first index. To introduce an offset, use typed array views. - If `N` is equal to `0`, the function returns `A` unchanged. - - If `α` is equal to `0`, the function returns `A` unchanged. + If `N` is equal to `0` or `α` is equal to `0`, the function returns `A` + unchanged. Parameters ---------- @@ -49,7 +48,7 @@ Returns ------- A: Float32Array - Output vector. + Input matrix. Examples -------- @@ -61,9 +60,9 @@ {{alias}}.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) - Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, - using alternative indexing semantics, where `α` is a scalar, `x` and `y` - are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using + alternative indexing semantics and where `α` is a scalar, `x` and `y` are + `N` element vectors, and `A` is an `N` by `N` symmetric matrix. While typed array views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting @@ -114,7 +113,7 @@ Returns ------- A: Float32Array - Output array. + Input matrix. Examples -------- From b71ee6f310ca459b17c6613a233ef65062e5e9cb Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:54:41 -0700 Subject: [PATCH 07/10] docs: simplify description --- lib/node_modules/@stdlib/blas/base/ssyr2/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/package.json b/lib/node_modules/@stdlib/blas/base/ssyr2/package.json index a1d4d66d96b2..cf7b13d10bb4 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/package.json +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/ssyr2", "version": "0.0.0", - "description": "Perform the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix.", + "description": "Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From 3a131db6df91c7a21ab7f44c87d644ef19903ebb Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 02:57:48 -0700 Subject: [PATCH 08/10] docs: simplify description and fix example order --- .../@stdlib/blas/base/ssyr2/README.md | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/README.md b/lib/node_modules/@stdlib/blas/base/ssyr2/README.md index 2eb53c9a0d7b..1901c5737ee8 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/README.md +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/README.md @@ -20,7 +20,7 @@ limitations under the License. # ssyr2 -> Perform the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +> Perform the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`.
@@ -32,7 +32,7 @@ var ssyr2 = require( '@stdlib/blas/base/ssyr2' ); #### ssyr2( order, uplo, N, α, x, sx, y, sy, A, LDA ) -Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); @@ -79,13 +79,13 @@ Note that indexing is relative to the first index. To introduce an offset, use [ var Float32Array = require( '@stdlib/array/float32' ); // Initial arrays... -var x0 = new Float32Array( [ 1.0, 1.0, 1.0 ] ); -var y0 = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var x0 = new Float32Array( [ 0.0, 1.0, 1.0, 1.0 ] ); +var y0 = new Float32Array( [ 0.0, 1.0, 2.0, 3.0 ] ); var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); // Create offset views... -var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*0 ); // start at 2nd element -var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*0 ); // start at 2nd element +var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element +var y1 = new Float32Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element ssyr2( 'row-major', 'upper', 3, 1.0, x1, 1, y1, 1, A, 3 ); // A => [ 3.0, 5.0, 7.0, 0.0, 5.0, 7.0, 0.0, 0.0, 7.0 ] @@ -93,17 +93,17 @@ ssyr2( 'row-major', 'upper', 3, 1.0, x1, 1, y1, 1, A, 3 ); #### ssyr2.ndarray( uplo, N, α, x, sx, ox, y, sy, oy, A, sa1, sa2, oa ) -Performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +Performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. ```javascript var Float32Array = require( '@stdlib/array/float32' ); var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); -var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -ssyr2.ndarray( 'upper', 3, 1.0, x, -2, 4, y, 1, 0, A, 3, 1, 0 ); -// A => [ 11.0, 15.0, 19.0, 0.0, 13.0, 13.0, 0.0, 0.0, 7.0 ] +ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); +// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] ``` The function has the following additional parameters: @@ -120,11 +120,11 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float32Array = require( '@stdlib/array/float32' ); var A = new Float32Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); -var x = new Float32Array( [ 1.0, 2.0, 3.0 ] ); +var x = new Float32Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); var y = new Float32Array( [ 1.0, 2.0, 3.0 ] ); -ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); -// A => [ 3.0, 6.0, 9.0, 0.0, 9.0, 14.0, 0.0, 0.0, 19.0 ] +ssyr2.ndarray( 'upper', 3, 1.0, x, -2, 4, y, 1, 0, A, 3, 1, 0 ); +// A => [ 11.0, 15.0, 19.0, 0.0, 13.0, 13.0, 0.0, 0.0, 7.0 ] ```
@@ -135,7 +135,7 @@ ssyr2.ndarray( 'upper', 3, 1.0, x, 1, 0, y, 1, 0, A, 3, 1, 0 ); ## Notes -- `ssyr2()` corresponds to the [BLAS][blas] level 2 function [`ssyr2`][ssyr2]. +- `ssyr2()` corresponds to the [BLAS][blas] level 2 function [`ssyr2`][blas-ssyr2]. @@ -254,7 +254,7 @@ TODO [blas]: http://www.netlib.org/blas -[ssyr2]: https://www.netlib.org/lapack/explore-html/dd/de5/group__her2_ga6741f2ac8fe025042fd994ccc6625b45.html#ga6741f2ac8fe025042fd994ccc6625b45 +[blas-ssyr2]: https://www.netlib.org/lapack/explore-html/dd/de5/group__her2_ga6741f2ac8fe025042fd994ccc6625b45.html#ga6741f2ac8fe025042fd994ccc6625b45 [mdn-float32array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array From 3dffceea4f456a9d9e918a95ca2ba8d44b1965e1 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 03:02:42 -0700 Subject: [PATCH 09/10] test: update descriptions --- .../@stdlib/blas/base/ssyr2/test/test.ndarray.js | 8 ++++---- .../@stdlib/blas/base/ssyr2/test/test.ssyr2.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js index 7d080e3f309a..95e0ef8f1510 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js @@ -197,7 +197,7 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun } }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { var expected; var data; var out; @@ -220,7 +220,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test( t ) { var expected; var data; var out; @@ -243,7 +243,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test( t ) { var expected; var data; var out; @@ -266,7 +266,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test( t ) { var expected; var data; var out; diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js index dece73c280c4..9c5bbe8e65db 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ssyr2.js @@ -239,7 +239,7 @@ tape( 'the function throws an error if provided an invalid tenth argument', func } }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, upper)', function test( t ) { var expected; var data; var out; @@ -262,7 +262,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, upper)', function test( t ) { var expected; var data; var out; @@ -285,7 +285,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (row-major, lower)', function test( t ) { var expected; var data; var out; @@ -308,7 +308,7 @@ tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α* t.end(); }); -tape( 'the function performs the symmetric rank 2 operation `A = α*x*y**T + α*y*x**T + A` where `α` is a scalar, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 2 operation `A = α*x*y^T + α*y*x^T + A` (column-major, lower)', function test( t ) { var expected; var data; var out; From 095b92519e0d8d2f97d5536b280e81d1029782ca Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Tue, 30 Jul 2024 03:05:23 -0700 Subject: [PATCH 10/10] test: update descriptions --- .../@stdlib/blas/base/ssyr2/test/test.ndarray.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js index 95e0ef8f1510..8bb9e87e537d 100644 --- a/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/ssyr2/test/test.ndarray.js @@ -362,7 +362,7 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i t.end(); }); -tape( 'the function supports specifying stride of the first and the second dimension of `A` (row-major)', function test( t ) { +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -385,7 +385,7 @@ tape( 'the function supports specifying stride of the first and the second dimen t.end(); }); -tape( 'the function supports specifying stride of the first and the second dimension of `A` (column-major)', function test( t ) { +tape( 'the function supports specifying the strides for the first and the second dimensions of `A` (column-major)', function test( t ) { var expected; var data; var out; @@ -408,7 +408,7 @@ tape( 'the function supports specifying stride of the first and the second dimen t.end(); }); -tape( 'the function supports a negative `strideA1` parameter (row-major)', function test( t ) { +tape( 'the function supports a negative stride for the first dimension of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -431,7 +431,7 @@ tape( 'the function supports a negative `strideA1` parameter (row-major)', funct t.end(); }); -tape( 'the function supports a negative `strideA1` parameter (column-major)', function test( t ) { +tape( 'the function supports a negative stride for the first dimension of `A` (column-major)', function test( t ) { var expected; var data; var out; @@ -454,7 +454,7 @@ tape( 'the function supports a negative `strideA1` parameter (column-major)', fu t.end(); }); -tape( 'the function supports a negative `strideA2` parameter (row-major)', function test( t ) { +tape( 'the function supports a negative stride for the second dimension of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -477,7 +477,7 @@ tape( 'the function supports a negative `strideA2` parameter (row-major)', funct t.end(); }); -tape( 'the function supports a negative `strideA2` parameter (column-major)', function test( t ) { +tape( 'the function supports a negative stride for the second dimension of `A` (column-major)', function test( t ) { var expected; var data; var out; @@ -592,7 +592,7 @@ tape( 'the function supports specifying an `A` offset (column-major)', function t.end(); }); -tape( 'the function supports specifying `x` and `y` stride values (row-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (row-major)', function test( t ) { var expected; var data; var out; @@ -615,7 +615,7 @@ tape( 'the function supports specifying `x` and `y` stride values (row-major)', t.end(); }); -tape( 'the function supports specifying `x` and `y` stride values (column-major)', function test( t ) { +tape( 'the function supports specifying `x` and `y` strides (column-major)', function test( t ) { var expected; var data; var out;