From 99d64dcfe9d1103c33e4e0bac8a604db3a998115 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 25 Jul 2024 17:01:54 +0530 Subject: [PATCH 1/8] feat: add BLAS Level 2 routine for dsyr --- .../@stdlib/blas/base/dsyr/README.md | 253 +++++++ .../blas/base/dsyr/benchmark/benchmark.js | 104 +++ .../base/dsyr/benchmark/benchmark.ndarray.js | 104 +++ .../@stdlib/blas/base/dsyr/docs/repl.txt | 115 +++ .../blas/base/dsyr/docs/types/index.d.ts | 117 +++ .../@stdlib/blas/base/dsyr/docs/types/test.ts | 358 +++++++++ .../@stdlib/blas/base/dsyr/examples/index.js | 35 + .../@stdlib/blas/base/dsyr/lib/base.js | 114 +++ .../@stdlib/blas/base/dsyr/lib/dsyr.js | 97 +++ .../@stdlib/blas/base/dsyr/lib/index.js | 70 ++ .../@stdlib/blas/base/dsyr/lib/main.js | 35 + .../@stdlib/blas/base/dsyr/lib/ndarray.js | 82 +++ .../@stdlib/blas/base/dsyr/package.json | 68 ++ .../column_major_complex_access_pattern.json | 14 + .../dsyr/test/fixtures/column_major_l.json | 15 + .../dsyr/test/fixtures/column_major_oa.json | 14 + .../test/fixtures/column_major_sa1_sa2.json | 14 + .../test/fixtures/column_major_sa1_sa2n.json | 14 + .../test/fixtures/column_major_sa1n_sa2.json | 14 + .../test/fixtures/column_major_sa1n_sa2n.json | 14 + .../dsyr/test/fixtures/column_major_u.json | 15 + .../dsyr/test/fixtures/column_major_xn.json | 15 + .../dsyr/test/fixtures/column_major_xp.json | 15 + .../row_major_complex_access_pattern.json | 14 + .../base/dsyr/test/fixtures/row_major_l.json | 15 + .../base/dsyr/test/fixtures/row_major_oa.json | 14 + .../dsyr/test/fixtures/row_major_sa1_sa2.json | 14 + .../test/fixtures/row_major_sa1_sa2n.json | 14 + .../test/fixtures/row_major_sa1n_sa2.json | 14 + .../test/fixtures/row_major_sa1n_sa2n.json | 14 + .../base/dsyr/test/fixtures/row_major_u.json | 15 + .../base/dsyr/test/fixtures/row_major_xn.json | 15 + .../base/dsyr/test/fixtures/row_major_xp.json | 15 + .../@stdlib/blas/base/dsyr/test/test.dsyr.js | 448 ++++++++++++ .../@stdlib/blas/base/dsyr/test/test.js | 82 +++ .../blas/base/dsyr/test/test.ndarray.js | 684 ++++++++++++++++++ 36 files changed, 3054 insertions(+) create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/README.md create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/examples/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/lib/main.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/package.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_l.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_l.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_u.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xn.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xp.json create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/test.js create mode 100644 lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/README.md b/lib/node_modules/@stdlib/blas/base/dsyr/README.md new file mode 100644 index 00000000000..fc2c277c032 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/README.md @@ -0,0 +1,253 @@ + + +# dsyr + +> Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. + +
+ +## Usage + +```javascript +var dsyr = require( '@stdlib/blas/base/dsyr' ); +``` + +#### dsyr( order, uplo, N, α, x, sx, A, LDA ) + +Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dsyr( 'row-major', 'upper', 3, 1.0, x, 1, A, 3 ); +// A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.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**: input [`Float64Array`][mdn-float64array]. +- **sx**: index increment for `x`. +- **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. +- **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x`, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +dsyr( 'row-major', 'upper', 3, 1.0, x, -2, A, 3 ); +// A => [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.0 ] +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +// Initial arrays... +var x0 = new Float64Array( [ 1.0, 1.0, 1.0, 1.0 ] ); +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); + +// Create offset views... +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +dsyr( 'row-major', 'upper', 3, 1.0, x1, -1, A, 3 ); +// A => [ 2.0, 3.0, 4.0, 0.0, 2.0, 3.0, 0.0, 0.0, 2.0 ] +``` + +#### dsyr.ndarray( order, uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) + +Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); + +dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, -2, 4, A, 3, 1, 0 ); +// A => [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.0 ] +``` + +The function has the following additional parameters: + +- **ox**: starting index for `x`. +- **oy**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); + +dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +// A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +``` + +
+ + + +
+ +## Notes + +- `dsyr()` corresponds to the [BLAS][blas] level 2 function [`dsyr`][dsyr]. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var dsyr = require( '@stdlib/blas/base/dsyr' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 3; + +var A = ones( N*N, opts.dtype ); +var x = discreteUniform( N, -10.0, 10.0, opts ); + +dsyr( 'row-major', 'upper', 3, 1.0, x, 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/dsyr/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.js new file mode 100644 index 00000000000..d8b526ca468 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dsyr = require( './../lib/dsyr.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = 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 = dsyr( 'row-major', 'upper', N, 1.0, x, 1, A, N ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js new file mode 100644 index 00000000000..6f1888c5f6d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ones = require( '@stdlib/array/ones' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dsyr = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of elements along each dimension +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x = 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 = dsyr( 'row-major', 'upper', N, 1.0, x, 1, 0, A, N, 1, 0 ); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( z[ i%z.length ] ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var min; + var max; + var N; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + N = floor( pow( pow( 10, i ), 1.0/2.0 ) ); + f = createBenchmark( N ); + bench( pkg+':ndarray:size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt new file mode 100644 index 00000000000..c670589c50b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt @@ -0,0 +1,115 @@ + +{{alias}}( order, uplo, N, α, x, sx, A, lda ) + Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a + scalar, `x` is an `N` element vector, 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: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + A: Float64Array + Matrix. + + lda: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float64Array + Output vector. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > {{alias}}( 'row-major', 'upper', 2, 1.0, x, 1, A, 2 ) + [ 2.0, 3.0, 0.0, 3.0 ] + + +{{alias}}.ndarray( order, uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) + Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using + alternative indexing semantics, where `α` is a scalar, `x` is an `N` + element vector, and `A` is an `N` by `N` symmetric matrix. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether to reference the upper or lower triangular part of + `A`. Must be either 'upper' or 'lower'. + + N: integer + Number of elements along each dimension of `A`. + + α: number + Scalar constant. + + x: Float64Array + Input vector. + + sx: integer + Index increment for `x`. + + ox: integer + Starting index for `x`. + + A: Float64Array + 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: Float64Array + Output array. + + Examples + -------- + > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); + > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); + > {{alias}}.ndarray( 'row-major', 'upper', 2, 1.0, x, 1, 0, A, 2, 1, 0 ) + [ 2.0, 3.0, 0.0, 3.0 ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts new file mode 100644 index 00000000000..12653d878ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts @@ -0,0 +1,117 @@ +/* +* @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 `dsyr`. +*/ +interface Routine { + /** + * Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 A - matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @returns `A` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); + * + * dsyr( 'row-major', 'upper', 3, 1.0, x, 1, A, 3 ); + * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] + */ + ( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, A: Float64Array, LDA: number ): Float64Array; + + /** + * Performs the matrix-vector operation `y = alpha*A*x + beta*y` using alternative indexing semantics and where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of the symmetric matrix `A` should be referenced + * @param N - number of elements along each dimension in the matrix `A` + * @param alpha - scalar constant + * @param x - first input array + * @param strideX - `x` stride length + * @param offsetX - starting index for `x` + * @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 Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); + * + * dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); + * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] + */ + ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, offsetX: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; +} + +/** +* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 A - matrix +* @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @returns `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr( 'column-major', 'lower', 3, 2.0, x, 1, A, 3 ); +* // y => [ 3.0, 5.0, 7.0, 0.0, 10.0, 14.0, 0.0, 0.0, 21.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ] ); +* var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr.ndarray( 'column-major', 'lower', 3, 2.0, x, 1, 0, A, 3, 1, 0 ); +* // y => [ 3.0, 5.0, 7.0, 0.0, 10.0, 14.0, 0.0, 0.0, 21.0 ] +*/ +declare var dsyr: Routine; + + +// EXPORTS // + +export = dsyr; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts new file mode 100644 index 00000000000..4d90d06270d --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts @@ -0,0 +1,358 @@ +/* +* @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 dsyr = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 10, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( true, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( false, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( null, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( undefined, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( [], 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( {}, 'upper', 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( ( x: number ): number => x, 'upper', 10, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 10, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', true, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', false, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', null, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', undefined, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', [ '1' ], 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', {}, 10, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', ( x: number ): number => x, 10, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', '10', 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', true, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', false, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', null, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', undefined, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', [], 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', {}, 1.0, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', 10, '10', x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, true, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, false, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, null, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, undefined, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, [], x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, {}, x, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', 10, 1.0, 10, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, '10', 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, true, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, false, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, null, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, undefined, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, {}, 1, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', 10, 1.0, x, '10', A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, true, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, false, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, null, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, undefined, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, [], A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, {}, A, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, A, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, 10, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, '10', 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, true, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, false, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, null, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, undefined, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, [ '1' ], 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, {}, 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, 10 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, '10' ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, true ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, false ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, null ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, undefined ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, [] ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, {} ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr(); // $ExpectError + dsyr( 'row-major' ); // $ExpectError + dsyr( 'row-major', 'upper' ); // $ExpectError + dsyr( 'row-major', 'upper', 10 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A ); // $ExpectError + dsyr( 'row-major', 'upper', 10, 1.0, x, 1, A, 10, 1 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 10, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( true, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( false, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( null, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( undefined, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( [], 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( {}, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( ( x: number ): number => x, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 10, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', true, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', false, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', null, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', undefined, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', [ '1' ], 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', {}, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', ( x: number ): number => x, 10, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', '10', 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', true, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', false, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', null, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', undefined, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', [], 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', {}, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, '10', x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, true, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, false, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, null, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, undefined, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, [], x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, {}, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... +{ + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, '10', 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, true, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, false, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, null, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, undefined, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, [], 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, {}, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, 0, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, '10', A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, true, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, false, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, null, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, undefined, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, [], A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, {}, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, A, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eighth argument which is not a Float64Array... +{ + const x = new Float64Array( 10 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an ninth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, '10', 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, true, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, false, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, null, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, undefined, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, [], 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, {}, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, '10', 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, true, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, false, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, null, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, undefined, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, [], 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, {}, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eleventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, '10' ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, true ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, false ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, null ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, undefined ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, [] ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, {} ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 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 Float64Array( 10 ); + const A = new Float64Array( 20 ); + + dsyr.ndarray(); // $ExpectError + dsyr.ndarray( 'row-major' ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper' ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1 ); // $ExpectError + dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/examples/index.js b/lib/node_modules/@stdlib/blas/base/dsyr/examples/index.js new file mode 100644 index 00000000000..198ebb4ad19 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/examples/index.js @@ -0,0 +1,35 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var ones = require( '@stdlib/array/ones' ); +var dsyr = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; + +var N = 3; + +var A = ones( N*N, opts.dtype ); +var x = discreteUniform( N, -10.0, 10.0, opts ); + +dsyr( 'row-major', 'upper', 3, 1.0, x, 1, A, 3 ); +console.log( A ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js new file mode 100644 index 00000000000..c9700143020 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js @@ -0,0 +1,114 @@ +/** +* @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'; + +// MAIN // + +/** +* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} 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 {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +*/ +function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + var isColMajor; + var isRowMajor; + var temp; + var ix0; + var ix1; + var sa0; + var sa1; + var i0; + var i1; + var oa; + var ox; + + isColMajor = ( order === 'column-major' ); + isRowMajor = ( order === 'row-major' ); + + if ( isRowMajor ) { + // 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; + if ( ( isColMajor && uplo === 'upper' ) || ( isRowMajor && uplo === 'lower' ) ) { + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( x[ ix1 ] !== 0.0 ) { + temp = alpha * x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ox; + for ( i0 = 0; i0 <= i1; i0++ ) { + A[ oa + (sa0*i0) ] += ( x[ ix0 ] * temp ); + ix0 += strideX; + } + } + ix1 += strideX; + } + return A; + } + ix1 = ox; + for ( i1 = 0; i1 < N; i1++ ) { + if ( x[ ix1 ] !== 0.0 ) { + temp = alpha * x[ ix1 ]; + oa = offsetA + (sa1*i1); + ix0 = ix1; + for ( i0 = i1; i0 < N; i0++ ) { + A[ oa + (sa0*i0) ] += ( x[ ix0 ] * temp ); + ix0 += strideX; + } + } + ix1 += strideX; + } + return A; +} + + +// EXPORTS // + +module.exports = dsyr; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js new file mode 100644 index 00000000000..d5501e2834c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js @@ -0,0 +1,97 @@ +/** +* @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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {Float64Array} 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 {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, A, 3 ); +* // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +*/ +function dsyr( order, uplo, N, alpha, x, strideX, A, LDA ) { + var sa1; + var sa2; + var ox; + + 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 ( LDA < max( 1, N ) ) { + throw new RangeError( format( 'invalid argument. Eighth 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 ); + return base( order, uplo, N, alpha, x, strideX, ox, A, sa1, sa2, 0 ); +} + + +// EXPORTS // + +module.exports = dsyr; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js new file mode 100644 index 00000000000..822bb0c345b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* +* @module @stdlib/blas/base/dsyr +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dsyr = require( '@stdlib/blas/base/dsyr' ); +* +* var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, A, 3 ); +* // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dsyr = require( '@stdlib/blas/base/dsyr' ); +* +* var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.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 dsyr; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dsyr = main; +} else { + dsyr = tmp; +} + + +// EXPORTS // + +module.exports = dsyr; + +// exports: { "ndarray": "dsyr.ndarray" } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/main.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/main.js new file mode 100644 index 00000000000..2e9caa4691c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/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 dsyr = require( './dsyr.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dsyr, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dsyr; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js new file mode 100644 index 00000000000..1746663e2de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.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 isLayout = require( '@stdlib/blas/base/assert/is-layout' ); +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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 {Float64Array} x - input vector +* @param {integer} strideX - `x` stride length +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {Float64Array} 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 {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); +* +* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +*/ +function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params + 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 ( N === 0 || alpha === 0.0 ) { + return A; + } + return base( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = dsyr; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/package.json b/lib/node_modules/@stdlib/blas/base/dsyr/package.json new file mode 100644 index 00000000000..0234ed2baea --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/blas/base/dsyr", + "version": "0.0.0", + "description": "Perform the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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", + "dsyr", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json new file mode 100644 index 00000000000..736ab1aa1bb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": -1, + "offsetX": 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, 2.0, 999.0, 4.0, 999.0, 6.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 5.0, 999.0, 8.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_l.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_l.json new file mode 100644 index 00000000000..389657f34ae --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_l.json @@ -0,0 +1,15 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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": [ 3.0, 5.0, 7.0, 0.0, 10.0, 14.0, 0.0, 0.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json new file mode 100644 index 00000000000..a4c6732c732 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 3.0, 5.0, 7.0, 999.0, 999.0, 0.0, 10.0, 14.0, 999.0, 999.0, 0.0, 0.0, 21.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json new file mode 100644 index 00000000000..a131548403f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 2.0, 999.0, 0.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 4.0, 999.0, 5.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 6.0, 999.0, 8.0, 999.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json new file mode 100644 index 00000000000..ea96abf8351 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 6.0, 999.0, 8.0, 999.0, 10.0, 999.0, 999.0, 999.0, 999.0, 999.0, 4.0, 999.0, 5.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 0.0, 999.0, 0.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json new file mode 100644 index 00000000000..5cf037d96f2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 5.0, 999.0, 4.0, 999.0, 999.0, 999.0, 999.0, 999.0, 10.0, 999.0, 8.0, 999.0, 6.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json new file mode 100644 index 00000000000..b49daa8730a --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json @@ -0,0 +1,14 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 10.0, 999.0, 8.0, 999.0, 6.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 5.0, 999.0, 4.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 0.0, 999.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_u.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_u.json new file mode 100644 index 00000000000..58f2411c7be --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_u.json @@ -0,0 +1,15 @@ +{ + "order": "column-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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": [ 2.0, 0.0, 0.0, 4.0, 5.0, 0.0, 6.0, 8.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xn.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xn.json new file mode 100644 index 00000000000..7f2bcd4c3de --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xn.json @@ -0,0 +1,15 @@ +{ + "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, + "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": [ 26.0, 0.0, 0.0, 17.0, 10.0, 0.0, 8.0, 5.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xp.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xp.json new file mode 100644 index 00000000000..92c08879256 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_xp.json @@ -0,0 +1,15 @@ +{ + "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, + "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": [ 2.0, 0.0, 0.0, 5.0, 10.0, 0.0, 8.0, 17.0, 26.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json new file mode 100644 index 00000000000..a61071b54b3 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": -1, + "offsetX": 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, 2.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, 4.0, 999.0, 5.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, 8.0, 999.0, 10.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_l.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_l.json new file mode 100644 index 00000000000..97b9c6b1226 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_l.json @@ -0,0 +1,15 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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": [ 3.0, 0.0, 0.0, 5.0, 10.0, 0.0, 7.0, 14.0, 21.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json new file mode 100644 index 00000000000..ce8fde48f7c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "lower", + "N": 3, + "alpha": 2.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 3.0, 0.0, 0.0, 5.0, 10.0, 0.0, 7.0, 14.0, 21.0, 999.0, 999.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json new file mode 100644 index 00000000000..39404d77f3b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 2.0, 999.0, 4.0, 999.0, 6.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 5.0, 999.0, 8.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, 10.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json new file mode 100644 index 00000000000..bcd67c74f7f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 6.0, 999.0, 4.0, 999.0, 2.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 8.0, 999.0, 5.0, 999.0, 0.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 10.0, 999.0, 0.0, 999.0, 0.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json new file mode 100644 index 00000000000..a91f94a03b5 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 10.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 0.0, 999.0, 5.0, 999.0, 8.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 999.0, 2.0, 999.0, 4.0, 999.0, 6.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json new file mode 100644 index 00000000000..6d420a3e03e --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json @@ -0,0 +1,14 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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, 10.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, 8.0, 999.0, 5.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, 4.0, 999.0, 2.0, 999.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_u.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_u.json new file mode 100644 index 00000000000..fd23d63a4fb --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_u.json @@ -0,0 +1,15 @@ +{ + "order": "row-major", + "uplo": "upper", + "N": 3, + "alpha": 1.0, + "x": [ 1.0, 2.0, 3.0 ], + "strideX": 1, + "offsetX": 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": [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xn.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xn.json new file mode 100644 index 00000000000..9bb9da9839b --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xn.json @@ -0,0 +1,15 @@ +{ + "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, + "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": [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xp.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xp.json new file mode 100644 index 00000000000..2967b1af66c --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_xp.json @@ -0,0 +1,15 @@ +{ + "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, + "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": [ 2.0, 5.0, 8.0, 0.0, 10.0, 17.0, 0.0, 0.0, 26.0 ] +} diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js new file mode 100644 index 00000000000..7812941fcd2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js @@ -0,0 +1,448 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dsyr = require( './../lib/dsyr.js' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.json' ); +var rxp = require( './fixtures/row_major_xp.json' ); +var rxn = require( './fixtures/row_major_xn.json' ); + +var cu = require( './fixtures/column_major_u.json' ); +var cl = require( './fixtures/column_major_l.json' ); +var cxp = require( './fixtures/column_major_xp.json' ); +var cxn = require( './fixtures/column_major_xn.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 dsyr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dsyr.length, 8, '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() { + dsyr( value, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( 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() { + dsyr( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( 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() { + dsyr( data.order, data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( 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() { + dsyr( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, new Float64Array( 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 = [ + 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() { + dsyr( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, new Float64Array( data.A ), value ); + }; + } +}); + +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = cu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A ); + + out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, 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; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A ); + + out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function supports specifying an `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, 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; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, a, data.lda ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.js new file mode 100644 index 00000000000..62f344c6d4f --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/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 dsyr = 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 dsyr, '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 dsyr.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 dsyr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dsyr, 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 dsyr; + var main; + + main = require( './../lib/dsyr.js' ); + + dsyr = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dsyr, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js new file mode 100644 index 00000000000..111e214a2c2 --- /dev/null +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js @@ -0,0 +1,684 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dsyr = require( './../lib/ndarray.js' ); + + +// FIXTURES // + +var ru = require( './fixtures/row_major_u.json' ); +var rl = require( './fixtures/row_major_l.json' ); +var rxp = require( './fixtures/row_major_xp.json' ); +var rxn = require( './fixtures/row_major_xn.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 cxp = require( './fixtures/column_major_xp.json' ); +var cxn = require( './fixtures/column_major_xn.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 dsyr, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 11', function test( t ) { + t.strictEqual( dsyr.length, 11, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var 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() { + dsyr( value, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( 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 = [ + '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() { + dsyr( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +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() { + dsyr( data.order, data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +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() { + dsyr( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + }; + } +}); + +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = cu; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = ru; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A ); + + out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, 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; + + data = cl; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A ); + + out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + t.deepEqual( a, expected, 'returns expected value' ); + + out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, 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; + + data = rsa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = csa1sa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rsa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = csa1nsa2; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rsa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = csa1sa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rsa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = csa1nsa2n; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = roa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = coa; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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 `x` stride (row-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = rxp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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 `x` stride (column-major)', function test( t ) { + var expected; + var data; + var out; + var a; + var x; + + data = cxp; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = cxn; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = rcap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, 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; + + data = ccap; + + a = new Float64Array( data.A ); + x = new Float64Array( data.x ); + + expected = new Float64Array( data.A_out ); + + out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + t.strictEqual( out, a, 'returns expected value' ); + isApprox( t, a, expected, 2.0 ); + + t.end(); +}); From 9199ba1b4ae5ccf3f1373b6d2217b7ef57ae3147 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Tue, 30 Jul 2024 10:25:30 +0530 Subject: [PATCH 2/8] refactor: update parameter for ndarray, and base implementations --- .../@stdlib/blas/base/dsyr/README.md | 10 +- .../base/dsyr/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/blas/base/dsyr/docs/repl.txt | 8 +- .../blas/base/dsyr/docs/types/index.d.ts | 6 +- .../@stdlib/blas/base/dsyr/docs/types/test.ts | 218 ++++++++---------- .../@stdlib/blas/base/dsyr/lib/base.js | 27 ++- .../@stdlib/blas/base/dsyr/lib/dsyr.js | 2 +- .../@stdlib/blas/base/dsyr/lib/index.js | 2 +- .../@stdlib/blas/base/dsyr/lib/ndarray.js | 24 +- .../column_major_complex_access_pattern.json | 1 - .../dsyr/test/fixtures/column_major_oa.json | 1 - .../test/fixtures/column_major_sa1_sa2.json | 1 - .../test/fixtures/column_major_sa1_sa2n.json | 1 - .../test/fixtures/column_major_sa1n_sa2.json | 1 - .../test/fixtures/column_major_sa1n_sa2n.json | 1 - .../row_major_complex_access_pattern.json | 1 - .../base/dsyr/test/fixtures/row_major_oa.json | 1 - .../dsyr/test/fixtures/row_major_sa1_sa2.json | 1 - .../test/fixtures/row_major_sa1_sa2n.json | 1 - .../test/fixtures/row_major_sa1n_sa2.json | 1 - .../test/fixtures/row_major_sa1n_sa2n.json | 1 - .../blas/base/dsyr/test/test.ndarray.js | 88 +++---- 22 files changed, 168 insertions(+), 231 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/README.md b/lib/node_modules/@stdlib/blas/base/dsyr/README.md index fc2c277c032..61d2a10b1b1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr/README.md @@ -85,7 +85,7 @@ dsyr( 'row-major', 'upper', 3, 1.0, x1, -1, A, 3 ); // A => [ 2.0, 3.0, 4.0, 0.0, 2.0, 3.0, 0.0, 0.0, 2.0 ] ``` -#### dsyr.ndarray( order, uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) +#### dsyr.ndarray( uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. @@ -95,14 +95,16 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, -2, 4, A, 3, 1, 0 ); +dsyr.ndarray( 'upper', 3, 1.0, x, -2, 4, A, 3, 1, 0 ); // A => [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.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, @@ -112,7 +114,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] ``` diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js index 6f1888c5f6d..7d1a7e3c9ad 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/benchmark/benchmark.ndarray.js @@ -62,7 +62,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dsyr( 'row-major', 'upper', N, 1.0, x, 1, 0, A, N, 1, 0 ); + z = dsyr( 'upper', N, 1.0, x, 1, 0, A, N, 1, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt index c670589c50b..4808b6dbdc5 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt @@ -53,7 +53,7 @@ [ 2.0, 3.0, 0.0, 3.0 ] -{{alias}}.ndarray( order, uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) +{{alias}}.ndarray( uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. @@ -64,10 +64,6 @@ 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'. @@ -108,7 +104,7 @@ -------- > var x = new {{alias:@stdlib/array/float64}}( [ 1.0, 1.0 ] ); > var A = new {{alias:@stdlib/array/float64}}( [ 1.0, 2.0, 0.0, 2.0 ] ); - > {{alias}}.ndarray( 'row-major', 'upper', 2, 1.0, x, 1, 0, A, 2, 1, 0 ) + > {{alias}}.ndarray( 'upper', 2, 1.0, x, 1, 0, A, 2, 1, 0 ) [ 2.0, 3.0, 0.0, 3.0 ] See Also diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts index 12653d878ae..1dda93237c4 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts @@ -72,10 +72,10 @@ interface Routine { * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); * - * dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); + * dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] */ - ndarray( order: Layout, uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, offsetX: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; + ndarray( uplo: MatrixTriangle, N: number, alpha: number, x: Float64Array, strideX: number, offsetX: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; } /** @@ -106,7 +106,7 @@ interface Routine { * var A = new Float64Array( [ 1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 0.0, 3.0 ] ); * var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); * -* dsyr.ndarray( 'column-major', 'lower', 3, 2.0, x, 1, 0, A, 3, 1, 0 ); +* dsyr.ndarray( 'lower', 3, 2.0, x, 1, 0, A, 3, 1, 0 ); * // y => [ 3.0, 5.0, 7.0, 0.0, 10.0, 14.0, 0.0, 0.0, 21.0 ] */ declare var dsyr: Routine; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts index 4d90d06270d..0b028410677 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/test.ts @@ -170,7 +170,7 @@ import dsyr = require( './index' ); const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectType Float64Array + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... @@ -178,29 +178,29 @@ import dsyr = require( './index' ); const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 10, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( true, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( false, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( null, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( undefined, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( [], 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( {}, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( ( x: number ): number => x, 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 10, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( true, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( false, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( null, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( undefined, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( [ '1' ], 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( {}, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( ( x: number ): number => x, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a second argument which is not a string... +// The compiler throws an error if the function is provided a second argument which is not a number... { const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 10, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', true, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', false, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', null, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', undefined, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', [ '1' ], 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', {}, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', ( x: number ): number => x, 10, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', '10', 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', true, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', false, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', null, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', undefined, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', [], 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', {}, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', ( x: number ): number => x, 1.0, x, 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... @@ -208,134 +208,119 @@ import dsyr = require( './index' ); const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', '10', 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', true, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', false, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', null, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', undefined, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', [], 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', {}, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', ( x: number ): number => x, 1.0, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, '10', x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, true, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, false, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, null, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, undefined, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, [], x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, {}, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, ( x: number ): number => x, x, 1, 0, A, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fourth argument which is not a number... +// The compiler throws an error if the function is provided a fourth argument which is not a Float64Array... { - const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, '10', x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, true, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, false, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, null, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, undefined, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, [], x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, {}, x, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, ( x: number ): number => x, x, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, ( x: number ): number => x, 1, 0, A, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a fifth argument which is not a Float64Array... -{ - const A = new Float64Array( 20 ); - - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, 10, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, '10', 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, true, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, false, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, null, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, undefined, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, [ '1' ], 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, {}, 1, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, ( x: number ): number => x, 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... +// The compiler throws an error if the function is provided a fifth argument which is not a number... { const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, '10', 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, true, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, false, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, null, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, undefined, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, [], 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, {}, 0, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, ( x: number ): number => x, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, '10', 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, true, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, false, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, null, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, undefined, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, [], 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, {}, 0, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, ( x: number ): number => x, 0, A, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a seventh argument which is not a number... +// The compiler throws an error if the function is provided a sixth argument which is not a number... { const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, '10', A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, true, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, false, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, null, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, undefined, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, [], A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, {}, A, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, ( x: number ): number => x, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, '10', A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, true, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, false, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, null, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, undefined, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, [], A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, {}, A, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, ( x: number ): number => x, A, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a eighth argument which is not a Float64Array... +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... { const x = new Float64Array( 10 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, true, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, false, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, null, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, 10, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, '10', 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, true, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, false, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, null, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, undefined, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, [ '1' ], 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, {}, 10, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, ( x: number ): number => x, 10, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided an ninth 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 Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, '10', 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, true, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, false, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, null, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, undefined, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, [], 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, {}, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, ( x: number ): number => x, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, '10', 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, true, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, false, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, null, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, undefined, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, [], 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, {}, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, ( x: number ): number => x, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a tenth argument which is not a number... +// The compiler throws an error if the function is provided a ninth argument which is not a number... { const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, '10', 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, true, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, false, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, null, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, undefined, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, [], 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, {}, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, ( x: number ): number => x, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, '10', 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, true, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, false, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, null, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, undefined, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, [], 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, {}, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, ( x: number ): number => x, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a eleventh argument which is not a number... +// The compiler throws an error if the function is provided a tenth argument which is not a number... { const x = new Float64Array( 10 ); const A = new Float64Array( 20 ); - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, '10' ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, true ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, false ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, null ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, undefined ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, [] ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, {} ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, ( x: number ): number => x ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, '10' ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, true ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, false ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, null ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, undefined ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, [] ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, {} ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 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... @@ -344,15 +329,14 @@ import dsyr = require( './index' ); const A = new Float64Array( 20 ); dsyr.ndarray(); // $ExpectError - dsyr.ndarray( 'row-major' ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper' ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1 ); // $ExpectError - dsyr.ndarray( 'row-major', 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0, 10 ); // $ExpectError + dsyr.ndarray( 'upper' ); // $ExpectError + dsyr.ndarray( 'upper', 10 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1 ); // $ExpectError + dsyr.ndarray( 'upper', 10, 1.0, x, 1, 0, A, 10, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js index c9700143020..e68314f6178 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js @@ -18,12 +18,17 @@ 'use strict'; +// MODULES // + +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); +var isColMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); + + // MAIN // /** * Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 @@ -34,10 +39,6 @@ * @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 {Float64Array} `A` * * @example @@ -46,12 +47,10 @@ * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); * -* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* dsyr( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] */ -function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params - var isColMajor; - var isRowMajor; +function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len var temp; var ix0; var ix1; @@ -62,10 +61,7 @@ function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2 var oa; var ox; - isColMajor = ( order === 'column-major' ); - isRowMajor = ( order === 'row-major' ); - - if ( isRowMajor ) { + 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 @@ -76,7 +72,10 @@ function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2 } ox = offsetX; - if ( ( isColMajor && uplo === 'upper' ) || ( isRowMajor && uplo === 'lower' ) ) { + if ( + ( isColMajor( [ strideA1, strideA2 ] ) && uplo === 'upper' ) || + ( isRowMajor( [ strideA1, strideA2 ] ) && uplo === 'lower' ) + ) { ix1 = ox; for ( i1 = 0; i1 < N; i1++ ) { if ( x[ ix1 ] !== 0.0 ) { diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js index d5501e2834c..fc694bd11a1 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js @@ -88,7 +88,7 @@ function dsyr( order, uplo, N, alpha, x, strideX, A, LDA ) { sa2 = 1; } ox = stride2offset( N, strideX ); - return base( order, uplo, N, alpha, x, strideX, ox, A, sa1, sa2, 0 ); + return base( uplo, N, alpha, x, strideX, ox, A, sa1, sa2, 0 ); } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js index 822bb0c345b..fcf4218547e 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js @@ -40,7 +40,7 @@ * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); * -* dsyr.ndarray( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] */ diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js index 1746663e2de..2bfeb5c923c 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js @@ -20,7 +20,6 @@ // MODULES // -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); var isMatrixTriangle = require( '@stdlib/blas/base/assert/is-matrix-triangle' ); var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -31,7 +30,6 @@ var base = require( './base.js' ); /** * Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, 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 @@ -42,10 +40,9 @@ 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 * @returns {Float64Array} `A` * * @example @@ -54,26 +51,23 @@ var base = require( './base.js' ); * var A = new Float64Array( [ 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 Float64Array( [ 1.0, 2.0, 3.0 ] ); * -* dsyr( 'row-major', 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +* dsyr( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] */ -function dsyr( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len, max-params - if ( !isLayout( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); - } +function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len 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. 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. Third argument must be a nonnegative integer. Value: `%d`.', N ) ); + 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. Sixth argument must be non-zero. Value: `%d`.', strideX ) ); + throw new RangeError( format( 'invalid argument. Fifth argument must be non-zero. Value: `%d`.', strideX ) ); } if ( N === 0 || alpha === 0.0 ) { return A; } - return base( order, uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len + return base( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json index 736ab1aa1bb..981b891e4c3 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_complex_access_pattern.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json index a4c6732c732..3ba11130094 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_oa.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "lower", "N": 3, "alpha": 2.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json index a131548403f..c5ab8a57e72 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json index ea96abf8351..9f5de627240 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1_sa2n.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json index 5cf037d96f2..ed222434544 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json index b49daa8730a..651cfb6ad85 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/column_major_sa1n_sa2n.json @@ -1,5 +1,4 @@ { - "order": "column-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json index a61071b54b3..68d3224c684 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_complex_access_pattern.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json index ce8fde48f7c..6f31e049fb3 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_oa.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "lower", "N": 3, "alpha": 2.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json index 39404d77f3b..02b637c5d58 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json index bcd67c74f7f..4c53cadd7f0 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1_sa2n.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json index a91f94a03b5..c942623c982 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json index 6d420a3e03e..0f0160506cf 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/fixtures/row_major_sa1n_sa2n.json @@ -1,5 +1,4 @@ { - "order": "row-major", "uplo": "upper", "N": 3, "alpha": 1.0, diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js index 111e214a2c2..018e26beab6 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js @@ -91,8 +91,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 11', function test( t ) { - t.strictEqual( dsyr.length, 11, 'returns expected value' ); +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dsyr.length, 10, 'returns expected value' ); t.end(); }); @@ -117,7 +117,7 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dsyr( value, data.uplo, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + dsyr( value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); }; } }); @@ -129,32 +129,6 @@ tape( 'the function throws an error if provided an invalid second argument', fun 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() { - dsyr( data.order, value, data.N, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); - }; - } -}); - -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, @@ -168,12 +142,12 @@ tape( 'the function throws an error if provided an invalid third argument', func function badValue( value ) { return function badValue() { - dsyr( data.order, data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + dsyr( data.uplo, value, data.alpha, new Float64Array( data.x ), data.strideX, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); }; } }); -tape( 'the function throws an error if provided an invalid sixth argument', function test( t ) { +tape( 'the function throws an error if provided an invalid fifth argument', function test( t ) { var values; var data; var i; @@ -191,7 +165,7 @@ tape( 'the function throws an error if provided an invalid sixth argument', func function badValue( value ) { return function badValue() { - dsyr( data.order, data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); + dsyr( data.uplo, data.N, data.alpha, new Float64Array( data.x ), value, data.offsetX, new Float64Array( data.A ), data.strideA1, data.strideA2, data.offsetA ); }; } }); @@ -210,7 +184,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -231,7 +205,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -252,7 +226,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -273,7 +247,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -291,7 +265,7 @@ tape( 'the function returns a reference to the input matrix `A`', function test( a = new Float64Array( data.A ); x = new Float64Array( data.x ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.end(); @@ -311,11 +285,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -336,11 +310,11 @@ tape( 'if `N` is zero or the scalar constant is zero, the function returns the i expected = new Float64Array( data.A ); - out = dsyr( data.order, data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, 0, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); - out = dsyr( data.order, data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, 0.0, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); t.deepEqual( a, expected, 'returns expected value' ); @@ -361,7 +335,7 @@ tape( 'the function supports specifying stride of the first and the second dimen expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -382,7 +356,7 @@ tape( 'the function supports specifying stride of the first and the second dimen expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -403,7 +377,7 @@ tape( 'the function supports a negative `strideA1` parameter (row-major)', funct expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -424,7 +398,7 @@ tape( 'the function supports a negative `strideA1` parameter (column-major)', fu expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -445,7 +419,7 @@ tape( 'the function supports a negative `strideA2` parameter (row-major)', funct expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -466,7 +440,7 @@ tape( 'the function supports a negative `strideA2` parameter (column-major)', fu expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -487,7 +461,7 @@ tape( 'the function supports negative strides for `A` (row-major)', function tes expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -508,7 +482,7 @@ tape( 'the function supports negative strides for `A` (column-major)', function expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -529,7 +503,7 @@ tape( 'the function supports specifying an `A` offset (row-major)', function tes expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -550,7 +524,7 @@ tape( 'the function supports specifying an `A` offset (column-major)', function expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -571,7 +545,7 @@ tape( 'the function supports specifying an `x` stride (row-major)', function tes expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -592,7 +566,7 @@ tape( 'the function supports specifying an `x` stride (column-major)', function expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -613,7 +587,7 @@ tape( 'the function supports specifying a negative `x` stride (row-major)', func expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -634,7 +608,7 @@ tape( 'the function supports specifying a negative `x` stride (column-major)', f expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -655,7 +629,7 @@ tape( 'the function supports complex access patterns (row-major)', function test expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); @@ -676,7 +650,7 @@ tape( 'the function supports complex access patterns (column-major)', function t expected = new Float64Array( data.A_out ); - out = dsyr( data.order, data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); + out = dsyr( data.uplo, data.N, data.alpha, x, data.strideX, data.offsetX, a, data.strideA1, data.strideA2, data.offsetA ); t.strictEqual( out, a, 'returns expected value' ); isApprox( t, a, expected, 2.0 ); From f3335d7de0cd0242fc72eb75a4293559d011f243 Mon Sep 17 00:00:00 2001 From: aman-095 Date: Thu, 1 Aug 2024 12:35:36 +0530 Subject: [PATCH 3/8] chore: apply review changes --- .../@stdlib/blas/base/dsyr/README.md | 12 +++++----- .../@stdlib/blas/base/dsyr/docs/repl.txt | 21 ++++++++-------- .../blas/base/dsyr/docs/types/index.d.ts | 14 +++++------ .../@stdlib/blas/base/dsyr/lib/base.js | 22 +++++++++-------- .../@stdlib/blas/base/dsyr/lib/dsyr.js | 6 ++--- .../@stdlib/blas/base/dsyr/lib/index.js | 2 +- .../@stdlib/blas/base/dsyr/lib/ndarray.js | 6 ++--- .../@stdlib/blas/base/dsyr/package.json | 2 +- .../@stdlib/blas/base/dsyr/test/test.dsyr.js | 8 +++---- .../blas/base/dsyr/test/test.ndarray.js | 24 +++++++++---------- 10 files changed, 59 insertions(+), 58 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/README.md b/lib/node_modules/@stdlib/blas/base/dsyr/README.md index 61d2a10b1b1..99e9a994ec8 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr/README.md @@ -20,7 +20,7 @@ limitations under the License. # dsyr -> Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +> Perform the symmetric rank 1 operation `A = α*x*x^T + A`.
@@ -32,7 +32,7 @@ var dsyr = require( '@stdlib/blas/base/dsyr' ); #### dsyr( order, uplo, N, α, x, sx, A, LDA ) -Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -55,7 +55,7 @@ The function has the following parameters: - **A**: input matrix stored in linear memory as a [`Float64Array`][mdn-float64array]. - **lda**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). -The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over the elements of `x`, +The stride parameters determine how elements in the input arrays are accessed at runtime. For example, to iterate over every other element of `x` in reverse order, ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -87,7 +87,7 @@ dsyr( 'row-major', 'upper', 3, 1.0, x1, -1, A, 3 ); #### dsyr.ndarray( uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) -Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using alternative indexing semantics, where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative indexing semantics and where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. ```javascript var Float64Array = require( '@stdlib/array/float64' ); @@ -126,7 +126,7 @@ dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); ## Notes -- `dsyr()` corresponds to the [BLAS][blas] level 2 function [`dsyr`][dsyr]. +- `dsyr()` corresponds to the [BLAS][blas] level 2 function [`dsyr`][blas-dsyr].
@@ -244,7 +244,7 @@ TODO [blas]: http://www.netlib.org/blas -[dsyr]: https://www.netlib.org/lapack/explore-html/dc/d82/group__her_ga07f0e3f8592107877f12a554a41c7413.html#ga07f0e3f8592107877f12a554a41c7413 +[blas-dsyr]: https://www.netlib.org/lapack/explore-html/dc/d82/group__her_ga07f0e3f8592107877f12a554a41c7413.html#ga07f0e3f8592107877f12a554a41c7413 [mdn-float64array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt index 4808b6dbdc5..b417cd9e60c 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/repl.txt @@ -1,15 +1,14 @@ {{alias}}( order, uplo, N, α, x, sx, A, lda ) - Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a + Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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 ---------- @@ -34,7 +33,7 @@ Index increment for `x`. A: Float64Array - Matrix. + Input matrix. lda: integer Stride of the first dimension of `A` (a.k.a., leading dimension of the @@ -43,7 +42,7 @@ Returns ------- A: Float64Array - Output vector. + Input matrix. Examples -------- @@ -54,9 +53,9 @@ {{alias}}.ndarray( uplo, N, α, x, sx, ox, A, sa1, sa2, oa ) - Performs the symmetric rank 1 operation `A = α*x*x**T + A`, using - alternative indexing semantics, where `α` is a scalar, `x` is an `N` - element vector, and `A` is an `N` by `N` symmetric matrix. + Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative + indexing semantics and where `α` is a scalar, `x` is an `N` element vector, + 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 @@ -84,7 +83,7 @@ Starting index for `x`. A: Float64Array - Matrix. + Input matrix. sa1: integer Stride of the first dimension of `A`. @@ -98,7 +97,7 @@ Returns ------- A: Float64Array - Output array. + Input matrix. Examples -------- diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts index 1dda93237c4..66d7e1cd0ea 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/base/dsyr/docs/types/index.d.ts @@ -27,13 +27,13 @@ import { Layout, MatrixTriangle } from '@stdlib/types/blas'; */ interface Routine { /** - * Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. + * Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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 + * @param x - input vector * @param strideX - `x` stride length * @param A - matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) @@ -57,7 +57,7 @@ interface Routine { * @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 x - input vector * @param strideX - `x` stride length * @param offsetX - starting index for `x` * @param A - matrix @@ -79,13 +79,13 @@ interface Routine { } /** -* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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 +* @param x - input vector * @param strideX - `x` stride length * @param A - matrix * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js index e68314f6178..051d85c7bf9 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js @@ -21,14 +21,14 @@ // MODULES // var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); -var isColMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); // MAIN // /** -* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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 @@ -51,7 +51,8 @@ var isColMajor = require( '@stdlib/ndarray/base/assert/is-column-major' ); * // A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] */ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len - var temp; + var isrm; + var tmp; var ix0; var ix1; var sa0; @@ -61,7 +62,8 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse var oa; var ox; - if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + isrm = isRowMajor( [ strideA1, strideA2 ] ); + if ( isrm ) { // For row-major matrices, the last dimension has the fastest changing index... sa0 = strideA2; // stride for innermost loop sa1 = strideA1; // stride for outermost loop @@ -73,17 +75,17 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse ox = offsetX; if ( - ( isColMajor( [ strideA1, strideA2 ] ) && uplo === 'upper' ) || - ( isRowMajor( [ strideA1, strideA2 ] ) && uplo === 'lower' ) + ( !isrm && uplo === 'upper' ) || + ( isrm && uplo === 'lower' ) ) { ix1 = ox; for ( i1 = 0; i1 < N; i1++ ) { if ( x[ ix1 ] !== 0.0 ) { - temp = alpha * x[ ix1 ]; + tmp = alpha * x[ ix1 ]; oa = offsetA + (sa1*i1); ix0 = ox; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa + (sa0*i0) ] += ( x[ ix0 ] * temp ); + A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp ); ix0 += strideX; } } @@ -94,11 +96,11 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse ix1 = ox; for ( i1 = 0; i1 < N; i1++ ) { if ( x[ ix1 ] !== 0.0 ) { - temp = alpha * x[ ix1 ]; + tmp = alpha * x[ ix1 ]; oa = offsetA + (sa1*i1); ix0 = ix1; for ( i0 = i1; i0 < N; i0++ ) { - A[ oa + (sa0*i0) ] += ( x[ ix0 ] * temp ); + A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp ); ix0 += strideX; } } diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js index fc694bd11a1..c409241187a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js @@ -31,7 +31,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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 @@ -42,7 +42,7 @@ var base = require( './base.js' ); * @param {Float64Array} 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) @@ -66,7 +66,7 @@ function dsyr( order, uplo, N, alpha, x, strideX, 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 ) ); diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js index fcf4218547e..3275f78309c 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* BLAS level 2 routine to perform the matrix-vector operation `y = alpha*A*x + beta*y` where `alpha` and `beta` are scalars, `x` and `y` are `N` element vectors, and `A` is an `N` by `N` symmetric matrix. +* BLAS level 2 routine to perform the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. * * @module @stdlib/blas/base/dsyr * diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js index 2bfeb5c923c..490056e2b0e 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/ndarray.js @@ -28,7 +28,7 @@ var base = require( './base.js' ); // MAIN // /** -* Performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. +* Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, 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` @@ -40,7 +40,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 * @returns {Float64Array} `A` @@ -56,7 +56,7 @@ var base = require( './base.js' ); */ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len 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 to 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/dsyr/package.json b/lib/node_modules/@stdlib/blas/base/dsyr/package.json index 0234ed2baea..9c3c693ea93 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/package.json +++ b/lib/node_modules/@stdlib/blas/base/dsyr/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/blas/base/dsyr", "version": "0.0.0", - "description": "Perform the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix.", + "description": "Perform the symmetric rank 1 operation `A = α*x*x^T + A`.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js index 7812941fcd2..4affab6c33f 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.dsyr.js @@ -212,7 +212,7 @@ tape( 'the function throws an error if provided an invalid eighth argument', fun } }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (row-major, upper)', function test( t ) { var expected; var data; var out; @@ -233,7 +233,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (column-major, upper)', function test( t ) { var expected; var data; var out; @@ -254,7 +254,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (row-major, lower)', function test( t ) { var expected; var data; var out; @@ -275,7 +275,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (column-major, lower)', function test( t ) { var expected; var data; var out; diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js index 018e26beab6..6af401f4716 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js @@ -170,7 +170,7 @@ tape( 'the function throws an error if provided an invalid fifth argument', func } }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (row-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (row-major, upper)', function test( t ) { var expected; var data; var out; @@ -191,7 +191,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (column-major, upper)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (column-major, upper)', function test( t ) { var expected; var data; var out; @@ -212,7 +212,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (row-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (row-major, lower)', function test( t ) { var expected; var data; var out; @@ -233,7 +233,7 @@ tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` t.end(); }); -tape( 'the function performs the symmetric rank 1 operation `A = α*x*x**T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix (column-major, lower)', function test( t ) { +tape( 'the function performs the symmetric rank 1 operation `A = α*x*x^T + A` (column-major, lower)', function test( t ) { var expected; var data; var out; @@ -321,7 +321,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 stride of the first and second dimensions of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -342,7 +342,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 stride of the first and second dimensions of `A` (column-major)', function test( t ) { var expected; var data; var out; @@ -363,7 +363,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; @@ -384,7 +384,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; @@ -405,7 +405,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; @@ -426,7 +426,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; @@ -447,7 +447,7 @@ tape( 'the function supports a negative `strideA2` parameter (column-major)', fu t.end(); }); -tape( 'the function supports negative strides for `A` (row-major)', function test( t ) { +tape( 'the function supports negative strides for both dimensions of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -468,7 +468,7 @@ tape( 'the function supports negative strides for `A` (row-major)', function tes t.end(); }); -tape( 'the function supports negative strides for `A` (column-major)', function test( t ) { +tape( 'the function supports negative strides for both dimensions of `A` (column-major)', function test( t ) { var expected; var data; var out; From 332ac6aa488ccc93aa2ab14dcc3314036ca6c569 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 1 Aug 2024 13:32:55 -0700 Subject: [PATCH 4/8] refactor: use "fast" `max` utility and fix missing private annotation --- lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js index c409241187a..f79003591f9 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.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' ); @@ -33,6 +33,7 @@ var base = require( './base.js' ); /** * Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. * +* @private * @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` From c3d4ce17198bbe3bf65219936a84e0ca6e85d203 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 1 Aug 2024 13:33:34 -0700 Subject: [PATCH 5/8] fix: remove private annotation --- lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js index f79003591f9..2f6f395661a 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/dsyr.js @@ -33,7 +33,6 @@ var base = require( './base.js' ); /** * Performs the symmetric rank 1 operation `A = α*x*x^T + A` where `α` is a scalar, `x` is an `N` element vector, and `A` is an `N` by `N` symmetric matrix. * -* @private * @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` From 61822017a979f9ba9e12c4d945b529d05426370f Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 1 Aug 2024 13:35:25 -0700 Subject: [PATCH 6/8] style: remove extra parentheses --- lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js index 051d85c7bf9..bdc56a39a98 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/lib/base.js @@ -72,7 +72,6 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse sa0 = strideA1; // stride for innermost loop sa1 = strideA2; // stride for outermost loop } - ox = offsetX; if ( ( !isrm && uplo === 'upper' ) || @@ -85,7 +84,7 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse oa = offsetA + (sa1*i1); ix0 = ox; for ( i0 = 0; i0 <= i1; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp ); + A[ oa+(sa0*i0) ] += x[ ix0 ] * tmp; ix0 += strideX; } } @@ -93,6 +92,7 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse } return A; } + // ( isrm && uplo === 'upper' ) || ( !isrm && uplo === 'lower' ) ix1 = ox; for ( i1 = 0; i1 < N; i1++ ) { if ( x[ ix1 ] !== 0.0 ) { @@ -100,7 +100,7 @@ function dsyr( uplo, N, alpha, x, strideX, offsetX, A, strideA1, strideA2, offse oa = offsetA + (sa1*i1); ix0 = ix1; for ( i0 = i1; i0 < N; i0++ ) { - A[ oa+(sa0*i0) ] += ( x[ ix0 ] * tmp ); + A[ oa+(sa0*i0) ] += x[ ix0 ] * tmp; ix0 += strideX; } } From 5d650d9a044e87018d46a3804d4292bd31ad7fd6 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 1 Aug 2024 13:41:34 -0700 Subject: [PATCH 7/8] test: fix grammar --- lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js index 6af401f4716..b63cc69100f 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/blas/base/dsyr/test/test.ndarray.js @@ -321,7 +321,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 second dimensions of `A` (row-major)', function test( t ) { +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (row-major)', function test( t ) { var expected; var data; var out; @@ -342,7 +342,7 @@ tape( 'the function supports specifying stride of the first and second dimension t.end(); }); -tape( 'the function supports specifying stride of the first and second dimensions of `A` (column-major)', function test( t ) { +tape( 'the function supports specifying the strides of the first and second dimensions of `A` (column-major)', function test( t ) { var expected; var data; var out; From 95e45f3aa9c02171c008e561df77b84bb4f307d4 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 1 Aug 2024 13:44:24 -0700 Subject: [PATCH 8/8] docs: fix example order --- lib/node_modules/@stdlib/blas/base/dsyr/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/blas/base/dsyr/README.md b/lib/node_modules/@stdlib/blas/base/dsyr/README.md index 99e9a994ec8..988613098c3 100644 --- a/lib/node_modules/@stdlib/blas/base/dsyr/README.md +++ b/lib/node_modules/@stdlib/blas/base/dsyr/README.md @@ -93,10 +93,10 @@ Performs the symmetric rank 1 operation `A = α*x*x^T + A`, using alternative in var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); -var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); -dsyr.ndarray( 'upper', 3, 1.0, x, -2, 4, A, 3, 1, 0 ); -// A => [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.0 ] +dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); +// A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] ``` The function has the following additional parameters: @@ -112,10 +112,10 @@ While [`typed array`][mdn-typed-array] views mandate a view offset based on the var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 0.0, 0.0, 1.0 ] ); -var x = new Float64Array( [ 1.0, 2.0, 3.0 ] ); +var x = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] ); -dsyr.ndarray( 'upper', 3, 1.0, x, 1, 0, A, 3, 1, 0 ); -// A => [ 2.0, 4.0, 6.0, 0.0, 5.0, 8.0, 0.0, 0.0, 10.0 ] +dsyr.ndarray( 'upper', 3, 1.0, x, -2, 4, A, 3, 1, 0 ); +// A => [ 26.0, 17.0, 8.0, 0.0, 10.0, 5.0, 0.0, 0.0, 2.0 ] ```