From 86eb823fd866ed4d5be8bfce11e2d4a95ad0a494 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:04:23 +0530 Subject: [PATCH 01/19] feat: init lapack/base/dlaset --- .../@stdlib/lapack/base/dlaset/README.md | 230 ++++++++++++++++++ .../lapack/base/dlaset/examples/index.js | 28 +++ .../@stdlib/lapack/base/dlaset/lib/base.js | 114 +++++++++ .../@stdlib/lapack/base/dlaset/lib/dlaset.js | 62 +++++ .../@stdlib/lapack/base/dlaset/lib/index.js | 68 ++++++ .../@stdlib/lapack/base/dlaset/lib/main.js | 35 +++ .../@stdlib/lapack/base/dlaset/lib/ndarray.js | 63 +++++ .../@stdlib/lapack/base/dlaset/package.json | 67 +++++ 8 files changed, 667 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/README.md create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/examples/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/lib/main.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/package.json diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md new file mode 100644 index 000000000000..c1a2ea59ff7a --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md @@ -0,0 +1,230 @@ + + +# dlaset + +> Initialize an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. + +
+ +## Usage + +```javascript +var dlaset = require( '@stdlib/lapack/base/dlaset' ); +``` + +#### dlaset( order, uplo, M, N, alpha, beta, A, LDA ) + +Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); +// A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +``` + +The function has the following parameters: + +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of matrix `A` is supplied. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **alpha**: scalar constant to which off-diagonal elements are set. +- **beta**: scalar constant to which diagonal elements are set. +- **A**: input [`Float64Array`][mdn-float64array] matrix `A`. +- **LDA**: stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`). + +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 A0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +// Create offset views... +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 1st element + +dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A1, 3 ); +// A0 => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +``` + +#### dlaset.ndarray( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) + +Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); +// A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +``` + +The function has the following additional parameters: + +- **offsetA**: starting index for `A`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); + +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +// A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +``` + +
+ + + +
+ +## Notes + +- `dlaset()` corresponds to the [LAPACK][lapack] routine [`dlaset`][dlaset]. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Array = require( '@stdlib/array/float64' ); +var dlaset = require( '@stdlib/lapack/base/dlaset' ); + +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, 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/lapack/base/dlaset/examples/index.js b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/index.js new file mode 100644 index 000000000000..af56e99fbba6 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var dlaset = require( './../lib' ); + +var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + +dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); +console.log( A ); +// A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js new file mode 100644 index 000000000000..5ed58e5ccc72 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/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'; + +// MODULES // + +var min = require( '@stdlib/math/base/special/min' ); + + +// MAIN // + +/** +* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @private +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ +function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { + var i; + var j; + + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } + + if ( uplo === 'upper' ) { + if ( order === 'column-major' ) { + for ( j = 1; j < N; j++ ) { + for ( i = 0; i < min( j - 1, M ); i++ ) { + A[ offsetA + ( j * LDA ) + i ] = alpha; + } + } + return A; + } + // order === 'row-major' + for ( j = 1; j < N; j++ ) { + for ( i = 0; i < min( j - 1, M ); i++ ) { + A[ offsetA + ( i * LDA ) + j ] = alpha; + } + } + return A; + } + if ( uplo === 'lower' ) { + if ( order === 'column-major' ) { + for ( j = 0; j < min( M, N ); j++ ) { + for ( i = j + 1; i < M; i++ ) { + A[ offsetA + ( j * LDA ) + i ] = alpha; + } + } + return A; + } + // order === 'row-major' + for ( j = 0; j < min( M, N ); j++ ) { + for ( i = j + 1; i < M; i++ ) { + A[ offsetA + ( i * LDA ) + j ] = alpha; + } + } + return A; + } + // All of the matrix `A` + if ( order === 'column-major' ) { + for ( j = 0; j < N; j++ ) { + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( j * LDA ) + i ] = alpha; + } + } + return A; + } + // order === 'row-major' + for ( j = 0; j < N; j++ ) { + for ( i = 0; i < M; i++ ) { + A[ offsetA + ( i * LDA ) + j ] = alpha; + } + } + return A; +} + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js new file mode 100644 index 000000000000..bfed810a2674 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js @@ -0,0 +1,62 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} 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 +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ +function dlaset( order, uplo, M, N, alpha, beta, A, LDA ) { + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + return base( order, uplo, M, N, alpha, beta, A, LDA, 0 ); +} + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js new file mode 100644 index 000000000000..29086addc41e --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js @@ -0,0 +1,68 @@ +/** +* @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'; + +/** +* LAPACK routine to initialize an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @module @stdlib/lapack/base/dlaset +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaset = require( '@stdlib/lapack/base/dlaset' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* var dlaset = require( '@stdlib/lapack/base/dlaset' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ + +// 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 dlaset; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + dlaset = main; +} else { + dlaset = tmp; +} + + +// EXPORTS // + +module.exports = dlaset; + +// exports: { "ndarray": "dlaset.ndarray" } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/main.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/main.js new file mode 100644 index 000000000000..77b02a3774fc --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/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 dlaset = require( './dlaset.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( dlaset, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js new file mode 100644 index 000000000000..0341deec6b80 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js @@ -0,0 +1,63 @@ +/** +* @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 format = require( '@stdlib/string/format' ); +var base = require( './base.js' ); + + +// MAIN // + +/** +* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. +* +* @param {string} order - storage layout +* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @param {Float64Array} A - input matrix +* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @param {NonNegativeInteger} offsetA - starting index for `A` +* @throws {TypeError} first argument must be a valid order +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ +function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { + if ( !isLayout( order ) ) { + throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); + } + return base( order, uplo, M, N, alpha, beta, A, LDA, offsetA ); +} + + +// EXPORTS // + +module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/package.json b/lib/node_modules/@stdlib/lapack/base/dlaset/package.json new file mode 100644 index 000000000000..8919c234f5e0 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/package.json @@ -0,0 +1,67 @@ +{ + "name": "@stdlib/lapack/base/dlacpy", + "version": "0.0.0", + "description": "Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals.", + "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", + "lapack", + "dlaset", + "linear", + "algebra", + "subroutines", + "array", + "ndarray", + "float64", + "double", + "float64array" + ] +} From a9ff05d576993578d357ec95826bc5542957a4d4 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:13:42 +0530 Subject: [PATCH 02/19] docs: add docs/types --- .../lapack/base/dlaset/docs/types/index.d.ts | 110 +++++++ .../lapack/base/dlaset/docs/types/test.ts | 304 ++++++++++++++++++ 2 files changed, 414 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts new file mode 100644 index 000000000000..423d7591a5ba --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts @@ -0,0 +1,110 @@ +/* @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 } from '@stdlib/types/blas'; + +/** +* Interface describing `dlaset`. +*/ +interface Routine { + /** + * Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param alpha - scalar constant to which off-diagonal elements are set + * @param beta - scalar constant to which diagonal elements are set + * @param A - input 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( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); + * // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] + */ + ( order: Layout, uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, LDA: number ): Float64Array; + + /** + * Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. + * + * @param order - storage layout + * @param uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied + * @param M - number of rows in matrix `A` + * @param N - number of columns in matrix `A` + * @param alpha - scalar constant to which off-diagonal elements are set + * @param beta - scalar constant to which diagonal elements are set + * @param A - input matrix + * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @param offsetA - starting index for `A` + * @returns `A` + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + * + * dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); + * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] + */ + ndarray( order: Layout, uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, LDA: number, offsetA: number ): Float64Array; +} + +/** +* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @param order - storage layout +* @param uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param M - number of rows in matrix `A` +* @param N - number of columns in matrix `A` +* @param alpha - scalar constant to which off-diagonal elements are set +* @param beta - scalar constant to which diagonal elements are set +* @param A - input 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( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ +declare var dlaset: Routine; + + +// EXPORTS // + +export = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts new file mode 100644 index 000000000000..1012fdc5dc7d --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts @@ -0,0 +1,304 @@ +/* +* @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 dlaset = require( './index' ); + + +// TESTS // + +// The function returns a Float64Array... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 5, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( true, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( false, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( null, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( void 0, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( [], 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( {}, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( ( x: number ): number => x, 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 5, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', true, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', false, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', null, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', void 0, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', [], 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', {}, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', '5', 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', true, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', false, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', null, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', void 0, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', [], 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', {}, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', 3, '5', 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, true, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, false, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, null, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, void 0, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, [], 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, {}, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', 3, 3, '5', 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, true, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, false, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, null, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, void 0, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, [], 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, {}, 3.7, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', 3, 3, 3.1, '5', A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, true, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, false, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, null, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, void 0, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, [], A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, {}, A, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, false, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, null, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, void 0, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, [], 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, {}, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, '5' ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, true ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, false ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, null ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, void 0 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, [] ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, {} ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset(); // $ExpectError + dlaset( 'row-major' ); // $ExpectError + dlaset( 'row-major', 'lower' ); // $ExpectError + dlaset( 'row-major', 'lower', 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7 ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A ); // $ExpectError + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 10 ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a Float64Array... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectType Float64Array +} + +// The compiler throws an error if the function is provided a first argument which is not a string... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 5, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( true, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( false, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( null, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( void 0, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( [], 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( {}, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( ( x: number ): number => x, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a string... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 5, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', true, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', false, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', null, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', void 0, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', [], 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', {}, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', '5', 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', true, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', false, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', null, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', void 0, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', [], 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', {}, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, '5', 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, true, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, false, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, null, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, void 0, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, [], 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, {}, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, '5', 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, true, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, false, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, null, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, void 0, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, [], 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, {}, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, '5', A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, true, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, false, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, null, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, void 0, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, [], A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, {}, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +{ + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, false, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, null, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, void 0, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, [], 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, {}, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eighth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, '5', 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, true, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, false, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, null, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, void 0, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, [], 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, {}, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, '5' ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, true ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, false ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, null ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, void 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, [] ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, {} ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray(); // $ExpectError + dlaset.ndarray( 'row-major' ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower' ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0, 10 ); // $ExpectError +} From eef7158f0ff2097b83bbcbd7474c3f44af17e25b Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:19:00 +0530 Subject: [PATCH 03/19] docs: add repl.txt --- .../@stdlib/lapack/base/dlaset/docs/repl.txt | 117 ++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt new file mode 100644 index 000000000000..5cbba33fa236 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt @@ -0,0 +1,117 @@ + +{{alias}}( order, uplo, M, N, alpha, beta, A, LDA ) + Initializes an `M` by `N` matrix `A` to `beta` on the diagonal + and `alpha` on the off-diagonals. + + Indexing is relative to the first index. To introduce an offset, use typed + array views. + + 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 the upper or lower triangular matrix of `A` is + supplied. + + M: integer + Number of row in `A`. + + N: integer + Number of columns in `A`. + + alpha: number + Scalar constant to which off-diagonal elements are set. + + beta: number + Scalar constant to which diagonal elements are set. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + Returns + ------- + A: Float64Array + Output matrix. + + Examples + -------- + // Standard usage: + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2 ) + [ 3.7, 0.0, 3.1, 3.7 ] + + // Using typed array views: + > var A0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > var A1 = new {{alias:@stdlib/array/float64}}( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); + > {{alias}}( 'row-major', 'lower', 2, 2, 3.1, 3.7, A1, 2 ); + > A0 + [ 0.0, 3.7, 0.0, 3.1, 3.7 ] + + +{{alias}}.ndarray( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) + Initializes an `M` by `N` matrix `A` to `beta` on the diagonal + and `alpha` on the off-diagonals using alternative indexing semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameters support indexing semantics based on starting + indices. + + Parameters + ---------- + order: string + Row-major (C-style) or column-major (Fortran-style) order. Must be + either 'row-major' or 'column-major'. + + uplo: string + Specifies whether the upper or lower triangular matrix of `A` is + supplied. + + M: integer + Number of row in `A`. + + N: integer + Number of columns in `A`. + + alpha: number + Scalar constant to which off-diagonal elements are set. + + beta: number + Scalar constant to which diagonal elements are set. + + A: Float64Array + Input matrix `A`. + + LDA: integer + Stride of the first dimension of `A` (a.k.a., leading dimension of the + matrix `A`). + + offsetA: integer + Starting index for `A`. + + Returns + ------- + A: Float64Array + Output matrix. + + Examples + -------- + // Standard usage: + // Standard usage: + > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 0 ) + [ 3.7, 0.0, 3.1, 3.7 ] + + // Advanced indexing: + > A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1 ) + [ 0.0, 3.7, 0.0, 3.1, 3.7 ] + + See Also + -------- From e63682d041651d31525e11671df9a8a12b30a73a Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:22:47 +0530 Subject: [PATCH 04/19] chore: add benchmark --- .../lapack/base/dlaset/benchmark/benchmark.js | 105 ++++++++++++++++++ .../dlaset/benchmark/benchmark.ndarray.js | 105 ++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.js b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.js new file mode 100644 index 000000000000..8f5bab269bca --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaset = require( './../lib/dlaset.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 A; + + A = uniform( N*N, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlaset( 'column-major', 'lower', N, N, 3.1, 3.7, 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+':order=column-major,size='+(N*N), f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..b328c83bad71 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js @@ -0,0 +1,105 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var pkg = require( './../package.json' ).name; +var dlaset = 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 A; + + A = uniform( N*N, -10.0, 10.0, options ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = dlaset( 'column-major', 'lower', N, N, 3.1, 3.7, A, N, 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:order=column-major,size='+(N*N), f ); + } +} + +main(); From e163ab058b5127a0cc858163131777c6b54eb9eb Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:40:41 +0530 Subject: [PATCH 05/19] fix: incorrect base implementation --- .../@stdlib/lapack/base/dlaset/lib/base.js | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index 5ed58e5ccc72..7e5208b0fe66 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -52,10 +52,6 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { var i; var j; - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; - } - if ( uplo === 'upper' ) { if ( order === 'column-major' ) { for ( j = 1; j < N; j++ ) { @@ -63,6 +59,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( j * LDA ) + i ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } // order === 'row-major' @@ -71,6 +70,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( i * LDA ) + j ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } if ( uplo === 'lower' ) { @@ -80,6 +82,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( j * LDA ) + i ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } // order === 'row-major' @@ -88,6 +93,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( i * LDA ) + j ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } // All of the matrix `A` @@ -97,6 +105,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( j * LDA ) + i ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } // order === 'row-major' @@ -105,6 +116,9 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { A[ offsetA + ( i * LDA ) + j ] = alpha; } } + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * LDA ) + i ] = beta; + } return A; } From bdbe835cd1951905572b58010b4253b34d73fda1 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Thu, 11 Jul 2024 12:41:34 +0530 Subject: [PATCH 06/19] test: add ndarray and dlaset --- .../lapack/base/dlaset/test/test.dlaset.js | 216 ++++++++++++++++++ .../@stdlib/lapack/base/dlaset/test/test.js | 82 +++++++ .../lapack/base/dlaset/test/test.ndarray.js | 216 ++++++++++++++++++ 3 files changed, 514 insertions(+) create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js create mode 100644 lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js new file mode 100644 index 000000000000..ce5f85136464 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js @@ -0,0 +1,216 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlaset = require( './../lib/dlaset.js' ); + + +// 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 dlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 8', function test( t ) { + t.strictEqual( dlaset.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 A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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() { + dlaset( value, 'lower', 2, 2, 3.1, 3.7, A, 2 ); + }; + } +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, lower)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ]); + + out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, lower)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 3.1, 0.0, 3.7, 0.0, 0.0 ]); + + out = dlaset( 'column-major', 'lower', M, N, 3.1, 3.7, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, upper)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); + + out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, upper)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 0.0, 0.0, 3.7, 3.1, 0.0 ]); + + out = dlaset( 'column-major', 'upper', M, N, 3.1, 3.7, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, all)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ]); + + out = dlaset( 'row-major', 'all', M, N, 3.1, 3.7, A, N ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, all)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 3.1, 3.1, 3.7, 3.1, 3.1 ]); + + out = dlaset( 'column-major', 'all', M, N, 3.1, 3.7, A, M ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js new file mode 100644 index 000000000000..b1b9bf5ac416 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/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 dlaset = 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 dlaset, '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 dlaset.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 dlaset = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaset, 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 dlaset; + var main; + + main = require( './../lib/dlaset.js' ); + + dlaset = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire + }); + + t.strictEqual( dlaset, main, 'returns expected value' ); + t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js new file mode 100644 index 000000000000..06beae6c4cb3 --- /dev/null +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js @@ -0,0 +1,216 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var dlaset = require( './../lib/ndarray.js' ); + + +// 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 dlaset, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dlaset.length, 9, 'returns expected value' ); + t.end(); +}); + +tape( 'the function throws an error if provided an invalid first argument', function test( t ) { + var values; + var A; + var i; + + values = [ + 'foo', + 'bar', + 'beep', + 'boop' + ]; + + A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + + 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() { + dlaset( value, 'lower', 2, 2, 3.1, 3.7, A, 2, 0 ); + }; + } +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, lower, offsetA = 5)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ]); + + out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N, 5 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, lower, offsetA = 3)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 0.0, 3.7, 0.0, 0.0 ]); + + out = dlaset( 'column-major', 'lower', M, N, 3.1, 3.7, A, M, 3 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, upper, offsetA = 3)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); + + out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N, 3 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, upper, offsetA = 3)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.7, 3.1, 0.0 ]); + + out = dlaset( 'column-major', 'upper', M, N, 3.1, 3.7, A, M, 3); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, all, offsetA = 3)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ]); + + out = dlaset( 'row-major', 'all', M, N, 3.1, 3.7, A, N, 3 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); + +tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, all, offsetA = 3)', function test( t ) { + var expected; + var out; + var A; + var M; + var N; + + M = 2; + N = 3; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.7, 3.1, 3.1 ]); + + out = dlaset( 'column-major', 'all', M, N, 3.1, 3.7, A, M, 3 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + t.end(); +}); From b055506bcecf99c46db813b4d50a89ec7729d5ca Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 16:59:43 +0530 Subject: [PATCH 07/19] refactor: lapack/base/dlaset --- .../@stdlib/lapack/base/dlaset/lib/base.js | 43 ++++++++++++------- .../@stdlib/lapack/base/dlaset/lib/dlaset.js | 11 ++++- .../@stdlib/lapack/base/dlaset/lib/index.js | 2 +- .../@stdlib/lapack/base/dlaset/lib/ndarray.js | 9 ++-- 4 files changed, 44 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index 7e5208b0fe66..4dab91e4c078 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -36,7 +36,8 @@ var min = require( '@stdlib/math/base/special/min' ); * @param {number} alpha - scalar constant to which off-diagonal elements are set * @param {number} beta - scalar constant to which diagonal elements are set * @param {Float64Array} A - input matrix -* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @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` * @returns {Float64Array} `A` * @@ -45,33 +46,45 @@ var min = require( '@stdlib/math/base/special/min' ); * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); * // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ -function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { +function dlaset( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len + var sa0; + var sa1; var i; var j; + if ( order === 'row-major' ) { + // For row-major matrices, the last dimension has the fastest changing index... + sa0 = strideA2; // stride for innermost loop + sa1 = strideA1; // stride for outermost loop + } else { // order == 'column-major' + // For column-major matrices, the first dimension has the fastest changing index... + sa0 = strideA1; // stride for innermost loop + sa1 = strideA2; // stride for outermost loop + } + if ( uplo === 'upper' ) { if ( order === 'column-major' ) { for ( j = 1; j < N; j++ ) { for ( i = 0; i < min( j - 1, M ); i++ ) { - A[ offsetA + ( j * LDA ) + i ] = alpha; + A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; } return A; } // order === 'row-major' for ( j = 1; j < N; j++ ) { for ( i = 0; i < min( j - 1, M ); i++ ) { - A[ offsetA + ( i * LDA ) + j ] = alpha; + A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; } return A; } @@ -79,22 +92,22 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { if ( order === 'column-major' ) { for ( j = 0; j < min( M, N ); j++ ) { for ( i = j + 1; i < M; i++ ) { - A[ offsetA + ( j * LDA ) + i ] = alpha; + A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; } return A; } // order === 'row-major' for ( j = 0; j < min( M, N ); j++ ) { for ( i = j + 1; i < M; i++ ) { - A[ offsetA + ( i * LDA ) + j ] = alpha; + A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; } return A; } @@ -102,22 +115,22 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { if ( order === 'column-major' ) { for ( j = 0; j < N; j++ ) { for ( i = 0; i < M; i++ ) { - A[ offsetA + ( j * LDA ) + i ] = alpha; + A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; } return A; } // order === 'row-major' for ( j = 0; j < N; j++ ) { for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * LDA ) + j ] = alpha; + A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * LDA ) + i ] = beta; + A[ offsetA + ( i * sa0 )+ ( i * sa1 ) ] = beta; } return A; } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js index bfed810a2674..17824eca4126 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js @@ -50,10 +50,19 @@ var base = require( './base.js' ); * // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ function dlaset( order, uplo, M, N, alpha, beta, A, LDA ) { + var sa1; + var sa2; if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - return base( order, uplo, M, N, alpha, beta, A, LDA, 0 ); + if ( order === 'column-major' ) { + sa1 = 1; + sa2 = LDA; + } else { // order === 'row-major' + sa1 = LDA; + sa2 = 1; + } + return base( order, uplo, M, N, alpha, beta, A, sa1, sa2, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js index 29086addc41e..bc6254275cca 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js @@ -38,7 +38,7 @@ * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js index 0341deec6b80..9560eb610435 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js @@ -37,7 +37,8 @@ var base = require( './base.js' ); * @param {number} alpha - scalar constant to which off-diagonal elements are set * @param {number} beta - scalar constant to which diagonal elements are set * @param {Float64Array} A - input matrix -* @param {PositiveInteger} LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) +* @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 * @returns {Float64Array} `A` @@ -47,14 +48,14 @@ var base = require( './base.js' ); * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ -function dlaset( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) { +function dlaset( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - return base( order, uplo, M, N, alpha, beta, A, LDA, offsetA ); + return base( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); } From 24df4882405101af0c7149ec1b55e5842f6ad7fc Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:00:20 +0530 Subject: [PATCH 08/19] chore: add eslint disable comment to suppress warning for line max len --- lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js index 9560eb610435..11a03a4ebfe5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js @@ -55,7 +55,7 @@ function dlaset( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA if ( !isLayout( order ) ) { throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); } - return base( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + return base( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len } From 707811945cd972e0722f809acfc7916abda0ee0c Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:02:11 +0530 Subject: [PATCH 09/19] refactor: readme for dlaset --- .../@stdlib/lapack/base/dlaset/README.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md index c1a2ea59ff7a..edf97c850847 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md @@ -71,7 +71,7 @@ dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A1, 3 ); // A0 => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` -#### dlaset.ndarray( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) +#### dlaset.ndarray( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. @@ -80,14 +80,24 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); +dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` -The function has the following additional parameters: +The function has the following parameters: +- **order**: storage layout. +- **uplo**: specifies whether the upper or lower triangular part of matrix `A` is supplied. +- **M**: number of rows in `A`. +- **N**: number of columns in `A`. +- **alpha**: scalar constant to which off-diagonal elements are set. +- **beta**: scalar constant to which diagonal elements are set. +- **A**: input [`Float64Array`][mdn-float64array] matrix `A`. +- **strideA1**: stride of the first dimension of `A`. +- **strideA2**: stride of the second dimension of `A`. - **offsetA**: 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, @@ -97,7 +107,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` From f445acda3a1182ea64544ed99ca95ec5b54c1c08 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:02:32 +0530 Subject: [PATCH 10/19] refactor: ndarray tests --- .../lapack/base/dlaset/test/test.ndarray.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js index 06beae6c4cb3..e2c718fc773b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js @@ -64,8 +64,8 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 9', function test( t ) { - t.strictEqual( dlaset.length, 9, 'returns expected value' ); +tape( 'the function has an arity of 10', function test( t ) { + t.strictEqual( dlaset.length, 10, 'returns expected value' ); t.end(); }); @@ -90,7 +90,7 @@ tape( 'the function throws an error if provided an invalid first argument', func function badValue( value ) { return function badValue() { - dlaset( value, 'lower', 2, 2, 3.1, 3.7, A, 2, 0 ); + dlaset( value, 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 0 ); }; } }); @@ -108,7 +108,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ]); - out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N, 5 ); + out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N, 1, 5 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -128,7 +128,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 0.0, 3.7, 0.0, 0.0 ]); - out = dlaset( 'column-major', 'lower', M, N, 3.1, 3.7, A, M, 3 ); + out = dlaset( 'column-major', 'lower', M, N, 3.1, 3.7, A, 1, M, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -148,7 +148,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); - out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N, 3 ); + out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N, 1, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -168,7 +168,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.7, 3.1, 0.0 ]); - out = dlaset( 'column-major', 'upper', M, N, 3.1, 3.7, A, M, 3); + out = dlaset( 'column-major', 'upper', M, N, 3.1, 3.7, A, 1, M, 3); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -188,7 +188,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ]); - out = dlaset( 'row-major', 'all', M, N, 3.1, 3.7, A, N, 3 ); + out = dlaset( 'row-major', 'all', M, N, 3.1, 3.7, A, N, 1, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -208,7 +208,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.7, 3.1, 3.1 ]); - out = dlaset( 'column-major', 'all', M, N, 3.1, 3.7, A, M, 3 ); + out = dlaset( 'column-major', 'all', M, N, 3.1, 3.7, A, 1, M, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); From 09fe4c3f1c8f42299afba3a3fb945cdb47160a1e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:03:36 +0530 Subject: [PATCH 11/19] refactor: repl.txt for dlaset --- .../@stdlib/lapack/base/dlaset/docs/repl.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt index 5cbba33fa236..c8e9d7f5efb8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt @@ -55,7 +55,7 @@ [ 0.0, 3.7, 0.0, 3.1, 3.7 ] -{{alias}}.ndarray( order, uplo, M, N, alpha, beta, A, LDA, offsetA ) +{{alias}}.ndarray( order, uplo, M, N, alpha, beta, A, sa1, sa2, offsetA ) Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. @@ -88,9 +88,11 @@ A: Float64Array Input matrix `A`. - LDA: integer - Stride of the first dimension of `A` (a.k.a., leading dimension of the - matrix `A`). + sa1: integer + Stride of the first dimension of `A`. + + sa2: integer + Stride of the second dimension of `A`. offsetA: integer Starting index for `A`. @@ -105,12 +107,12 @@ // Standard usage: // Standard usage: > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); - > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 0 ) + > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 0 ) [ 3.7, 0.0, 3.1, 3.7 ] // Advanced indexing: > A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1 ) + > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 1 ) [ 0.0, 3.7, 0.0, 3.1, 3.7 ] See Also From 579994b3b5b63a27414f3e02997450771a13a025 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:09:21 +0530 Subject: [PATCH 12/19] refactor: docs/types --- .../lapack/base/dlaset/docs/types/index.d.ts | 9 +- .../lapack/base/dlaset/docs/types/test.ts | 166 ++++++++++-------- 2 files changed, 96 insertions(+), 79 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts index 423d7591a5ba..7cdda7438f3b 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts @@ -58,7 +58,8 @@ interface Routine { * @param alpha - scalar constant to which off-diagonal elements are set * @param beta - scalar constant to which diagonal elements are set * @param A - input matrix - * @param LDA - stride of the first dimension of `A` (a.k.a., leading dimension of the matrix `A`) + * @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` * @@ -67,10 +68,10 @@ interface Routine { * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * - * dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); + * dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ - ndarray( order: Layout, uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, LDA: number, offsetA: number ): Float64Array; + ndarray( order: Layout, uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; } /** @@ -99,7 +100,7 @@ interface Routine { * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); +* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ declare var dlaset: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts index 1012fdc5dc7d..6a5a2697457c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts @@ -114,6 +114,7 @@ import dlaset = require( './index' ); // The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... { + dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3 ); // $ExpectError dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3 ); // $ExpectError dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3 ); // $ExpectError @@ -158,133 +159,147 @@ import dlaset = require( './index' ); { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectType Float64Array + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 5, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( true, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( false, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( null, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( void 0, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( [], 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( {}, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( ( x: number ): number => x, 'lower', 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 5, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( true, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( false, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( null, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( void 0, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( [], 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( {}, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( ( x: number ): number => x, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a second argument which is not a string... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 5, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', true, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', false, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', null, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', void 0, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', [], 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', {}, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 5, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', true, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', false, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', null, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', void 0, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', [], 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', {}, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', '5', 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', true, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', false, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', null, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', void 0, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', [], 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', {}, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', '5', 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', true, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', false, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', null, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', void 0, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', [], 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', {}, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, '5', 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, true, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, false, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, null, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, void 0, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, [], 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, {}, 3.1, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, '5', 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, true, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, false, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, null, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, void 0, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, [], 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, {}, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, '5', 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, true, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, false, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, null, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, void 0, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, [], 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, {}, 3.7, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, '5', 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, true, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, false, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, null, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, void 0, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, [], 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, {}, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a sixth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, '5', A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, true, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, false, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, null, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, void 0, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, [], A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, {}, A, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, '5', A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, true, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, false, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, null, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, void 0, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, [], A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, {}, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... { - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, false, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, null, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, void 0, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, [], 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, {}, 3, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, false, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, null, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, void 0, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, [], 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, {}, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, '5', 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, true, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, false, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, null, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, void 0, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, [], 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, {}, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, '5', 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, true, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, false, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, null, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, void 0, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, [], 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, {}, 1, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, '5' ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, true ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, false ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, null ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, void 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, [] ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, {} ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, ( x: number ): number => x ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, '5', 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, true, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, false, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, null, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, void 0, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, [], 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, {}, 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, '5' ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, true ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, false ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, null ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, void 0 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, [] ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, {} ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -300,5 +315,6 @@ import dlaset = require( './index' ); dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7 ); // $ExpectError dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A ); // $ExpectError dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 0, 10 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); // $ExpectError + dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0, 10 ); // $ExpectError } From 3d76c837c8dc1e8580fe5ddb74ebd548e5659440 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:10:20 +0530 Subject: [PATCH 13/19] refactor: ndarray benchmark --- .../@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js index b328c83bad71..9678ca3ad269 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaset( 'column-major', 'lower', N, N, 3.1, 3.7, A, N, 0 ); + z = dlaset( 'column-major', 'lower', N, N, 3.1, 3.7, A, 1, N, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } From 8348363da31d939fbed13c0c8ebdaff93d1fb95d Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Tue, 16 Jul 2024 17:22:17 +0530 Subject: [PATCH 14/19] chore: use fast min as stated --- lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index 4dab91e4c078..6e7f48cb6000 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -20,7 +20,7 @@ // MODULES // -var min = require( '@stdlib/math/base/special/min' ); +var min = require( '@stdlib/math/base/special/fast/min' ); // MAIN // From 4bbdc8fa56a817b0972c91b31a754a448dd6d852 Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 3 Aug 2024 13:36:30 +0530 Subject: [PATCH 15/19] refactor: base implementation --- .../@stdlib/lapack/base/dlaset/README.md | 9 +- .../dlaset/benchmark/benchmark.ndarray.js | 2 +- .../@stdlib/lapack/base/dlaset/docs/repl.txt | 17 +- .../lapack/base/dlaset/docs/types/index.d.ts | 7 +- .../lapack/base/dlaset/docs/types/test.ts | 189 ++++++++---------- .../@stdlib/lapack/base/dlaset/lib/base.js | 188 ++++++++++------- .../@stdlib/lapack/base/dlaset/lib/dlaset.js | 2 +- .../@stdlib/lapack/base/dlaset/lib/index.js | 2 +- .../@stdlib/lapack/base/dlaset/lib/ndarray.js | 12 +- .../@stdlib/lapack/base/dlaset/test/test.js | 1 + .../lapack/base/dlaset/test/test.ndarray.js | 42 +--- 11 files changed, 224 insertions(+), 247 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md index edf97c850847..fd82d112be5c 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/README.md +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/README.md @@ -65,13 +65,13 @@ var Float64Array = require( '@stdlib/array/float64' ); var A0 = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); // Create offset views... -var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 1st element +var A1 = new Float64Array( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); // start at 2nd element dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A1, 3 ); // A0 => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` -#### dlaset.ndarray( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) +#### dlaset.ndarray( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. @@ -80,13 +80,12 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); +dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` The function has the following parameters: -- **order**: storage layout. - **uplo**: specifies whether the upper or lower triangular part of matrix `A` is supplied. - **M**: number of rows in `A`. - **N**: number of columns in `A`. @@ -107,7 +106,7 @@ var Float64Array = require( '@stdlib/array/float64' ); var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); -dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); +dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] ``` diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js index 9678ca3ad269..b17411a9c11d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/benchmark/benchmark.ndarray.js @@ -63,7 +63,7 @@ function createBenchmark( N ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - z = dlaset( 'column-major', 'lower', N, N, 3.1, 3.7, A, 1, N, 0 ); + z = dlaset( 'lower', N, N, 3.1, 3.7, A, 1, N, 0 ); if ( isnan( z[ i%z.length ] ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt index c8e9d7f5efb8..a5d75eebcef5 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/repl.txt @@ -47,15 +47,8 @@ > {{alias}}( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2 ) [ 3.7, 0.0, 3.1, 3.7 ] - // Using typed array views: - > var A0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - > var A1 = new {{alias:@stdlib/array/float64}}( A0.buffer, A0.BYTES_PER_ELEMENT*1 ); - > {{alias}}( 'row-major', 'lower', 2, 2, 3.1, 3.7, A1, 2 ); - > A0 - [ 0.0, 3.7, 0.0, 3.1, 3.7 ] - -{{alias}}.ndarray( order, uplo, M, N, alpha, beta, A, sa1, sa2, offsetA ) +{{alias}}.ndarray( uplo, M, N, alpha, beta, A, sa1, sa2, offsetA ) Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. @@ -65,10 +58,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 the upper or lower triangular matrix of `A` is supplied. @@ -107,12 +96,12 @@ // Standard usage: // Standard usage: > var A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] ); - > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 0 ) + > {{alias}}.ndarray( 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 0 ) [ 3.7, 0.0, 3.1, 3.7 ] // Advanced indexing: > A = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - > {{alias}}.ndarray( 'row-major', 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 1 ) + > {{alias}}.ndarray( 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 1 ) [ 0.0, 3.7, 0.0, 3.1, 3.7 ] See Also diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts index 7cdda7438f3b..b334940ef7bc 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/index.d.ts @@ -51,7 +51,6 @@ interface Routine { /** * Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. * - * @param order - storage layout * @param uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied * @param M - number of rows in matrix `A` * @param N - number of columns in matrix `A` @@ -68,10 +67,10 @@ interface Routine { * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * - * dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); + * dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ - ndarray( order: Layout, uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; + ndarray( uplo: string, M: number, N: number, alpha: number, beta: number, A: Float64Array, strideA1: number, strideA2: number, offsetA: number ): Float64Array; } /** @@ -100,7 +99,7 @@ interface Routine { * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); +* dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ declare var dlaset: Routine; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts index 6a5a2697457c..a41a79632d42 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/docs/types/test.ts @@ -159,147 +159,133 @@ import dlaset = require( './index' ); { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectType Float64Array + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectType Float64Array } // The compiler throws an error if the function is provided a first argument which is not a string... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 5, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( true, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( false, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( null, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( void 0, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( [], 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( {}, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( ( x: number ): number => x, 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 5, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( true, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( false, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( null, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( void 0, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( [], 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( {}, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3, 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 A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 5, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', true, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', false, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', null, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', void 0, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', [], 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', {}, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', ( x: number ): number => x, 3, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', '5', 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', true, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', false, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', null, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', void 0, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', [], 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', {}, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a third argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', '5', 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', true, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', false, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', null, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', void 0, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', [], 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', {}, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', ( x: number ): number => x, 3, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, '5', 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, true, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, false, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, null, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, void 0, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, [], 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, {}, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, '5', 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, true, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, false, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, null, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, void 0, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, [], 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, {}, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, ( x: number ): number => x, 3.1, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, '5', 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, true, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, false, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, null, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, void 0, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, [], 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, {}, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, '5', 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, true, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, false, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, null, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, void 0, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, [], 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, {}, 3.7, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, ( x: number ): number => x, 3.7, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, '5', A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, true, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, false, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, null, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, void 0, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, [], A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, {}, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3, 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 sixth argument which is not a Float64Array... { - const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, '5', A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, true, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, false, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, null, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, void 0, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, [], A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, {}, A, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, ( x: number ): number => x, A, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, '5', 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, 5, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, true, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, false, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, null, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, void 0, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, [], 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, {}, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3, 1, 0 ); // $ExpectError } -// The compiler throws an error if the function is provided a seventh argument which is not a Float64Array... +// The compiler throws an error if the function is provided a seventh argument which is not a number... { + const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, '5', 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, 5, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, true, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, false, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, null, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, void 0, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, [], 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, {}, 3, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, ( x: number ): number => x, 3, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, '5', 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, true, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, false, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, null, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, void 0, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, [], 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, {}, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x, 1, 0 ); // $ExpectError } // The compiler throws an error if the function is provided an eighth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, '5', 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, true, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, false, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, null, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, void 0, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, [], 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, {}, 1, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, ( x: number ): number => x, 1, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, '5', 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, true, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, false, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, null, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, void 0, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, [], 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, {}, 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, ( x: number ): number => x, 0 ); // $ExpectError } // The compiler throws an error if the function is provided a ninth argument which is not a number... { const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, '5', 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, true, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, false, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, null, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, void 0, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, [], 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, {}, 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, ( x: number ): number => x, 0 ); // $ExpectError -} - -// The compiler throws an error if the function is provided a tenth argument which is not a number... -{ - const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, '5' ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, true ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, false ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, null ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, void 0 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, [] ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, {} ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, ( x: number ): number => x ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, '5' ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, true ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, false ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, null ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, void 0 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, [] ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, {} ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -307,14 +293,13 @@ import dlaset = require( './index' ); const A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); dlaset.ndarray(); // $ExpectError - dlaset.ndarray( 'row-major' ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower' ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); // $ExpectError - dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0, 10 ); // $ExpectError + dlaset.ndarray( 'lower' ); // $ExpectError + dlaset.ndarray( 'lower', 3 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1 ); // $ExpectError + dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0, 10 ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index 6e7f48cb6000..dc2531f7a5c9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -23,14 +23,12 @@ var min = require( '@stdlib/math/base/special/fast/min' ); -// MAIN // +// FUNCTIONS // /** -* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Initializes the upper triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. * * @private -* @param {string} order - storage layout -* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {number} alpha - scalar constant to which off-diagonal elements are set @@ -44,98 +42,136 @@ var min = require( '@stdlib/math/base/special/fast/min' ); * @example * var Float64Array = require( '@stdlib/array/float64' ); * -* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); -* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +* setUpper( 2, 3, 3.1, 3.7, A, 3, 1, 0 ); +* // A => [ 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ] */ -function dlaset( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len - var sa0; - var sa1; +function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { var i; var j; - if ( order === 'row-major' ) { - // For row-major matrices, the last dimension has the fastest changing index... - sa0 = strideA2; // stride for innermost loop - sa1 = strideA1; // stride for outermost loop - } else { // order == 'column-major' - // For column-major matrices, the first dimension has the fastest changing index... - sa0 = strideA1; // stride for innermost loop - sa1 = strideA2; // stride for outermost loop - } - - if ( uplo === 'upper' ) { - if ( order === 'column-major' ) { - for ( j = 1; j < N; j++ ) { - for ( i = 0; i < min( j - 1, M ); i++ ) { - A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; - } - } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; - } - return A; - } - // order === 'row-major' - for ( j = 1; j < N; j++ ) { - for ( i = 0; i < min( j - 1, M ); i++ ) { - A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; - } + for ( j = 1; j < N; j++ ) { + for ( i = 0; i < min( j - 1, M ); i++ ) { + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; - } - return A; } - if ( uplo === 'lower' ) { - if ( order === 'column-major' ) { - for ( j = 0; j < min( M, N ); j++ ) { - for ( i = j + 1; i < M; i++ ) { - A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; - } - } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; - } - return A; - } - // order === 'row-major' - for ( j = 0; j < min( M, N ); j++ ) { - for ( i = j + 1; i < M; i++ ) { - A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; - } - } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; - } - return A; + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ] = beta; } - // All of the matrix `A` - if ( order === 'column-major' ) { - for ( j = 0; j < N; j++ ) { - for ( i = 0; i < M; i++ ) { - A[ offsetA + ( j * sa1 ) + ( i * sa0 ) ] = alpha; - } - } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 ) + ( i * sa1 ) ] = beta; + return A; +} + +/** +* Initializes the lower triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @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` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* setLower( 2, 3, 3.1, 3.7, A, 3, 1, 0 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ] +*/ +function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var i; + var j; + for ( j = 0; j < min( M, N ); j++ ) { + for ( i = j + 1; i < M; i++ ) { + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; } - return A; } - // order === 'row-major' + for ( i = 0; i < min( M, N ); i++ ) { + A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ] = beta; + } + return A; +} + +/** +* Initializes all of triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @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` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* setAll( 2, 3, 3.1, 3.7, A, 3, 1, 0 ); +* // A => [ 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ] +*/ +function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var i; + var j; + for ( j = 0; j < N; j++ ) { for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * sa1 ) + ( j * sa0 ) ] = alpha; + A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; } } for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * sa0 )+ ( i * sa1 ) ] = beta; + A[ offsetA + ( i * strideA2 )+ ( i * strideA1 ) ] = beta; } return A; } +// MAIN // + +/** +* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* +* @private +* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} alpha - scalar constant to which off-diagonal elements are set +* @param {number} beta - scalar constant to which diagonal elements are set +* @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` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* dlaset( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 0 ); +* // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] +*/ +function dlaset( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + if ( uplo === 'upper' ) { + return setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + } + if ( uplo === 'lower' ) { + return setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); + } + return setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ); +} + + // EXPORTS // module.exports = dlaset; diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js index 17824eca4126..13ab0d7ec43d 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js @@ -62,7 +62,7 @@ function dlaset( order, uplo, M, N, alpha, beta, A, LDA ) { sa1 = LDA; sa2 = 1; } - return base( order, uplo, M, N, alpha, beta, A, sa1, sa2, 0 ); + return base( uplo, M, N, alpha, beta, A, sa1, sa2, 0 ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js index bc6254275cca..cd30d8e13ac8 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js @@ -38,7 +38,7 @@ * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset.ndarray( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); +* dlaset.ndarray( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js index 11a03a4ebfe5..8d8d101d1b95 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js @@ -20,8 +20,6 @@ // MODULES // -var isLayout = require( '@stdlib/blas/base/assert/is-layout' ); -var format = require( '@stdlib/string/format' ); var base = require( './base.js' ); @@ -30,7 +28,6 @@ var base = require( './base.js' ); /** * Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. * -* @param {string} order - storage layout * @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` @@ -48,14 +45,11 @@ var base = require( './base.js' ); * * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * -* dlaset( 'row-major', 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); +* dlaset( 'lower', 3, 3, 3.1, 3.7, A, 3, 1, 1 ); * // A => [ 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0, 3.1, 3.1, 3.7 ] */ -function dlaset( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // eslint-disable-line max-len - if ( !isLayout( order ) ) { - throw new TypeError( format( 'invalid argument. First argument must be a valid order. Value: `%s`.', order ) ); - } - return base( order, uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); // eslint-disable-line max-len +function dlaset( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + return base( uplo, M, N, alpha, beta, A, strideA1, strideA2, offsetA ); } diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js index b1b9bf5ac416..d22fe58f3fed 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js @@ -1,3 +1,4 @@ + /** * @license Apache-2.0 * diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js index e2c718fc773b..5a0c696eda87 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js @@ -64,37 +64,11 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'the function has an arity of 10', function test( t ) { - t.strictEqual( dlaset.length, 10, 'returns expected value' ); +tape( 'the function has an arity of 9', function test( t ) { + t.strictEqual( dlaset.length, 9, 'returns expected value' ); t.end(); }); -tape( 'the function throws an error if provided an invalid first argument', function test( t ) { - var values; - var A; - var i; - - values = [ - 'foo', - 'bar', - 'beep', - 'boop' - ]; - - A = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); - - 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() { - dlaset( value, 'lower', 2, 2, 3.1, 3.7, A, 2, 1, 0 ); - }; - } -}); - tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, lower, offsetA = 5)', function test( t ) { var expected; var out; @@ -108,7 +82,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ]); - out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N, 1, 5 ); + out = dlaset( 'lower', M, N, 3.1, 3.7, A, N, 1, 5 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -128,7 +102,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 0.0, 3.7, 0.0, 0.0 ]); - out = dlaset( 'column-major', 'lower', M, N, 3.1, 3.7, A, 1, M, 3 ); + out = dlaset( 'lower', M, N, 3.1, 3.7, A, 1, M, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -148,7 +122,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); - out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N, 1, 3 ); + out = dlaset( 'upper', M, N, 3.1, 3.7, A, N, 1, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -168,7 +142,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 0.0, 3.7, 3.1, 0.0 ]); - out = dlaset( 'column-major', 'upper', M, N, 3.1, 3.7, A, 1, M, 3); + out = dlaset( 'upper', M, N, 3.1, 3.7, A, 1, M, 3); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -188,7 +162,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ]); - out = dlaset( 'row-major', 'all', M, N, 3.1, 3.7, A, N, 1, 3 ); + out = dlaset( 'all', M, N, 3.1, 3.7, A, N, 1, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); @@ -208,7 +182,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 3.1, 3.7, 3.1, 3.1 ]); - out = dlaset( 'column-major', 'all', M, N, 3.1, 3.7, A, 1, M, 3 ); + out = dlaset( 'all', M, N, 3.1, 3.7, A, 1, M, 3 ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); From 915f7e1f6460c2fa647d14e77de7c14441f465cf Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sat, 3 Aug 2024 13:37:25 +0530 Subject: [PATCH 16/19] chore: remove empty header line from test.js --- lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js index d22fe58f3fed..b1b9bf5ac416 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.js @@ -1,4 +1,3 @@ - /** * @license Apache-2.0 * From a4ad93b82cc93c39336202797fd48f0a417aeb35 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Sat, 3 Aug 2024 13:53:02 -0700 Subject: [PATCH 17/19] refactor: reduce redundant computation, create helper, and update descriptions --- .../@stdlib/lapack/base/dlaset/lib/base.js | 70 ++++++++++++++----- .../@stdlib/lapack/base/dlaset/lib/dlaset.js | 4 +- .../@stdlib/lapack/base/dlaset/lib/index.js | 2 +- .../@stdlib/lapack/base/dlaset/lib/ndarray.js | 5 +- 4 files changed, 58 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index dc2531f7a5c9..8ba1b31d9bed 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -26,7 +26,42 @@ var min = require( '@stdlib/math/base/special/fast/min' ); // FUNCTIONS // /** -* Initializes the upper triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Sets the diagonal of a matrix `A` to `β`. +* +* @private +* @param {NonNegativeInteger} M - number of rows in matrix `A` +* @param {NonNegativeInteger} N - number of columns in matrix `A` +* @param {number} beta - scalar constant to which diagonal elements are set +* @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` +* @returns {Float64Array} `A` +* +* @example +* var Float64Array = require( '@stdlib/array/float64' ); +* +* var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); +* +* setDiagonal( 2, 3, 3.7, A, 3, 1, 0 ); +* // A => [ 3.7, 0.0, 0.0, 0.0, 3.7, 0.0 ] +*/ +function setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ) { + var sa; + var ia; + var i; + + sa = strideA1 + strideA2; + ia = offsetA; + for ( i = 0; i < min( M, N ); i++ ) { + A[ ia ] = beta; + ia += sa; + } + return A; +} + +/** +* Initializes the upper triangular/trapezoidal part of a matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -48,22 +83,22 @@ var min = require( '@stdlib/math/base/special/fast/min' ); * // A => [ 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ] */ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var ia; var i; var j; for ( j = 1; j < N; j++ ) { - for ( i = 0; i < min( j - 1, M ); i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; + ia = offsetA + ( j*strideA2 ); + for ( i = 0; i < min( j-1, M ); i++ ) { + A[ ia+(i*strideA1) ] = alpha; } } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ] = beta; - } + setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); return A; } /** -* Initializes the lower triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Initializes the lower triangular/trapezoidal part of a matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -85,21 +120,22 @@ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { * // A => [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ] */ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var ia; var i; var j; + for ( j = 0; j < min( M, N ); j++ ) { + ia = offsetA + ( j*strideA2 ); for ( i = j + 1; i < M; i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; + A[ ia+(i*strideA1) ] = alpha; } } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * strideA2 ) + ( i * strideA1 ) ] = beta; - } + setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); return A; } /** -* Initializes all of triangular/trapezoidal part of a matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Initializes all of triangular/trapezoidal part of a matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @private * @param {NonNegativeInteger} M - number of rows in matrix `A` @@ -121,17 +157,17 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { * // A => [ 3.7, 3.1, 3.1, 3.1, 3.7, 3.1 ] */ function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { + var ia; var i; var j; for ( j = 0; j < N; j++ ) { + ia = offsetA + ( j*strideA2 ); for ( i = 0; i < M; i++ ) { - A[ offsetA + ( i * strideA1 ) + ( j * strideA2 ) ] = alpha; + A[ ia+(i*strideA1) ] = alpha; } } - for ( i = 0; i < min( M, N ); i++ ) { - A[ offsetA + ( i * strideA2 )+ ( i * strideA1 ) ] = beta; - } + setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); return A; } @@ -139,7 +175,7 @@ function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { // MAIN // /** -* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Initializes an `M` by `N` matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @private * @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js index 13ab0d7ec43d..4e91a0fca1e9 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/dlaset.js @@ -28,10 +28,10 @@ var base = require( './base.js' ); // MAIN // /** -* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* Initializes an `M` by `N` matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @param {string} order - storage layout -* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {string} uplo - specifies whether to set the upper or lower triangular part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {number} alpha - scalar constant to which off-diagonal elements are set diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js index cd30d8e13ac8..7170d7df5659 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* LAPACK routine to initialize an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals. +* LAPACK routine to initialize an `M` by `N` matrix `A` to `β` on the diagonal and `α` on the off-diagonals. * * @module @stdlib/lapack/base/dlaset * diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js index 8d8d101d1b95..65004b203157 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/ndarray.js @@ -26,9 +26,9 @@ var base = require( './base.js' ); // MAIN // /** -* Initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals using alternative indexing semantics. +* Initializes an `M` by `N` matrix `A` to `β` on the diagonal and `α` on the off-diagonals using alternative indexing semantics. * -* @param {string} uplo - specifies whether the upper or lower triangular part of matrix `A` is supplied +* @param {string} uplo - specifies whether to set the upper or lower triangular part of matrix `A` * @param {NonNegativeInteger} M - number of rows in matrix `A` * @param {NonNegativeInteger} N - number of columns in matrix `A` * @param {number} alpha - scalar constant to which off-diagonal elements are set @@ -37,7 +37,6 @@ 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 * @returns {Float64Array} `A` * * @example From 7b025cb73182046e6bb360eb076c3bb42668ab0e Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sun, 4 Aug 2024 13:56:35 +0530 Subject: [PATCH 18/19] refactor: base implementation --- .../@stdlib/lapack/base/dlaset/lib/base.js | 49 ++++++++++++++++--- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js index 8ba1b31d9bed..9e27b94883ed 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/lib/base.js @@ -20,6 +20,7 @@ // MODULES // +var isRowMajor = require( '@stdlib/ndarray/base/assert/is-row-major' ); var min = require( '@stdlib/math/base/special/fast/min' ); @@ -80,17 +81,30 @@ function setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ) { * var A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); * * setUpper( 2, 3, 3.1, 3.7, A, 3, 1, 0 ); -* // A => [ 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ] +* // A => [ 3.7, 3.1, 0.0, 0.0, 3.7, 0.0 ] */ function setUpper( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { var ia; var i; var j; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i = 0; i < M; i++ ) { + ia = offsetA + ( i * strideA1 ); + for ( j = i + 1; j < min( M, N ); j++ ) { + if ( i !== j ) { + A[ ia + ( j * strideA2 ) ] = alpha; + } + } + } + setDiagonal( M, N, beta, A, strideA2, strideA1, offsetA ); + return A; + } + // 'column-major' for ( j = 1; j < N; j++ ) { - ia = offsetA + ( j*strideA2 ); - for ( i = 0; i < min( j-1, M ); i++ ) { - A[ ia+(i*strideA1) ] = alpha; + ia = offsetA + ( j * strideA2 ); + for ( i = 0; i < min( j - 1, M ); i++ ) { + A[ ia + ( i * strideA1 ) ] = alpha; } } setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); @@ -124,10 +138,22 @@ function setLower( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { var i; var j; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i = 0; i < M; i++ ) { + ia = offsetA + ( i * strideA1 ); + for ( j = i; j >= 0; j-- ) { + if ( i !== j ) { + A[ ia + ( j*strideA2 ) ] = alpha; + } + } + } + setDiagonal( M, N, beta, A, strideA2, strideA1, offsetA ); + } + // 'column-major' for ( j = 0; j < min( M, N ); j++ ) { ia = offsetA + ( j*strideA2 ); for ( i = j + 1; i < M; i++ ) { - A[ ia+(i*strideA1) ] = alpha; + A[ ia + ( i*strideA1 ) ] = alpha; } } setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); @@ -161,10 +187,21 @@ function setAll( M, N, alpha, beta, A, strideA1, strideA2, offsetA ) { var i; var j; + if ( isRowMajor( [ strideA1, strideA2 ] ) ) { + for ( i = 0; i < M; i++ ) { + ia = offsetA + ( i*strideA1 ); + for ( j = 0; j < N; j++ ) { + A[ ia + ( j*strideA2 ) ] = alpha; + } + } + setDiagonal( M, N, beta, A, strideA2, strideA1, offsetA ); + return A; + } + // 'column-major' for ( j = 0; j < N; j++ ) { ia = offsetA + ( j*strideA2 ); for ( i = 0; i < M; i++ ) { - A[ ia+(i*strideA1) ] = alpha; + A[ ia + ( i*strideA1 ) ] = alpha; } } setDiagonal( M, N, beta, A, strideA1, strideA2, offsetA ); From b27de0c70d4ecb80773352afcad027cb6c13f7ac Mon Sep 17 00:00:00 2001 From: Pranavchiku Date: Sun, 4 Aug 2024 13:57:25 +0530 Subject: [PATCH 19/19] test: update description and add more tests --- .../lapack/base/dlaset/test/test.dlaset.js | 36 +++++++-- .../lapack/base/dlaset/test/test.ndarray.js | 78 +++++++++++++++++-- 2 files changed, 100 insertions(+), 14 deletions(-) diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js index ce5f85136464..c8a8f05c34f6 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.dlaset.js @@ -95,7 +95,7 @@ tape( 'the function throws an error if provided an invalid first argument', func } }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, lower)', function test( t ) { +tape( 'the function sets lower part of a rectangular matrix (row-major, lower)', function test( t ) { var expected; var out; var A; @@ -109,13 +109,14 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon expected = new Float64Array( [ 3.7, 0.0, 0.0, 3.1, 3.7, 0.0 ]); out = dlaset( 'row-major', 'lower', M, N, 3.1, 3.7, A, N ); + console.log( out ); t.strictEqual( out, A, 'returns expected value' ); isApprox( t, A, expected, 2.0 ); t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, lower)', function test( t ) { +tape( 'the function sets lower part of a column major rectangular matrix (column-major, lower)', function test( t ) { var expected; var out; var A; @@ -135,7 +136,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, upper)', function test( t ) { +tape( 'the function sets upper part of rectangular matrix (row-major, upper)', function test( t ) { var expected; var out; var A; @@ -146,7 +147,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon N = 3; A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Float64Array( [ 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); + expected = new Float64Array( [ 3.7, 3.1, 0, 0, 3.7, 0.0 ]); out = dlaset( 'row-major', 'upper', M, N, 3.1, 3.7, A, N ); t.strictEqual( out, A, 'returns expected value' ); @@ -155,7 +156,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, upper)', function test( t ) { +tape( 'the function sets upper part of column major rectangular matrix (column-major, upper)', function test( t ) { var expected; var out; var A; @@ -175,7 +176,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, all)', function test( t ) { +tape( 'the function sets all of rectangular matrix (row-major, all)', function test( t ) { var expected; var out; var A; @@ -195,7 +196,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, all)', function test( t ) { +tape( 'the function sets all of column major rectangular matrix (column-major, all)', function test( t ) { var expected; var out; var A; @@ -214,3 +215,24 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); + +tape( 'the function correctly sets a square matrix `A`', function test( t ) { + var expected; + var out2; + var out; + var A; + + A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); + expected = new Float64Array( [ 3.7, 3.1, 3.1, 3.1, 0.0, 3.7, 3.1, 3.1, 0.0, 0.0, 3.7, 3.1, 0.0, 0.0, 0.0, 3.7 ] ); + + out = dlaset( 'row-major', 'upper', 4, 4, 3.1, 3.7, A, 4 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + + out = dlaset( 'row-major', 'lower', 4, 4, 3.1, 3.7, A, 4 ); + t.strictEqual( out, A, 'returns expected value' ); + out2 = dlaset( 'row-major', 'all', 4, 4, 3.1, 3.7, A, 4 ); + t.strictEqual( out2, A, 'returns expected value' ); + t.strictEqual( out, out2, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js index 5a0c696eda87..d36e74ab75da 100644 --- a/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/lapack/base/dlaset/test/test.ndarray.js @@ -69,7 +69,7 @@ tape( 'the function has an arity of 9', function test( t ) { t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, lower, offsetA = 5)', function test( t ) { +tape( 'the function allows specifying offset and sets lower part of the given rectangular matrix (row-major, lower, offsetA = 5)', function test( t ) { var expected; var out; var A; @@ -89,7 +89,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, lower, offsetA = 3)', function test( t ) { +tape( 'the function allows specifying offset and sets lower part of the given column major rectangular matrix (column-major, lower, offsetA = 3)', function test( t ) { var expected; var out; var A; @@ -109,7 +109,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, upper, offsetA = 3)', function test( t ) { +tape( 'the function allows specifying offset and sets upper part of the given rectangular matrix (row-major, upper, offsetA = 3)', function test( t ) { var expected; var out; var A; @@ -120,7 +120,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon N = 3; A = new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ); - expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 0.0, 3.1, 0.0, 3.7, 0.0 ]); + expected = new Float64Array( [ 0.0, 0.0, 0.0, 3.7, 3.1, 0, 0, 3.7, 0.0 ]); out = dlaset( 'upper', M, N, 3.1, 3.7, A, N, 1, 3 ); t.strictEqual( out, A, 'returns expected value' ); @@ -129,7 +129,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, upper, offsetA = 3)', function test( t ) { +tape( 'the function allows specifying offset and sets upper part of the given column major rectangular matrix (column-major, upper, offsetA = 3)', function test( t ) { var expected; var out; var A; @@ -149,7 +149,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (row-major, all, offsetA = 3)', function test( t ) { +tape( 'the function allows specifying offset and sets all of the given rectangular matrix (row-major, all, offsetA = 3)', function test( t ) { var expected; var out; var A; @@ -169,7 +169,7 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); -tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagonal and `alpha` on the off-diagonals (column-major, all, offsetA = 3)', function test( t ) { +tape( 'the function allows specifying offset and sets all of the given column major rectangular matrix (column-major, all, offsetA = 3)', function test( t ) { var expected; var out; var A; @@ -188,3 +188,67 @@ tape( 'the function initializes an `M` by `N` matrix `A` to `beta` on the diagon t.end(); }); + +tape( 'the function allows accessing elements from non contiguous arrangement of row and column (row-major)', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 4, 999, 5, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 6, + 999, 999, 999, 999, 999, 999 + ]); + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 3.7, 999, 3.1, 999, 3.1, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 3.7, 999, 3.1, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 3.7, + 999, 999, 999, 999, 999, 999 + ]); + + out = dlaset( 'upper', 3, 3, 3.1, 3.7, A, 12, 2, 7 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +}); + +tape( 'the function allows access elements from non contiguous arrangement of row and column in reverse order (row-major)', function test( t ) { + var expected; + var out; + var A; + + /* eslint-disable array-element-newline, no-multi-spaces */ + + A = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 1, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 4, 999, 5, + 999, 999, 999, 999, 999, 999, + 999, 0, 999, 0, 999, 6, + 999, 999, 999, 999, 999, 999 + ]); + expected = new Float64Array([ + 999, 999, 999, 999, 999, 999, + 999, 3.7, 999, 2, 999, 3, + 999, 999, 999, 999, 999, 999, + 999, 3.1, 999, 3.7, 999, 5, + 999, 999, 999, 999, 999, 999, + 999, 3.1, 999, 3.1, 999, 3.7, + 999, 999, 999, 999, 999, 999 + ]); + + out = dlaset( 'upper', 3, 3, 3.1, 3.7, A, -12, -2, 35 ); + t.strictEqual( out, A, 'returns expected value' ); + isApprox( t, A, expected, 2.0 ); + t.end(); +});